Change the default fonts

Posted by pantek on 08-Jan-2020 13:38

Hi

The change of DefaultFont from Arial Unicode MS to Noto Sans results in increase the size of windows and change value of session parameters as follow:
Arial: PIXELS-PER-ROW=29 PIXELS-PER-COLUMN=6
Noto: PIXELS-PER-ROW=29 PIXELS-PER-COLUMN=9

How PROGRESS session calculates values of that parameters?
What kind of font properties are taken into account during this calculation? Where from - windows registry, font table?

Posted by Matt Gilarde on 10-Jan-2020 14:40

I don't know how Windows calculates tmAveCharWidth. Try setting CharWidth=6 in the Startup section of the registry or your ini file. This may accomplish what you're looking for.

All Replies

Posted by Matt Gilarde on 08-Jan-2020 14:18

PIXELS-PER-ROW is the height of the default font multiplied by 1.5. PIXELS-PER-COLUMN is the average character width of the default font. The font's height and average character width are gotten by querying the font itself.

Posted by pantek on 08-Jan-2020 19:26

Thank You Matt for the answer. Can you explain what height it is about? From INI file? And what exactly mean "are gotten by querying the font itself" ?

Posted by Matt Gilarde on 08-Jan-2020 19:59

When you set DefaultFont you tell us a typeface (Arial, Noto, etc.), a size in points, and other optional attributes such as bold, italic, underline, etc. All of those things together specify a font. We ask Windows to create the font and then we ask Windows how big characters in that font are in pixels.

Different fonts can have different heights and widths even if the size you tell us is the same. For example, the default font is MS Sans Serif, size=8 and the default fixed font is Courier New, size=8. Size=8 isn't enough to tell us how tall or wide a character in that font will be. We have to create the font and ask it how big it is. The average width of a character in Courier New is wider than the average width of a character in MS Sans Serif. If your case, the average width of a character in Noto is wider than the average width of a character in Arial.

Posted by pantek on 09-Jan-2020 07:08

Everything is clear and understandable. But how You exactly ask Windows OS about font height and width in pixels? You read some keys from register or call some functions from Windows API? You know, I'm looking for font features that affect its width in pixels. That's why I asked about the session parameter PIXELS-PER-COLUMN. It's calculated on session start, and affect on windows and frames size (and all of screen objects). In our software we used Arial Unicode MS font. But this font has become paid. After replace Arial Unicode MS with Noto Sans Regular, the size of windows, frames etc, has changed - everything have become wider. It's because value of PIXELS-PER-COLUMN has changed from 6 - for Arial, to 9 - for Noto.

Posted by pantek on 09-Jan-2020 10:13

Ok. All this is clear and understandable. But how You ask Windows about font size in pixels? Do You get value of some keys from the windows registry? Or do You call some functions in Windows API? What determines the value of PIXELS-PER-COLUMN during progress session start? What font property?

Posted by Marko Myllymäki on 09-Jan-2020 10:57

IIRC, in Windows 7 also the selected Windows font size (text scaling) affected the pixels-per-row/pixels-per-column values. But now in Windows 10 the font size does not seem to affect those values. Matt, could you please verify if this is correct? I'm using OpenEdge 11.7.5.

I think the pixels-per-row/pixels-per-column values should be settable by the application so that we could create scalable applications more easily. Relying on DefaultFont is too restrictive.

Posted by pantek on 09-Jan-2020 12:07

Ok Matt. All this is clear and understandable. But how You ask Windows about font size in pixels? Do You get value of some keys from the windows registry? Or do You call some functions in Windows API? What determines the value of PIXELS-PER-COLUMN during progress session start? What font property?

Posted by pantek on 09-Jan-2020 12:24

I apologize for the duplicate messages. After clicking on the Reply button messages did not appear. Now I see them all.

Posted by Matt Gilarde on 09-Jan-2020 12:39

We create the font with CreateFontIndirect. Then we use GetTextMetrics to fill a TEXTMETRIC structure with information about the font. Structure member tmHeight is the font height and tmAveCharWidth is the average character width.

PIXELS-PER-ROW = tmHeight * 3 / 2

PIXELS-PER-COLUMN = tmAveCharWidth

Posted by Matt Gilarde on 09-Jan-2020 12:58

[quote user="Marko Myllymäki"]

IIRC, in Windows 7 also the selected Windows font size (text scaling) affected the pixels-per-row/pixels-per-column values. But now in Windows 10 the font size does not seem to affect those values. Matt, could you please verify if this is correct? I'm using OpenEdge 11.7.5.[/quote]That is correct. Text scaling in older versions of Windows used to change the actual font files for some fonts, including MS Sans Serif. For example, if you scaled to 150%, the normal font files were replaced with ones which had characters which were 50% larger. When OpenEdge asked for the font size the values were larger so PIXELS-PER-ROW and PIXELS-PER-COLUMN became larger. Windows 10 doesn't do this so the font size values stay consistent.

[quote user="Marko Myllymäki"]I think the pixels-per-row/pixels-per-column values should be settable by the application so that we could create scalable applications more easily. Relying on DefaultFont is too restrictive.[/quote]Sounds like a good enhancement request.

Posted by pantek on 10-Jan-2020 14:06

Thanj You Matt. Ok. Now we khow how PIXELS-PER-COLUMN is calculated. Maybe You know what font properties affect on tmAveCharWidth value? I can;t fint it. I would try to modify Noto Sans font to get the value of PIXELS-PER-COLUMN similar as for Arial Unicode. I use FontLab software.

Posted by Matt Gilarde on 10-Jan-2020 14:40

I don't know how Windows calculates tmAveCharWidth. Try setting CharWidth=6 in the Startup section of the registry or your ini file. This may accomplish what you're looking for.

Posted by pantek on 13-Jan-2020 10:31

It looks very good. Thank You Matt. I need to set the right value for changing the font size, but this is manageable. It could be described in the documentation for the session parameter PIXELS-PER-ROW/COLUMNS. Well, unless there are any risks in using this parameter?

This thread is closed