Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java custom Font not working in html jlabels

I'm making an application with some custom fonts.

I have several JLabels, one of which has simple html text (starts and ends with html tag + has BR tags). My font's are A, B, C and D (loaded from disk).

Setting the font for the html JLabel only gives a visible effect if using font A or B. (the JLabel will not use the provided font, but a default font)

Removing the html tags form the JLabel makes font C and D work as well.

Setting the font for any non-html JLabel works fine with all fonts.

Anyone know why only some fonts work with html JLabels, is there a way around this? and is there a way to tell which fonts will not work with it?

like image 459
klogd Avatar asked Mar 28 '26 21:03

klogd


1 Answers

when you use html tags java uses a html engine to render the html content .. this means that the font names defined in your markup would be referencing the system's cache of fonts and not your app .. this is the reason why your app isn't displaying the font you've defined..

you can try and install the font locally on the machine and use it in your HTML.

like image 79
Anantha Sharma Avatar answered Mar 31 '26 05:03

Anantha Sharma