[lltx] Ignoring select fonts

Will Robertson wspr81 at gmail.com
Sun May 16 14:23:24 CEST 2010


Hi,

Mac OS X contains a font called "LastResort.ttf" that takes a looooong time to be cached (it contains a glyph for every since unicode code point). So long I've never sat through the caching process.

To fix this up, I tried writing some naive code to allow fonts to be ignored; I didn't get far before running into issues, however. (At first I used a basic inline conditional but thought that looked like too much of a back.)

The idea was to filter out the contents of `list`:


    list = remove_ignore_fonts(list)
    for _,fnt in ipairs(list) do
        fnt = path_normalize(fnt)
        load_font(fnt, fontnames, status, newfontnames, newstatus, texmf)
    end


With something like this:


if os.name == "macosx" then

    ignorefonts = {
      "/System/Library/Fonts/LastResort.ttf"
    }
    
    function remove_ignore_fonts(fonts)
        local fontsubset = fonts
        
        for N,fnt in ipairs(fonts) do
        for _,ignore in ipairs(ignorefonts) do
            if fnt == ignore then
              logs.report("ignoring font '%s'", fnt)
              table.remove(fontsubset,N)
            end
        end
        end
        
        return fontsubset
    end
    
else
    function remove_ignore_fonts(fonts)
        return fonts
    end
end


I know this is a pretty inefficient approach but first things first, right.
When this is run, I get warnings such as this turning up non-systematically:

texlua(62003) malloc: *** error for object 0x327860: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Every now and then it causes a more serious problem:

texlua(61939) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
luaotfload | loading font: /Users/will/Library/Fonts/CharisSILI.ttfnot enough memory

(Sometimes instead a segfault, sometimes a bus error.)

This is beyond my capability to debug in my present post-hangover state. (Tips on exactly what to do here greatly appreciated, however.) Now, I don't know if this is a problem with my code or somewhere else, but I just wanted to mention to be careful if you look at using anything from this in the main repo.

-- Will




More information about the lualatex-dev mailing list