[luatex] Reading registry to find Windows fonts

Élie Roux elie.roux at telecom-bretagne.eu
Sat May 30 15:05:34 CEST 2015


>> 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?

> 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...

> 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!

Thank you very much!
-- 
Elie


More information about the luatex mailing list