I am writing text on an image . I am using DrawString(x,y,string) method and I set font size as below
Font font = new Font(fontName, fontWeight, fontSize);
As you can see left side text written on image with 12pt size. Right side you can see 12pt size in HTML . Is there any way to map this so that I get same size in output as user sees in HTML ?
"The 'text-' properties are working rendered text without modifying of the characters geometry. The 'font-' properties are working with raw characters and imparts the specific form to them".
The default text size in browsers is 16px. So, the default size of 1em is 16px.
To change the font size in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-size. HTML5 do not support the <font> tag, so the CSS style is used to add font size.
Explanation. The Maximum font size in font drop down is 96 and minimum is 6 . 12 is default size for font size drop-down.
I found this link. Maybe useful. Try it out.
Basically it says 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 suggests
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);
I believe this is because java assumes 72 dpi display, where most everything else uses 96dpi now?
see: http://download.oracle.com/javase/tutorial/2d/text/fonts.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With