• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bold not working on a local font

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have a font in my jar file (to make my software cross platform) so that my panel can look the same also if the font is not installed in the system.
To load the font I do this:


For PLAIN text that's ok, works perfectly with all font sizes.
When I turn to BOLD the problems start...
Using the same InputStream with the Font.BOLD derivation doesn't work, but that's could be ok because the file cointaining the BOLD font is tahomabd.tff. (even if it's not totally true because with a label in HTML format the BOLD works and it shouldn't !?!?!?)

So I tried this:


I can also change Font.BOLD with Font.PLAIN (assuming that the font is already BOLD) but the result is the same: no BOLD at all.
In conclusion, importing tahoma.ttf or tahomabd.ttf makes no difference and setting Font.PLAIN or Font.BOLD still makes no difference, no BOLD text at all.
This happens only for BOLD, since Italic for example works as expected.
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also posted at: http://www.dreamincode.net/forums/topic/410373-bold-not-working-on-a-local-font/
 
Luca Vanon
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, it's the second time that someone tells me that the post is present in another forum...
Is it a bad thing?
I think that it's normal to ask the same question in different forums to get more answers...
 
Norm Radder
Rancher
Posts: 5008
38
 
Luca Vanon
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry, my fault...
I will let other people know when I cross post in the future.
From my point of view, cross posting is a good thing, if someone gives me a solution in another forum and I repost it here it's just more knowledge for everyone.
But no problem, I will write it next time.
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Luca Vanon wrote:. . .  if someone gives me a solution in another forum and I repost it here it's just more knowledge for everyone. . . . .

. . . and two people expend a great deal of effort simultaneously answering the same question.
 
Luca Vanon
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's probably the philosophy of a forum...
More people answering at the same time the same question, that's what you normally do on a forum, right?
If I have an answer I'm not gonna say: Oh, there is already someone working on that, they certainly don't need my solution...
But that's my opinion...
By the way, anyone considering a solution for my problem?
Thanks
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start by formatting the code so we can actually read it.
 
Luca Vanon
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I'm back from the weekend...
Here is the code for the plain tahoma font, size 16, file tahoma.ttf:

Setting Font.BOLD makes no changes (even if on the labels with HTML content the bold tag makes the text bold).

Here's the code for the bold font, file tahomabd.ttf, size 16:

This appear like the first one, even if the file loaded should be the bold one.
Changing Font.PLAIN or Font.BOLD makes no difference.
The code runs with no errors on the console.
 
Luca Vanon
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just an update...
Using arial instead of tahoma with the only file arial.ttf (no arialbd.ttf loaded) seems to work setting Font.BOLD.
I prefer to use tahoma if I can get it to work....
 
Luca Vanon
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another update.
The problem in tahoma bold only happens when I load the stream from the ttf file (no matter if it's tahoma.ttf or tahomabd.ttf, the result is always not bold).
Using system fonts like this:

Works perfectly, but obviously this will not work if the font is not installed in the system.
 
Luca Vanon
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking better (examining pixels) it seems that something change actually loading tahoma.ttf or tahomabd.ttf and also setting Font.PLAIN or Font.BOLD, so I guess I'm doing things correctly.
But every combination I try it never looks like setting the system font.
In other words:

Doesn't look like:

The second really looks BOLD, the first is like thicker than PLAIN, but not really BOLD...
 
reply
    Bookmark Topic Watch Topic
  • New Topic