DevHeads.net

Review Request 123458: Improvements to the handling of font weights and styles

Review request for KDE Software on Mac OS X and Qt KDE.

Repository: qt

Description
Handling of and support for less common font weight/style combinations is far from ideal on OS X but not perfect on Linux either. It is not difficult to run into typefaces that will not be restored properly from settings files for instance, because QFont(family,weight,style) and other methods to obtain a QFont from a font description do not return the appropriate font.
This is especially the case on OS X where the code makes the assumption in at least two locations that anything that isn't "Normal" is "Bold". In other places, including generic code, parsers apply overly course numberic weight classifications or fail to consider weights like "Medium", "Semibold", "Regular", "Roman" etc. (and return a fall-back weight: Normal).
Among the font families that are affected there are als common fonts like Segoe UI and Helvetica Neue (UI fonts on MS Windows and OS X 10.10+). NB: medium/semi-/demi-bold weights are perfect in UIs on high-resolution screens.

The proposed patch improves the code by adding additional checks against style names and weights. The changes are not only to Mac-specific files so Linux benefits from this too (and other platforms ought to, as well).

I'm putting it up for review on here mainly for lack of time to figure out why I failed to get in onto Qt's own code review site. It may appear there too, but if not:

I herewith put the attached code changes in the public domain, for possible inclusion into the Qt 4.x codebase under the license that governs that software.

Diffs
src/gui/dialogs/qfontdialog.cpp d791462
src/gui/dialogs/qfontdialog_mac.mm d557a7a
src/gui/kernel/qt_mac.cpp fb241ce
src/gui/text/qfontdatabase.cpp 4c2ace4
src/gui/text/qfontdatabase_mac.cpp 816a7bd
src/gui/text/qfontengine_coretext.mm 204d685
src/plugins/platforms/fontdatabases/coretext/qcoretextfontdatabase.mm 312015f
tools/qtconfig/mainwindow.cpp 1bb6e4e

Diff: <a href="https://git.reviewboard.kde.org/r/123458/diff/" title="https://git.reviewboard.kde.org/r/123458/diff/">https://git.reviewboard.kde.org/r/123458/diff/</a>

Testing
On OS X 10.9.5 and Kubuntu 14.04.2 against Qt 4.8.7 with the qtconfig utility and the attached test application

File Attachments
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/bbebc0af-e457-4fdf-965c-3918d8e871d0__fontweightissue.pro" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/bbebc0af-e457-4fdf-965c-3918d8e871d0__fontweightissue.pro">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/bbebc0af...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/cfdcbf23-406a-4abf-b0cb-5fdc1957dfe9__main.cpp" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/cfdcbf23-406a-4abf-b0cb-5fdc1957dfe9__main.cpp">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/cfdcbf23...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/9898afae-82ca-4c92-b7d9-5607d0dd8e24__dialog.h" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/9898afae-82ca-4c92-b7d9-5607d0dd8e24__dialog.h">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/9898afae...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/8ad258bf-7f82-4db4-a344-ce81d75e8c50__dialog.cpp" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/8ad258bf-7f82-4db4-a344-ce81d75e8c50__dialog.cpp">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/8ad258bf...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/2f0a7c6e-4601-406e-b703-603a36bff62b__fontweightissue.desktop" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/2f0a7c6e-4601-406e-b703-603a36bff62b__fontweightissue.desktop">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/2f0a7c6e...</a>

Thanks,

René J.V. Bertin

Comments

Re: Review Request 123458: Improvements to the handling of font

By =?utf-8?Q?Ren=C... at 04/21/2015 - 18:01

(Updated April 22, 2015, 12:01 a.m.)

Review request for KDE Software on Mac OS X and Qt KDE.

Repository: qt

Description
Handling of and support for less common font weight/style combinations is far from ideal on OS X but not perfect on Linux either. It is not difficult to run into typefaces that will not be restored properly from settings files for instance, because QFont(family,weight,style) and other methods to obtain a QFont from a font description do not return the appropriate font.
This is especially the case on OS X where the code makes the assumption in at least two locations that anything that isn't "Normal" is "Bold". In other places, including generic code, parsers apply overly course numberic weight classifications or fail to consider weights like "Medium", "Semibold", "Regular", "Roman" etc. (and return a fall-back weight: Normal).
Among the font families that are affected there are als common fonts like Segoe UI and Helvetica Neue (UI fonts on MS Windows and OS X 10.10+). NB: medium/semi-/demi-bold weights are perfect in UIs on high-resolution screens.

