Quicksand bold not rendering as expected when bold - flutter

As in picture R & A word is...
Here are my code as in picture below
child: Text(
'RENTAL SUMMARY',
style: TextStyle(
fontFamily: 'quicksand',
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20,
),
),

Please download the quicksand font from Google fonts. Add this to your pubspec yaml and try again. Maybe the ttf you have is corrupted

Related

Text is shifted vertically in Flutter

I have the following code:
AutoSizeText.rich(
TextSpan(children: [
const TextSpan(
text: "\$",
style: TextStyle(
color: Colors.white,
fontSize: 45,
height: 1.0,
letterSpacing: .0,
fontWeight: FontWeight.w600,
),
),
TextSpan(
text: widget.budget.truncate().toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 90,
),
),
TextSpan(
text: ".${widget.budget.toStringAsFixed(2).split(".")[1]}",
style: const TextStyle(
color: Colors.white,
fontSize: 45,
),
),
]),
style: GoogleFonts.manrope(
fontSize: 45,
letterSpacing: -4.5,
height: 1.0,
fontWeight: FontWeight.w600,
textStyle: const TextStyle(
leadingDistribution: TextLeadingDistribution.even,
)),
textAlign: TextAlign.center,
maxLines: 1,
);
The code results in this (I also tried with Text.rich instead of AutoSizeText but the result is the same):
In the image, I have wrapped the text in a red container to check its bounding box.
I am implementing this element following a design I made in Figma:
Similatly, in this image the red frame has an autolayout applied with all padding set to 0, in a way that simulates wrapping the text in a Container.
The text looks the same in both the design and the Flutter implementation, but the Flutter one is shifted upwards, which on big text sizes is really noticeable. I figured it might have something to do with the vertical alignment of the text but I could not find any way to fix it.
Is this an expected behaviour or am I doing something wrong?

How to make simple internationalization with flutter without json file?

I search to internationalize my app. I have lot of text, I search a simple and fast way to add english trad to my all text.
Here is the structure of all my text
Text('Mytext',
textAlign:TextAlign.center, style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400,
fontSize: SizeConfig.safeBlockHorizontal! * 4),
),
I don't know if there is a package of methode to add internationalization like an extention
Text('Mytext.internationalization',
textAlign:TextAlign.center, style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400,
fontSize: SizeConfig.safeBlockHorizontal! * 4),
),
If I can avoid to copy paste all my test to a JSON file and trad all, and change all my text structure it will be cool :)

How to override theme style in flutter

Hi i need text style for example bodyText3,like this
bodyText3: TextStyle(
fontSize: 16,
height: 1.5,
fontWeight: FontWeight.w600,
color: MyColors.black)
but in flutter we have only this styles.
headline1,
headline2,
headline3,
headline4,
headline5,
headline6,
subtitle1,
subtitle2,
bodyText1,
bodyText2,
caption,
What should i do to add my new style ?
Create a Constant to define the style
const TextStyle bodyText3 = TextStyle(
fontSize: 14,
color: darkGrey,
fontWeight: FontWeight.w700,
);
Use this constant in your Text's style property
Text(
'No',
style: bodyText3,
),

Flutter Text overflow

How to control TextOverFlow if don't know the const width of the box.
I know about
Text(
'some Text',
overflow: TextOverflow.ellipsis,
)
but is there any way to wrap widgets like expanded or flexible?
FittedBox(
fit: setToWidth ? BoxFit.contain : BoxFit.none,
child: Text(
displayText,
maxLines: 2,
textAlign: textAlign,
style: setToWidth
? TextStyle(
fontWeight: fontWeight,
color: textColor,
fontFamily: AppFonts.circularStd,
)
: TextStyle(
fontWeight: fontWeight,
color: textColor,
fontFamily: AppFonts.circularStd,
fontSize: textSize),
),
);
Try with this
You can try AutoSizeText instead.
https://pub.dev/packages/auto_size_text
Note: it'll increase your overall app size as it requires external dependencies. But it'll give you some extra features such as maxLines and minLines. I will suggest read more about it.

How to include multiple fonts into single text

I have an Arabic text in a pdf file. When I copy the text into Text Widget it becomes weird characters. When I checked the pdf file properties I found that it uses HQPB1, HQPB2, HQPB3, HQPB4 fonts, so I imported all of these fonts to my pubsec.yaml file. The problem is that I can use only one of these 4 fonts at a time but the pdf file uses all of these 4 fonts simultaneously.
this is the original text from pdf
when I added HQPB1.ttf only
when I added HQPB2.ttf only
So I want to include all of these 4 fonts in a Text so that each individual font should be used when it is needed as pdf does.
RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(text: 'Hello ', style: TextStyle(fontFamily: "Serif", fontSize: 30, color: Colors.black)),
TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.blue, fontSize: 30)),
TextSpan(text: ' world!', style: TextStyle(fontFamily: "Roboto", fontSize: 30, color: Colors.red)),
],
),
)
Output:
In order to have multiple styles on one Text widget you have to use RichText. RichText has a children[] so you can have custom TextStyle (which will use whatever font you want) for each TextSpan
Check it out here -> https://api.flutter.dev/flutter/widgets/RichText-class.html
const Text.rich(
TextSpan(
children: <TextSpan>[
TextSpan(
text: 'Hello ',
style: TextStyle(
fontFamily: "Serif",
fontSize: 30,
color: Colors.black,
),
),
TextSpan(
text: 'bold',
style: TextStyle(
fontFamily: "Arial",
fontWeight: FontWeight.bold,
color: Colors.blue,
fontSize: 30,
),
),
TextSpan(
text: ' world!',
style: TextStyle(
fontFamily: "Roboto",
fontSize: 30,
color: Colors.red,
),
),
],
),
)