• 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

Calculate Font Size With dimension screen

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.

I hope you are safe and healthy.

I want to talk about a problem with load personal font inside application java Swing.

I'm developing a new Open-source L&F that import material style in swing, now in at this time I'm losing with a problem with a Java font.

I will describe the problem.

I'm loading the font with this code



I think after you read the code, you have a question, Why you calculate the dimension font with this formula:  

The answer at your question is because if I only the dimension inside the font, I see the pixeled result, like this



If I use the screen resolution I can fix this problem and the result is this



But, now I have a problem with dimension font with a display with high resolution, the font is very small, as these pictures



Now I'm thinking of building a solution, as to create a set of default dimensions, For example, XXX_DISPLAY, XX_DISPLAY, X_DISPLAY.
This solution was implemented inside the android framework when adapting the icon at different screen dimensions.

But Before starting work I want to talk and exchange ideas about this problem.

I'm losing somethings to calculate correctly the font dimension?

P.S: I noted that with the JDK version >= 10 the pixel effect if not present but with JDK 8 is present.
 
Ranch Hand
Posts: 127
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the pixelation issue is fixed in more recent versions one can get from this that your issue in earlier versions is a rendering bug happen at some other point out of your direct control.
As for the general idea: Although screens and resolutions currently getting bigger and bigger I would recommend against some fixed values but try to work out how to calculate them on the fly. Reason: You assume that there're only so many resolutions where in fact anything from a single pixel up to infinity (or at least the max of some datatype) in any ratio, shape and form can be true.
So I suggest try to figure out if the issue is with our LaF only or if this also happens to standard LaF Java comes with. If it's only your LaF I guess it's time for some "creative inspiration" (copy'n'paste) - if it's also with the default LaF it's most likely cause Java (or at least the version you get this) is just not optimized for such a high resolution.
Think about when Java 8 was released. Back then anything larger than FullHD was still very exotic and just about to rise over the horizon like an early morning sunrise. As with time the number of 1440 and 4k and even bigger resolutions became more common so did Javas development evolved (or not for that fact).
Also: Developing a LaF from scratch sounds a hard task for one alone or a small team without the required basics or knowledge. So don't feel shy about copy some lines of the existing LaF - these are the work of several people over decades of time, nothing you can reproduce in what's an instant in comparison.
 
Vincenzo Palazzo
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your answer and agree with you, I will try to understand what is the problem.

P.S: The develop a new L&F is hard but is cool if you want generate feedback this is the project

Thanks for sharing your opinion about the post
 
reply
    Bookmark Topic Watch Topic
  • New Topic