The proposed patch improves the code by adding additional checks against style names and weights. The changes are not only to Mac-specific files so Linux benefits from this too (and other platforms ought to, as well).

I'm putting it up for review on here mainly for lack of time to figure out why I failed to get in onto Qt's own code review site. It may appear there too, but if not:

I herewith put the attached code changes in the public domain, for possible inclusion into the Qt 4.x codebase under the license that governs that software.

Diffs (updated)
src/gui/dialogs/qfontdialog.cpp d791462
src/gui/dialogs/qfontdialog_mac.mm d557a7a
src/gui/kernel/qt_mac.cpp fb241ce
src/gui/text/qfontdatabase.cpp 4c2ace4
src/gui/text/qfontdatabase_mac.cpp 816a7bd
src/gui/text/qfontengine_coretext.mm 204d685
src/plugins/platforms/fontdatabases/coretext/qcoretextfontdatabase.mm 312015f
tools/qtconfig/mainwindow.cpp 1bb6e4e

Diff: <a href="https://git.reviewboard.kde.org/r/123458/diff/" title="https://git.reviewboard.kde.org/r/123458/diff/">https://git.reviewboard.kde.org/r/123458/diff/</a>

Testing
On OS X 10.9.5 and Kubuntu 14.04.2 against Qt 4.8.7 with the qtconfig utility and the attached test application

File Attachments
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/bbebc0af-e457-4fdf-965c-3918d8e871d0__fontweightissue.pro" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/bbebc0af-e457-4fdf-965c-3918d8e871d0__fontweightissue.pro">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/bbebc0af...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/cfdcbf23-406a-4abf-b0cb-5fdc1957dfe9__main.cpp" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/cfdcbf23-406a-4abf-b0cb-5fdc1957dfe9__main.cpp">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/cfdcbf23...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/9898afae-82ca-4c92-b7d9-5607d0dd8e24__dialog.h" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/9898afae-82ca-4c92-b7d9-5607d0dd8e24__dialog.h">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/9898afae...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/8ad258bf-7f82-4db4-a344-ce81d75e8c50__dialog.cpp" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/8ad258bf-7f82-4db4-a344-ce81d75e8c50__dialog.cpp">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/8ad258bf...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/2f0a7c6e-4601-406e-b703-603a36bff62b__fontweightissue.desktop" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/2f0a7c6e-4601-406e-b703-603a36bff62b__fontweightissue.desktop">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/2f0a7c6e...</a>

Thanks,

René J.V. Bertin

Re: Review Request 123458: Improvements to the handling of font

By =?utf-8?Q?Ren=C... at 04/21/2015 - 18:06

(Updated April 22, 2015, 12:06 a.m.)

Review request for KDE Software on Mac OS X and Qt KDE.

Repository: qt

Description
Handling of and support for less common font weight/style combinations is far from ideal on OS X but not perfect on Linux either. It is not difficult to run into typefaces that will not be restored properly from settings files for instance, because QFont(family,weight,style) and other methods to obtain a QFont from a font description do not return the appropriate font.
This is especially the case on OS X where the code makes the assumption in at least two locations that anything that isn't "Normal" is "Bold". In other places, including generic code, parsers apply overly course numberic weight classifications or fail to consider weights like "Medium", "Semibold", "Regular", "Roman" etc. (and return a fall-back weight: Normal).
Among the font families that are affected there are als common fonts like Segoe UI and Helvetica Neue (UI fonts on MS Windows and OS X 10.10+). NB: medium/semi-/demi-bold weights are perfect in UIs on high-resolution screens.

The proposed patch improves the code by adding additional checks against style names and weights. The changes are not only to Mac-specific files so Linux benefits from this too (and other platforms ought to, as well).

I'm putting it up for review on here mainly for lack of time to figure out why I failed to get in onto Qt's own code review site. It may appear there too, but if not:

I herewith put the attached code changes in the public domain, for possible inclusion into the Qt 4.x codebase under the license that governs that software.

Diffs (updated)
src/gui/dialogs/qfontdialog.cpp d791462
src/gui/dialogs/qfontdialog_mac.mm d557a7a
src/gui/kernel/qt_mac.cpp fb241ce
src/gui/text/qfontdatabase.cpp 4c2ace4
src/gui/text/qfontdatabase_mac.cpp 816a7bd
src/gui/text/qfontengine_coretext.mm 204d685
src/plugins/platforms/fontdatabases/coretext/qcoretextfontdatabase.mm 312015f
tools/qtconfig/mainwindow.cpp 1bb6e4e

Diff: <a href="https://git.reviewboard.kde.org/r/123458/diff/" title="https://git.reviewboard.kde.org/r/123458/diff/">https://git.reviewboard.kde.org/r/123458/diff/</a>

Testing
On OS X 10.9.5 and Kubuntu 14.04.2 against Qt 4.8.7 with the qtconfig utility and the attached test application

File Attachments
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/bbebc0af-e457-4fdf-965c-3918d8e871d0__fontweightissue.pro" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/bbebc0af-e457-4fdf-965c-3918d8e871d0__fontweightissue.pro">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/bbebc0af...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/cfdcbf23-406a-4abf-b0cb-5fdc1957dfe9__main.cpp" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/cfdcbf23-406a-4abf-b0cb-5fdc1957dfe9__main.cpp">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/cfdcbf23...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/9898afae-82ca-4c92-b7d9-5607d0dd8e24__dialog.h" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/9898afae-82ca-4c92-b7d9-5607d0dd8e24__dialog.h">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/9898afae...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/8ad258bf-7f82-4db4-a344-ce81d75e8c50__dialog.cpp" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/8ad258bf-7f82-4db4-a344-ce81d75e8c50__dialog.cpp">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/8ad258bf...</a>
fontweight issue test application
<a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/2f0a7c6e-4601-406e-b703-603a36bff62b__fontweightissue.desktop" title="https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/2f0a7c6e-4601-406e-b703-603a36bff62b__fontweightissue.desktop">https://git.reviewboard.kde.org/media/uploaded/files/2015/04/21/2f0a7c6e...</a>

Thanks,

René J.V. Bertin

Re: Review Request 123458: Improvements to the handling of font

By Luigi Toscano at 04/21/2015 - 18:40

I think this should go to Qt (I think it's quite difficult they will accept it, as Qt4 is in hard freeze mode), and they will probably ask to see if it applies to Qt5 as well.
We just mirror Qt... not sure how to handle this.

- Luigi Toscano

On April 22, 2015, 12:06 a.m., René J.V. Bertin wrote:

Re: Review Request 123458: Improvements to the handling of font

By =?utf-8?Q?Ren=C... at 04/21/2015 - 20:08

It didn't even cross my mind to commit this patch to the Qt4 fork, just to put it up for review (and make it available publicly).

Oh, and if someone were to beat me to putting this up on Qt's code review site, I'd actually appreciate that, a lot even O:-)

- René J.V.

On April 22, 2015, 12:06 a.m., René J.V. Bertin wrote:

Re: Review Request 123458: Improvements to the handling of font

By Allan Sandfeld ... at 04/22/2015 - 17:40

On Wednesday 22 April 2015, René J.V. Bertin wrote:
`Allan

Re: Review Request 123458: Improvements to the handling of font

By Ben Cooksley at 04/21/2015 - 19:56

Our Qt mirrors are configured to be exact copies of the upstream code.qt.io mirrors, therefore any patches have to go through Qt Project to form part of our mirrors of it.

- Ben

On April 21, 2015, 10:06 p.m., René J.V. Bertin wrote:

Re: Review Request 123458: Improvements to the handling of font

By Aleix Pol at 04/21/2015 - 19:43

+1, we shouldn't go about maintaining a patched Qt4 fork.

- Aleix

On April 22, 2015, 12:06 a.m., René J.V. Bertin wrote:

Re: Review Request 123458: Improvements to the handling of font

By Luigi Toscano at 04/21/2015 - 18:46

Yes, I know you wrote that it should go to Qt, just stating that I'm not sure how to handle this patch in our Qt mirrors.

- Luigi

On April 22, 2015, 12:06 a.m., René J.V. Bertin wrote: