[luatex] Reading registry to find Windows fonts

Hans Hagen pragma at wxs.nl
Sat May 30 15:22:30 CEST 2015


On 5/30/2015 3:05 PM, Élie Roux wrote:
>>> An issue[0] was raised recently, from a user who had fonts installed
>>> under Windows, recognized by his softwares but not LuaTeX (nor XeTeX).
>>> Apparently[1] the fonts are installed through a mechanism documented by
>>> MS[2] consisting in adding the font in the list of fonts in the Windows
>>> Registry.
>>
>> did the user update the font database
>
> Yes, but would that make any difference? If a user has a font in a
> non-standard directory and the font is only referenced in the registry,
> I don't think ConTeXt could find it?

that would be a pretty fragile setup (and makes support in case of 
problems hard)

>> such a dll would add yet another dependency (even worse: on an operating
>> system)
>
> Not very satisfying indeed...
>
>> personally i'd never rely on this as for long term stable processing it
>> makes sense to know what font (file) you use and where it sits
>
> Sure, but users expectations are often surprising...

well, if they use tex they should realize that there can be many 
resources involved and that a bit of resource management helps to avoid 
unwanted results

>> anyway, a dll is not needed as one can do this:
>>
>> local command = [[reg QUERY "HKLM\SOFTWARE\Microsoft\Windows
>> NT\CurrentVersion\Fonts"]]
>> local pattern = ".-[\n\r]+%s+(.-)%s%(([^%)]+)%)%s+REG_SZ%s+(%S+)%s+"
>>
>> local function getnamesfromregistry()
>>      local data = os.resultof(command)
>>      local list = { }
>>      for name, format, filename in string.gmatch(data,pattern) do
>>          list[name] = filename
>>      end
>>      return list
>> end
>
> This is brilliant, I think it's the best solution so far. I don't know
> much (if anything) about Windows, so I'd never have been to find it out
> myself!

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the luatex mailing list