Java Font Size vs HTML Font Size
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 ?
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
精彩评论