Java font size vs HTML font size

I write text on the image. I use the DrawString (x, y, string) method and I set the font size below

Font font = new Font(fontName, fontWeight, fontSize); 

enter image description here

As you can see, the left text is written in a 12pt image. On the right side you can see the size 12pt in HTML. Is there a way to map this so that I get the same size in the output as the user sees in the HTML?

+7
source share
2 answers

I found this link . Maybe useful. Give it a try.

This basically suggests that

 Java assumes 72 dpi screen resolution Windows uses 96 dpi or 120 dpi depending on your font size setting in the display properties. 

The site offers

 instead of using getNormalizingTransform() you have to use getScreenResolution() 


From the website again.

 int screenRes = Toolkit.getDefaultToolkit().getScreenResolution(); int fontSize = (int)Math.round(12.0 * screenRes / 72.0); 
+5
source

I believe that this is due to the fact that java assumes a display of 72 dpi, where most of the rest now use 96dpi?

see http://download.oracle.com/javase/tutorial/2d/text/fonts.html

+2
source

All Articles