Opened 5 years ago

Closed 5 years ago

#51 closed enhancement (fixed)

Use OS/2 font database to match fonts

Reported by: dmik Owned by: dmik
Priority: blocker Milestone: Qt Beta 3
Component: QtGui Version: 4.5.1 Beta 1
Severity: Keywords:
Cc:

Description (last modified by dmik)

We will use the Freetype2 library to cache installed fonts and perform font matching for Qt applications (refer to #41 for more info).

Change History (11)

comment:1 Changed 5 years ago by dmik

  • Priority changed from major to blocker

A must for the GA.

comment:2 Changed 5 years ago by diver

  • Milestone changed from Qt GA to Qt Beta 3

comment:3 Changed 5 years ago by dmik

I'm leaning to dropping fontconfig support actually. Its main purpose is to make the font configuration on a given system centralized and static across different applications. While this is really makes sense for Linux systems, on OS/2 font configuration is already pretty centralized and static.

Besides, fontconfig requires libxml and both these libraries aren't normal citizens of the typical OS/2 setup which means that we have to statically compile them into Qt which I consider as an overkill for a simple task of selecting a font file based on the requested font properties.

The OS/2 font database contains all basic information we need when choosing fonts. If we want more (e.g. font substitution, anti-aliasing and hint rules based on font family etc) we will add support for that through recognizing extra keys in OS2.INI.

If some day later the situation changes and many OS/2 applications start using fontconfig + libxml, we are always able to switch to fontconfig in Qt4 too.

comment:4 Changed 5 years ago by dmik

  • Owner set to dmik
  • Status changed from new to accepted

comment:5 Changed 5 years ago by dmik

  • Summary changed from Use fontconfig to match fonts to Use OS/2 font database to match fonts

comment:6 Changed 5 years ago by dmik

Font enumeration is done in r220. The next step is font matching.

comment:7 Changed 5 years ago by dmik

Actually, we don't have direct access to font file names when enumerating installed fonts using the GPI API (GpiQueryFonts?), we only get properties (style, size, etc). While there is a GpiQueryFullFontDescs? call which may extract families and face names found in a specified file, I don't find it sane to

  1. Enumerate fonts with GpiQueryFonts?
  2. Get file names from the PM_Fonts registry key and pair them with enumerated fonts using GpiQueryFullFontDescs?
  3. Eventually pass those filenames down to Freetype2 for rendering

provided that using Freetype2 we can bypass GPI completely, and besides that GPI and Freetype2 may interpret some fonts differently and the opinion of the one which will actually render them (Freetype2) is obviously more important.

So, I'll better go through PM_Fonts and get their properties with Freetype2. We will of course not see fonts built into resource DLLs in such case (e.g. WarpSans?, System Proportional, System VIO etc) but it's not a big deal ATM since these fonts cannot be rendered by Freetype2 directly anyway (we'll need a driver for doing that, see #52).

comment:8 Changed 5 years ago by dmik

Implemented the Freetype2 way in r222. Also implemented font matching so that all available outline fonts (TTF and PFB) can now be selected in Qt applications.

There are minor glitches for tomorrow:

  • non-Latin1 input is broken.
  • requesting an unknown family causes the list of fonts to be reloaded and rescanned (slow).

comment:9 Changed 5 years ago by dmik

  • Description modified (diff)

Non-Latin1 text drawing is fixed in r223. An additional ticket #87 is created for further script-related improvements.

comment:10 Changed 5 years ago by dmik

Implemented simple font caching and got 10 times faster second and subsequent application startups: initial Qt font database population (which includes scanning font files) with the default set of eCS fonts takes ~1500 ms on my VBox, all subsequent populations (which read data from the cache) take ~150 ms. This covers the "requesting an unknown family" case described above.

PS. Spent several hours fixing a nasty vendor bug that was very difficult to find (r229). One of the side effects was that saving a QDateTime object in the registry using QSettings and then reading it could return a completely different QDateTime object! Unfortunately this bug slipped from the Windows version into the OS/2 version because they share the same code. This bug affects only non-Unicode Windows versions (95, 98) where they introduced a dirty hack instead of properly fixing the source of the problem. This explains why the bug has been remaining unfixed for so long. Since OS/2 is "non-Unicode" too, it affects it as well. I'm falling asleep now so will release Beta 3 tomorrow.

comment:11 Changed 5 years ago by dmik

  • Resolution set to fixed
  • Status changed from accepted to closed

Slightly improved font caching so that now it doesn't even look at the font cache in the registry when requesting unknown families provided that the font files haven't been changed, added, or removed. r230 contains the final font cache implementation.

Enough for this ticket. There are a few unimplemented methods, created #89 for it.

Note: See TracTickets for help on using tickets.