Author Topic: Font Sizes  (Read 1478 times)

skeptic mike

  • Posts: 8
Font Sizes
« on: 11 Jan '21 - 18:52 »
I'm scripting the production of the skin using ImageMagick, as I'm interested in scaling for different monitors. I'm producing a very plain skin using material icons in shades of pale gray.
I'm a bit puzzled about specifying font sizes. On my standard windows desktop (96 dpi) fonts I specify in skinconfig.txt seem to come out at 3/4 of the size I specify. Is this expected?
Also I'm trying to figure out how I should size the mask elements where text is written. (Or size the text for a given mask element height.) It looks as though about 7/4 of the actual font size is appropriate, although this may be font dependent. e.g. Specify 16 point, get 12 point, looks right in 21 pixel high space. The line spacing in the Info window feels different with different fonts at the same nominal size. e.g. If changed from Segoe UI to Arial it seems more cramped.

I'd be grateful for any advice.

Mike

Ian @ un4seen

  • Administrator
  • Posts: 24940
Re: Font Sizes
« Reply #1 on: 12 Jan '21 - 14:45 »
The font size is the character height in pixels. XMPlay negates the value before passing it to the CreateFont function:

   https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createfonta

From the formula on that page, the point size will indeed be 3/4 (72/96) of the value with 96 DPI.

The height of the masks will depend on how much space you want around the text, but they should probably be at least a bit above the font size to prevent it being too cramped. XMPlay will centre the text vertically within the masked area.

skeptic mike

  • Posts: 8
Re: Font Sizes
« Reply #2 on: 13 Jan '21 - 15:02 »
Thankyou. I think I understand now. I've confused pixels and points. Microsoft produces a reasonable explanation here:
 https://docs.microsoft.com/en-us/windows/win32/learnwin32/dpi-and-device-independent-pixels
XMPlay uses pixel sizes for fonts - skins are pixel sized . Windows at 96dpi will normally increase the size by 4/3. so. I was comparing pixel and point sized fonts.

On line and text spacing, default line spacing seems to be a characteristic of the font family metrics. I couldn't find a simple way to get them, but the example code in https://docs.microsoft.com/en-us/dotnet/desktop/winforms/advanced/how-to-obtain-font-metrics shows how to do it.

The ratio of emHeight to line spacing varies, it's 1.15 for Arial and 1.33 for Segoe UI. This accords with the observed line spacing I see for the two fonts in an info window.

Rah'Dick

  • Posts: 988
Re: Font Sizes
« Reply #3 on: 14 Jan '21 - 10:35 »
@ skeptic mike:
In case you're interested, I wrote an automatic skin scaler script with web and command line interface a while ago. It's Open Source:
http://rahdick.at/sonstiges/xmplay-skin-scaler/xmplay-skin-scaler-web.php
https://github.com/ThomasRadeke/xmplay-skin-scaler

I admit I haven't used it in a while, it might need some fixes now.