wxOSX Translate Courier and Times font names (PR #22355)

40 views
Skip to first unread message

Stefan Csomor

unread,
Apr 24, 2022, 6:21:08 AM4/24/22
to wx-...@googlegroups.com, Subscribed

under macOS 12 Monterey Courier and Times are no more, now always use the new versions (existing since macOS 10.7). and fix native font info toString roundtrip problems


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/22355

Commit Summary

  • a64b2c6 always switching to ‚new‘ variants of Times and Courier on macOS, fixing roundtrip test

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355@github.com>

VZ

unread,
Apr 25, 2022, 6:37:20 PM4/25/22
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

Thanks!

It looks like this ought to be split in 2 different commits as the 2 changes don't seem to be dependent on each other (unless I'm missing something), do you mind if I commit them as 2 commits to facilitate exploring the history later?

I'd also like to change FamilyToFaceName() in the same file to use the new font names -- even if the old ones get translated, it still seems better to use the actual font names directly to make things more clear. Would you mind if I did this?

And, as mentioned below, I'd appreciate if you could please explain the rationale for v3 font info format, either by pushing an additional commit to this branch or just leaving it in a comment directly here.

TIA!


In src/osx/carbon/font.cpp:

> @@ -1171,8 +1194,10 @@ wxString wxNativeFontInfo::ToString() const

             xml.Replace("\t",wxEmptyString,true);

             xml = xml.Mid(xml.Find("<plist"));

 

