Performance issue with FontImage() #474

Open
mskala opened this Issue Mar 22, 2013 · 1 comment

Comments

Projects
None yet
1 participant
@mskala
Member

mskala commented Mar 22, 2013

This script:

Open($1);
SelectWorthOutputting();
foreach
  FontImage(GlyphInfo("Name")+".png",[250,Utf8(GlyphInfo("Unicode"))]);
endloop

runs in a couple of seconds for a font with 256 glyphs, but takes upwards of half an hour for a font with about 3000 glyphs. The time per glyph seems to be proportional to the number of glyphs, making the script's running time quadratic overall where it seems it should be linear.

The code behind FontImage() isn't very clear, but it looks to me like it is generating an entire bitmap strike for the entire font on each line of output, and then discarding it immediately. That seems suboptimal. It would be better to cache the generated bitmaps, only generate the bitmaps needed for the glyphs actually requested, or both.

A possible workaround, which I haven't finished testing yet, may be to manually request generation of a bitmap strike before the start of the loop. Even if that helps my own case, however, it would be better that FontImage() work more efficiently.

@mskala

This comment has been minimized.

Show comment Hide comment
@mskala

mskala Mar 24, 2013

Member

It turns out that FontImage() generates the font to a TTF temporary file on every line. Why?

Member

mskala commented Mar 24, 2013

It turns out that FontImage() generates the font to a TTF temporary file on every line. Why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment