freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] Slow FT_Get_Next_Char


From: [Jongware]
Subject: Re: [ft] Slow FT_Get_Next_Char
Date: Mon, 8 Dec 2008 12:27:09 -0800 (PST)


Werner LEMBERG wrote:
> Please provide a small (compilable) code snippet which demonstrates
> how you use it.

Hm - I think I get the point, after constructing the canonical example at
the end of this post. Let me expand a bit while I wait for the program to
finish ...

As you can see below, it just prints out the glyph index for each available
unicode. That's equivalent to what the function in my original program does
(storing indices into an array, for easy retrieval).
The "problem" lies indeed in the font, not in the code. The font contains
(wait for it...) 388,232 unicode code points, and it takes the program quite
some time to list all of 'em. Granted, printing costs more time than storing
them in an array, but I had a few variants of same routine, called in
succession. I was assuming the error was in FreeType because literally
*every other* font I tested literally appeared in microseconds on the
screen.

This font must be useful in stress-testing FreeType -- it is a real border
case of what *should* be possible. As far as I know, enumerating Unicodes is
a fairly basic function of font file processing -- but my program is the
only one on my system that takes this list to post-process the font. (For a
fairly reasonable assumption of 'post processing'.) Apart from making an
exception list (with this as its single member), how can I foresee this for
any given font?

In case you are wondering what marvel the font is, more information and a
download location can be found at
http://en.wikipedia.org/wiki/LastResort#Apple.27s_LastResort_font

The output my test program creates starts with

 "Font is ready
  gindex 8 -> unicode 0000h"
followed by some 388,000 lines, ending with
"  gindex 184 -> unicode 10FFFFh
  this took 665016 msecs"

and this is the test proggie:

#include <stdio.h>

// Freetype
#include <ft2build.h>
#include FT_FREETYPE_H

FT_Library library;
FT_Face fontface;

void main (void)
{
        FT_Error err;
        FT_ULong charcode;
        FT_UInt gindex;

        err = FT_Init_FreeType(&library);
        if (err)
        {
                printf ("No freetype?\n");
                return;
        }

        err = FT_New_Face (library, "lastresort.ttf", 0, &fontface);
        if (err)
        {
                printf ("Error with font\n");
                return;
        }
        FT_Select_Charmap (fontface, FT_ENCODING_UNICODE);
        printf ("Font is ready\n");

        charcode = FT_Get_First_Char(fontface, &gindex);
        while (gindex != 0)
        {
                printf ("gindex %d -> unicode %04Xh\n", gindex, charcode);
                charcode = FT_Get_Next_Char(fontface, charcode, &gindex);
        }
}
-- 
View this message in context: 
http://www.nabble.com/Slow-FT_Get_Next_Char-tp20880907p20902838.html
Sent from the Freetype - User mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]