Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to determine the fonts Windows chooses for font-linking?

Suppose you have a string with text in two or more scripts. When you use a GDI function like TextOut, (modern versions of) Windows will do "font-linking". That is, GDI will draw what it can with your selected font and draw the rest in an appropriate font that it chooses automagically. For example, if part of your text is in English (using the Roman alphabet), and part of it is Chinese (using CJK characters), and you have Arial selected, the English portion will be drawn in Arial, and the Chinese portion will be drawn in another font that has the CJK glyphs.

My question is, is there a way to determine which fonts TextOut will choose (or did choose) for the font linking?

I have to draw some text with the low-level Uniscribe API, which doesn't do automatic font-linking. I've implemented my own font-linking, but sometimes my algorithm chooses a different font than TextOut does for the same text. I'm trying to understand the Windows algorithm better, but I'm not real good at identifying fonts on sight (especially in unfamiliar scripts).

like image 679
Adrian McCarthy Avatar asked Mar 11 '10 18:03

Adrian McCarthy


1 Answers

The font is selected by a registry entry. It is well described in this article. Quoting the relevant part:

If font linking is enabled on your device, you can examine the registry by enumerating the subkeys of the registry key at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink to determine the mappings of linked fonts to base fonts. You can add links by using Regedit to create additional subkeys.

like image 94
Hans Passant Avatar answered Oct 02 '22 02:10

Hans Passant