Author Topic: Unreadable font when testing wx-master  (Read 8007 times)

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Unreadable font when testing wx-master
« on: August 06, 2019, 04:31:18 pm »
I have just compiled wx-master (88f04f5) with C::B head. My setup was using Fira Code 10 with Direct Write, but when starting the new C::B I got a microfilm font in the edit window (about 2x2 pixels per character, similar to what you get with Ctrl+wheel applied eight times).

Changing the font to Courier New 10 fixed the issue, and later I could return to Fira Code 10 getting a normal sized font.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Unreadable font when testing wx-master
« Reply #1 on: August 06, 2019, 07:01:47 pm »
Do you have the original config file? Can you reproduce the issue? What happens if you move to the previous wx-master?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Unreadable font when testing wx-master
« Reply #2 on: August 07, 2019, 10:27:29 am »
Do you have the original config file? Can you reproduce the issue? What happens if you move to the previous wx-master?

I didn't have the original config file, but today I did the same steps in my home computer and the results are the same 100 %. Steps:
  - Check out commit 88f04f5, current wx-master
  - Activate DIRECT2D in setup.h and compile wx
  - Rebuild C::B with wx-master (you need to apply the patch in ticket 860 before)
  - Save apart default.conf
  - Run update31.bat
  - Start C::B from the output folder
  - The start page is OK
  - Open C::B workspace
  - You get a microfilm in the editor window
  - Switch font from Fira Code 10 to Courier New 10. Close Preferences
  - Switch font from Courier New 10 to Fira Code 10. Close Preferences
  - Now the font size is correct
  - Save apart default.conf

The default.conf diff is attached.

All these tests are made in MSW. I jumped straight from wx3.1.2 to yesterday's wx-master.
« Last Edit: August 07, 2019, 02:52:49 pm by Miguel Gimenez »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Unreadable font when testing wx-master
« Reply #3 on: August 10, 2019, 11:32:10 am »
I have just installed the last nightly in my home computer and I get again the microfont, just like in my C::B head/wxwidgets-master version.

The font is shown as MS sans serif, normal, but no size is shown (should be Fira Code, unless the nightly uses its own conf file).

If I set a size everything go back to normal.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Unreadable font when testing wx-master
« Reply #4 on: August 10, 2019, 04:40:03 pm »
I have just installed the last nightly in my home computer and I get again the microfont, just like in my C::B head/wxwidgets-master version.

The font is shown as MS sans serif, normal, but no size is shown (should be Fira Code, unless the nightly uses its own conf file).

If I set a size everything go back to normal.

Do you have to do that each time you open Code::Blocks?
Or is it just on the first start of Code::Blocks?
(The second start does not need it to be done)

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Unreadable font when testing wx-master
« Reply #5 on: August 10, 2019, 05:11:11 pm »
Once you set the size next starts are normal.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Unreadable font when testing wx-master
« Reply #6 on: August 12, 2019, 09:06:52 pm »
Can you please attach full config file which causes the problem. The diff you've attached doesn't make too much sense.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Unreadable font when testing wx-master
« Reply #7 on: August 12, 2019, 10:39:50 pm »
Here you have it.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Unreadable font when testing wx-master
« Reply #8 on: August 14, 2019, 08:16:00 am »
Now I can reproduce this. I'm 100% sure this is related to the zoom1 value stored in the .layout files. But I've done limited debugging.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Unreadable font when testing wx-master
« Reply #9 on: August 14, 2019, 09:06:35 pm »
nfi.FromString(fontstring); parses the font height to be -13.
Can you reset this font setting in the config file and try to reproduce the problem?
I think they (wx devs) have changed recently something related to this in wx-master.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Unreadable font when testing wx-master
« Reply #10 on: August 15, 2019, 07:36:58 am »
Probably commit 228cd926e27589ee514682513cc8d89aabc9a603 in wxWidgets is causing the problem or is fixing the problem. I don't know. You'll have to test. If it is something caused by wxWidgets, we have to report it.

Does setting the font with a night build (which uses 3.1.1) and then switching to a build using wx-master works correctly?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Unreadable font when testing wx-master
« Reply #11 on: August 15, 2019, 12:02:43 pm »
If I open the nightly I get MS Sans Serif - Normal - Blank size
Opening CB-head with wx-head I get Fira Code - Normal - Size 10
Both cases use the same default.conf and I get a micro font.

In both cases changing anything in the font fixes the issue.

The last four changes to src/mws/font.cpp were in fact related to font sizes, I will check.

EDIT: 3.1.1 saves fonts in V0 format, the rest in V1. The difference is a new parameter, next to the version, with the point size:

3.1.1: <![CDATA[0;-13;0;0;0;400;0;0;0;0;3;2;1;49;Fira Code]]>
3.1.2: <![CDATA[1;0;-13;0;0;0;400;0;0;0;0;3;2;1;49;Fira Code]]>
3.1.3: <![CDATA[1;9.75;-13;0;0;0;400;0;0;0;0;3;2;1;49;Fira Code]]>

The font saved by 3.1.2 has a 0 point size, while the 3.1.3 one has 9.75. This V1 string with 0 point size is what causes the problem.

The font size is read in line 670 of src/msw/font.cpp, but it is not validated; probably line 690 should be changed from

Code
if ( setPointSizeFromHeight )
        pointSize = GetPointSizeFromLogFontHeight(l);

to

Code
if ( (pointSize == 0.0) || setPointSizeFromHeight )
        pointSize = GetPointSizeFromLogFontHeight(l);

I will check if this fixes the issue
« Last Edit: August 15, 2019, 12:39:11 pm by Miguel Gimenez »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Unreadable font when testing wx-master
« Reply #12 on: August 15, 2019, 01:57:45 pm »
OK, the patch works. I will open a ticket in wx site.

The problem is:
  - wx3.1.1 uses v0 format for font-to-string conversion. It doesn't understand v1, so using a wx3.1.2 or newer C:B "corrupts" the font information in default.conf because they save it in v1 format, so wx3.1.1 reverts to a default font (MS Sans Script - Normal - Blank size).
  - wx3.1.2 saves in v1 format but read both. The problem is it saves a 0 point size, but it "corrects" this recalculating the size on load.
  - wx3.1.3 is like 3.1.2, but it uses the value read without checking, so fonts saved with wx3.1.2 will get a near zero size (the closest practical size).

Jumping directly from 3.1.1 to 3.1.3 does not have issues, because 3.1.3 will read the v0 format.

This is a problem normal users won't see because they stick to nightlies, but devs and others like me will find soon or later when changing back and forth between versions.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Unreadable font when testing wx-master
« Reply #13 on: August 15, 2019, 07:23:02 pm »
I'm not sure there is long a term benefit to fix this. The only real issue we should care is moving from cb+wx3.1.2 to cb+wx<3.1.2 or what happens if we go back to a version which doesn't understand v1 font string?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Unreadable font when testing wx-master
« Reply #14 on: August 15, 2019, 07:38:46 pm »
The current nightlies don't understand v1. If you are working with 3.1.2 or newer version you will loose all your font settings when using the nightly, nothing too important. If you mix wxmaster and wx3.1.2 you will then get the micro font, but it also has a simple solution and 3.1.2 has been used only by some people from this forum.

I intend to report this to wx devs because there are more software using wxWidgets that can benefit from this correction.