Set font weight bold programatically to true type font - cn1
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 |
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 '18 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 '18 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 '18 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 '18 at 5:51
add a comment |
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 '18 at 5:54
beck
asked Nov 19 '18 at 10:19
beckbeck
1,2921612
1,2921612
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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 5:51
add a comment |
1 Answer
1
active
oldest
votes
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 '18 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 '18 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 '18 at 7:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 '18 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 '18 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 '18 at 7:13
add a comment |
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 '18 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 '18 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 '18 at 7:13
add a comment |
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 '18 at 5:09
Shai AlmogShai Almog
40.3k52555
40.3k52555
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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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.
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 '18 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 '18 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 '18 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 '18 at 5:51