Set font weight bold programatically to true type font - cn1
up vote
1
down vote
favorite
I've a font name abc.ttf which gives bold in html web if font weight is set to bold but in codenameone, it never gives bold font. How can I achieve that?
The following code doesn't gives the bold font.
Font fnt = Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD);
serviceTypeLabel.getAllStyles().setFont(fnt);
In theme how can we set bold font to .ttf file

Update 1:
Using bold ttf works fine but only half of the letters are seen. Have a look at the image below. Here service no 12 is only half visible:

codenameone
add a comment |
up vote
1
down vote
favorite
I've a font name abc.ttf which gives bold in html web if font weight is set to bold but in codenameone, it never gives bold font. How can I achieve that?
The following code doesn't gives the bold font.
Font fnt = Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD);
serviceTypeLabel.getAllStyles().setFont(fnt);
In theme how can we set bold font to .ttf file

Update 1:
Using bold ttf works fine but only half of the letters are seen. Have a look at the image below. Here service no 12 is only half visible:

codenameone
Where isn't this working? Is the setting saved? Does it work on the simulator, device etc? Looking at the code this should work roughly the same way.
– Shai Almog
Nov 20 at 5:16
The problem is that the text is not bold. Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD); This line has no effect.
– beck
Nov 20 at 9:20
If it doesn't work in the code it won't work in the UI either. Usually TTFs are divided to separate versions for bold/regular etc. You would need the TTF matching bold. That second field is ignored for almost all fonts.
– Shai Almog
Nov 21 at 5:19
I used bold ttf file and it works but only half of the letters are seen. What happened? Plz see the update above.
– beck
Nov 23 at 5:51
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I've a font name abc.ttf which gives bold in html web if font weight is set to bold but in codenameone, it never gives bold font. How can I achieve that?
The following code doesn't gives the bold font.
Font fnt = Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD);
serviceTypeLabel.getAllStyles().setFont(fnt);
In theme how can we set bold font to .ttf file

Update 1:
Using bold ttf works fine but only half of the letters are seen. Have a look at the image below. Here service no 12 is only half visible:

codenameone
I've a font name abc.ttf which gives bold in html web if font weight is set to bold but in codenameone, it never gives bold font. How can I achieve that?
The following code doesn't gives the bold font.
Font fnt = Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD);
serviceTypeLabel.getAllStyles().setFont(fnt);
In theme how can we set bold font to .ttf file

Update 1:
Using bold ttf works fine but only half of the letters are seen. Have a look at the image below. Here service no 12 is only half visible:

codenameone
codenameone
edited Nov 23 at 5:54
asked Nov 19 at 10:19
beck
1,2451612
1,2451612
Where isn't this working? Is the setting saved? Does it work on the simulator, device etc? Looking at the code this should work roughly the same way.
– Shai Almog
Nov 20 at 5:16
The problem is that the text is not bold. Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD); This line has no effect.
– beck
Nov 20 at 9:20
If it doesn't work in the code it won't work in the UI either. Usually TTFs are divided to separate versions for bold/regular etc. You would need the TTF matching bold. That second field is ignored for almost all fonts.
– Shai Almog
Nov 21 at 5:19
I used bold ttf file and it works but only half of the letters are seen. What happened? Plz see the update above.
– beck
Nov 23 at 5:51
add a comment |
Where isn't this working? Is the setting saved? Does it work on the simulator, device etc? Looking at the code this should work roughly the same way.
– Shai Almog
Nov 20 at 5:16
The problem is that the text is not bold. Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD); This line has no effect.
– beck
Nov 20 at 9:20
If it doesn't work in the code it won't work in the UI either. Usually TTFs are divided to separate versions for bold/regular etc. You would need the TTF matching bold. That second field is ignored for almost all fonts.
– Shai Almog
Nov 21 at 5:19
I used bold ttf file and it works but only half of the letters are seen. What happened? Plz see the update above.
– beck
Nov 23 at 5:51
Where isn't this working? Is the setting saved? Does it work on the simulator, device etc? Looking at the code this should work roughly the same way.
– Shai Almog
Nov 20 at 5:16
Where isn't this working? Is the setting saved? Does it work on the simulator, device etc? Looking at the code this should work roughly the same way.
– Shai Almog
Nov 20 at 5:16
The problem is that the text is not bold. Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD); This line has no effect.
– beck
Nov 20 at 9:20
The problem is that the text is not bold. Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD); This line has no effect.
– beck
Nov 20 at 9:20
If it doesn't work in the code it won't work in the UI either. Usually TTFs are divided to separate versions for bold/regular etc. You would need the TTF matching bold. That second field is ignored for almost all fonts.
– Shai Almog
Nov 21 at 5:19
If it doesn't work in the code it won't work in the UI either. Usually TTFs are divided to separate versions for bold/regular etc. You would need the TTF matching bold. That second field is ignored for almost all fonts.
– Shai Almog
Nov 21 at 5:19
I used bold ttf file and it works but only half of the letters are seen. What happened? Plz see the update above.
– beck
Nov 23 at 5:51
I used bold ttf file and it works but only half of the letters are seen. What happened? Plz see the update above.
– beck
Nov 23 at 5:51
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You should use a bold TTF font. When applying the font you need to apply it to all states. If you do it after layout you need to animate the layout or revalidate. Since the bold font has different measurements.
yeahh I used it in unselected, selected, pressed in theme and set it as UIId of the component. I have used revalidate() at the end of the code as well... But it is not fully shown in devices and simulator too.
– beck
Nov 24 at 5:48
What type of code was used to generate the screenshot you provided? All of those things collide with one another so you need to pick one strategy and make sure it works correctly.
– Shai Almog
Nov 25 at 5:28
I'm reopening a question, its messy here. And I found out the issue is odd. Have a look at the specific question for it: stackoverflow.com/questions/53465390/…
– beck
Nov 25 at 7:13
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You should use a bold TTF font. When applying the font you need to apply it to all states. If you do it after layout you need to animate the layout or revalidate. Since the bold font has different measurements.
yeahh I used it in unselected, selected, pressed in theme and set it as UIId of the component. I have used revalidate() at the end of the code as well... But it is not fully shown in devices and simulator too.
– beck
Nov 24 at 5:48
What type of code was used to generate the screenshot you provided? All of those things collide with one another so you need to pick one strategy and make sure it works correctly.
– Shai Almog
Nov 25 at 5:28
I'm reopening a question, its messy here. And I found out the issue is odd. Have a look at the specific question for it: stackoverflow.com/questions/53465390/…
– beck
Nov 25 at 7:13
add a comment |
up vote
0
down vote
You should use a bold TTF font. When applying the font you need to apply it to all states. If you do it after layout you need to animate the layout or revalidate. Since the bold font has different measurements.
yeahh I used it in unselected, selected, pressed in theme and set it as UIId of the component. I have used revalidate() at the end of the code as well... But it is not fully shown in devices and simulator too.
– beck
Nov 24 at 5:48
What type of code was used to generate the screenshot you provided? All of those things collide with one another so you need to pick one strategy and make sure it works correctly.
– Shai Almog
Nov 25 at 5:28
I'm reopening a question, its messy here. And I found out the issue is odd. Have a look at the specific question for it: stackoverflow.com/questions/53465390/…
– beck
Nov 25 at 7:13
add a comment |
up vote
0
down vote
up vote
0
down vote
You should use a bold TTF font. When applying the font you need to apply it to all states. If you do it after layout you need to animate the layout or revalidate. Since the bold font has different measurements.
You should use a bold TTF font. When applying the font you need to apply it to all states. If you do it after layout you need to animate the layout or revalidate. Since the bold font has different measurements.
answered Nov 24 at 5:09
Shai Almog
39.1k52553
39.1k52553
yeahh I used it in unselected, selected, pressed in theme and set it as UIId of the component. I have used revalidate() at the end of the code as well... But it is not fully shown in devices and simulator too.
– beck
Nov 24 at 5:48
What type of code was used to generate the screenshot you provided? All of those things collide with one another so you need to pick one strategy and make sure it works correctly.
– Shai Almog
Nov 25 at 5:28
I'm reopening a question, its messy here. And I found out the issue is odd. Have a look at the specific question for it: stackoverflow.com/questions/53465390/…
– beck
Nov 25 at 7:13
add a comment |
yeahh I used it in unselected, selected, pressed in theme and set it as UIId of the component. I have used revalidate() at the end of the code as well... But it is not fully shown in devices and simulator too.
– beck
Nov 24 at 5:48
What type of code was used to generate the screenshot you provided? All of those things collide with one another so you need to pick one strategy and make sure it works correctly.
– Shai Almog
Nov 25 at 5:28
I'm reopening a question, its messy here. And I found out the issue is odd. Have a look at the specific question for it: stackoverflow.com/questions/53465390/…
– beck
Nov 25 at 7:13
yeahh I used it in unselected, selected, pressed in theme and set it as UIId of the component. I have used revalidate() at the end of the code as well... But it is not fully shown in devices and simulator too.
– beck
Nov 24 at 5:48
yeahh I used it in unselected, selected, pressed in theme and set it as UIId of the component. I have used revalidate() at the end of the code as well... But it is not fully shown in devices and simulator too.
– beck
Nov 24 at 5:48
What type of code was used to generate the screenshot you provided? All of those things collide with one another so you need to pick one strategy and make sure it works correctly.
– Shai Almog
Nov 25 at 5:28
What type of code was used to generate the screenshot you provided? All of those things collide with one another so you need to pick one strategy and make sure it works correctly.
– Shai Almog
Nov 25 at 5:28
I'm reopening a question, its messy here. And I found out the issue is odd. Have a look at the specific question for it: stackoverflow.com/questions/53465390/…
– beck
Nov 25 at 7:13
I'm reopening a question, its messy here. And I found out the issue is odd. Have a look at the specific question for it: stackoverflow.com/questions/53465390/…
– beck
Nov 25 at 7:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372489%2fset-font-weight-bold-programatically-to-true-type-font-cn1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Where isn't this working? Is the setting saved? Does it work on the simulator, device etc? Looking at the code this should work roughly the same way.
– Shai Almog
Nov 20 at 5:16
The problem is that the text is not bold. Font.createTrueTypeFont("abc.ttf", 3).derive(40, Font.STYLE_BOLD); This line has no effect.
– beck
Nov 20 at 9:20
If it doesn't work in the code it won't work in the UI either. Usually TTFs are divided to separate versions for bold/regular etc. You would need the TTF matching bold. That second field is ignored for almost all fonts.
– Shai Almog
Nov 21 at 5:19
I used bold ttf file and it works but only half of the letters are seen. What happened? Plz see the update above.
– beck
Nov 23 at 5:51