-            s.Printf("%d;%d;%d;%d;%s",

-                 2, // version

+            s.Printf("%d;%d;%d;%d;%d;%d;%s",

+                 3, // version

The comment above needs to be updated to explain the v3 format rather than v2 which is not used any longer. In particular, I'd really like to know why do we include style but not weight into it now (and while I have some conjectures about the family, I'd appreciate having an explanation for it too).


In src/osx/carbon/font.cpp:

> @@ -927,6 +927,11 @@ void wxNativeFontInfo::CreateCTFontDescriptor()

         if ( fontname.empty() )

             fontname = FamilyToFaceName(m_family);

 

+        if ( fontname == "Courier")

I think we need some explanation here as it doesn't seem to be that obvious, e.g.

⬇️ Suggested change
-        if ( fontname == "Courier")

+        // Courier and Times fonts used to be available everywhere and so are commonly

+        // hard-coded in the applications (even though they shouldn't be, and "teletype"

+        // or "roman" font family should be used instead), so make sure we still support

+        // them even if macOS > 12 doesn't have any fonts with these names any more.

+        if ( fontname == "Courier")


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/review/952517184@github.com>

Stefan Csomor

unread,
Apr 26, 2022, 1:49:21 AM4/26/22
to wx-...@googlegroups.com, Push

@csomor pushed 1 commit.

  • 0412cc2 Update src/osx/carbon/font.cpp


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/push/9719170317@github.com>

Stefan Csomor

unread,
Apr 26, 2022, 5:08:32 AM4/26/22
to wx-...@googlegroups.com, Subscribed

@csomor commented on this pull request.


In src/osx/carbon/font.cpp:

> @@ -1171,8 +1194,10 @@ wxString wxNativeFontInfo::ToString() const
             xml.Replace("\t",wxEmptyString,true);
             xml = xml.Mid(xml.Find("<plist"));
 
-            s.Printf("%d;%d;%d;%d;%s",
-                 2, // version
+            s.Printf("%d;%d;%d;%d;%d;%d;%s",
+                 3, // version

The font tests showed that a font created from a font info string was not getting family nor italic round-trip correct. I was exporting a string from the native font descriptor as xml and had to add what was missing in front (v2), now the tests showed that two other properties were not roundtrip correct.

Eg a font could have a slant variant natively (thus expressed in the descriptor) or emulated by wx (normal font in font descriptor, slant matrix applied when constructing the font itself, 3rd param in CTFontCreateWithFontDescriptor).

Deducing the font family does not work the way I thought it would, apparently the stylistic font class information is not always available. At least not from the descriptor alone. So while I try to find out whether I can make this work natively, exposing the family like this makes test pass correctly.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/review/953032490@github.com>

VZ

unread,
Apr 27, 2022, 1:41:53 PM4/27/22
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.


In src/osx/carbon/font.cpp:

> @@ -1171,8 +1194,10 @@ wxString wxNativeFontInfo::ToString() const
             xml.Replace("\t",wxEmptyString,true);
             xml = xml.Mid(xml.Find("<plist"));
 
-            s.Printf("%d;%d;%d;%d;%s",
-                 2, // version
+            s.Printf("%d;%d;%d;%d;%d;%d;%s",
+                 3, // version

I don't think making the tests pass under Mac is the highest priority -- it would be great if they passed, of course, but what we really need is for things to work correctly and I'm not totally sure if these changes actually achieve this. I.e. if it's just a temporary hack to make the tests pass, I'd rather avoid changing the format and add Mac-specific checks to the tests instead.

In response to the last question, I think wxNativeFontInfo should only be available when the corresponding native font is available, otherwise what's the point of using it? The rationale for it is to be able to exactly preserve, without any loss due to round tripping between it and wx font description, any native font. As long as we don't have any native font, we shouldn't need wxNativeFontInfo at all.

Because of this I'm also not sure at all if storing wx family in the serialized representation really makes sense...


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/review/955308799@github.com>

VZ

unread,
Apr 27, 2022, 1:44:48 PM4/27/22
to wx-...@googlegroups.com, Subscribed

It looks like this ought to be split in 2 different commits as the 2 changes don't seem to be dependent on each other (unless I'm missing something), do you mind if I commit them as 2 commits to facilitate exploring the history later?

I'd like to apply the first commit ("Use actually existing fonts") already, do you mind if I do this?

I'd also like to change FamilyToFaceName() in the same file to use the new font names -- even if the old ones get translated, it still seems better to use the actual font names directly to make things more clear. Would you mind if I did this?

I'd also still like to do this too.

And, as mentioned below, I'd appreciate if you could please explain the rationale for v3 font info format, either by pushing an additional commit to this branch or just leaving it in a comment directly here.

AFAICS this change is less critical and so could wait and, also, unless you're absolutely sure it's correct and the v3 format is here to stay, I'd rather not change the format now only to possibly change it again very soon.

So, to summarize, I'd like to partially apply this a.s.a.p. but leave the serialization format-related changes for later unless you're definitely certain that we should apply them now. Please let me know what do you think, TIA!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/c1111303215@github.com>

Stefan Csomor

unread,
Apr 27, 2022, 2:13:45 PM4/27/22
to wx-...@googlegroups.com, Subscribed

@vadz I'm fine with merging the font names part, so go ahead :-)

and if there is no need for a native font info to be preserved if the font it wants to express is not available, I'll store the descriptor back after a font resolution, thus the font family should work, I hope at least ...


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/c1111328854@github.com>

Stefan Csomor

unread,
Apr 27, 2022, 2:17:45 PM4/27/22
to wx-...@googlegroups.com, Subscribed

@csomor commented on this pull request.


In src/osx/carbon/font.cpp:

> @@ -1171,8 +1194,10 @@ wxString wxNativeFontInfo::ToString() const
             xml.Replace("\t",wxEmptyString,true);
             xml = xml.Mid(xml.Find("<plist"));
 
-            s.Printf("%d;%d;%d;%d;%s",
-                 2, // version
+            s.Printf("%d;%d;%d;%d;%d;%d;%s",
+                 3, // version

No the reason would not be to make the tests work, but to make things work as expected. So the style must be working correctly, this will be needed, either by the style flag or by adding a matrix transform, the first seemed to be easier, so this will be remain, but regarding the family, there is another option, see below ...


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/review/955353604@github.com>

VZ

unread,
Apr 27, 2022, 6:57:20 PM4/27/22
to wx-...@googlegroups.com, Subscribed

OK, done now, thanks!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/c1111557490@github.com>

VZ

unread,
Apr 27, 2022, 6:57:26 PM4/27/22
to wx-...@googlegroups.com, Subscribed

Closed #22355 via 5f7d4a7.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/issue_event/6510638118@github.com>

Stefan Csomor

unread,
Apr 28, 2022, 1:20:13 AM4/28/22
to wx-...@googlegroups.com, Subscribed

@vadz what is the best way to continue with the remaining part, a new PR or reopening this ?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/c1111756847@github.com>

VZ

unread,
Apr 28, 2022, 7:42:05 AM4/28/22
to wx-...@googlegroups.com, Subscribed

I think the best would be to create a new PR, as this one was just about the font names and this part got applied. TIA!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/c1112102709@github.com>

Stefan Csomor

unread,
Apr 28, 2022, 1:05:34 PM4/28/22
to wx-...@googlegroups.com, Subscribed

ok, done in #22373


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/22355/c1112450340@github.com>

Reply all
Reply to author
Forward
0 new messages