Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-platform solution for Arial font

Tags:

java

fonts

swing

In my Swing application I use Arial font. Unfortunately it is rendered differently on different platforms:

Windows:

Windows variant

Mac OS X:

enter image description here

Linux:

enter image description here

Windows and Mac OS X variants look almost the same. Linux is quite different and seems to be not an Arial at all. Main problem is the different width of letters...

What would be the best solution that would render text similar to Windows variant on Linux? Probably some alternative fonts like for example Nimbus Sans L?

Some limitations: JRE cannot be supplied with the application and it should be very close to Arial.

Thanks!

like image 602
Andrej Avatar asked May 20 '26 10:05

Andrej


1 Answers

Embrace platform variety. Given that different platforms have similar fonts with different metrics, let each component do the work of calculating its own preferred size by not interfering and by using layouts correctly. Here's a nice example with screenshots.

like image 124
trashgod Avatar answered May 22 '26 22:05

trashgod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!