[Top][All Lists]

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

Re: [Devel] Fonts with glyphs containing zero contours

From: David Turner
Subject: Re: [Devel] Fonts with glyphs containing zero contours
Date: Thu, 07 Feb 2002 18:29:51 +0100

Hi Keith,

Keith Packard a écrit :
> I've discovered that even common fonts contain glyphs which are not
> supposed to be blank that have no contours defined for the outlines.
> The venerable 'courier new' font (
> has three glyphs encoded in the unicode map at 0x2591, 0x2592 and 0x2593
> with no contours.  Those are normally the light, medium and dark shade
> glyphs so it's not surprising they're omitted from the font, what's
> surprising is that the unicode map includes references to three blank
> glyphs in their place.
> Perhaps, however, the glyph loader is simply broken.  Please find enclosed
> a trivial test program that lists all of the glyphs in the BMP section of
> the Unicode mapping which have no contours.
> If this methodology looks sound, I'm going to include this test as a part
> of building the unicode coverage map for my font configuration library.
> Towards that end, can anyone suggest a set of FT_LOAD flags that would
> cause minimal work within the library?  All I need is to load the
> contours to check their count.
I believe that we're running out of bit flags for FT_LOAD_XXXX already
(we need to limit ourselves to 16-bits only to support lesser processors :-)

Besides, I don't think that using FT_Load_Glyph to get the information
you need is an elegant way to solve the problem.. I can think of several

  - the simple one:: provide a new API, like:

         FT_Bool  FT_Glyph_Test_Format( FT_Face    face,
                                        FT_UInt    glyph_index,
                                        FT_UInt32  format_tag );

    whose purpose is to answer the question: "does glyph 'index' has
    an image in a specific 'format' ?"

  - the very sophisticated one:: provide some iterators to parse all
    glyphs and/or characters that correspond to certain criterion
    (including image format), for example:

        // completely opaque pointer type !!
        typedef FT_GlyphIteratorRec_*   FT_GlyphIterator;

        typedef enum
          ft_glyph_iterator_type_glyph = 0,  /* iterate over glyph array */
          ft_glyph_iterator_type_char,       /* iterate over character codes in 
current charmap */

        } FT_GlyphIteratorType;

        // really a bad example of iterator specialization, we could use
        // OOP as well, but this makes the example a lot smaller :-)
        typedef enum
          ft_glyph_iterator_kind_default = 0,   /* all glyphs or chars */

        } FT_GlyphIteratorKind;

        // returns NULL in case of invalid arguments or out of memory..
        FT_GlyphIterator  FT_GlyphIterator_New( FT_Face               face,
                                                FT_GlyphIteratorType  type,
                                                FT_GlyphIteratorKind  kind );

        // updates iterator to next glyph/char
        // *piterator is set to NULL at the end of the iteration
        // (no need for FT_GlyphIterator_Done...)
        void   FT_GlyphIterator_Next( FT_GlyphIterator*  piterator );

        // return glyph index
        FT_UInt   FT_GlyphIterator_GetGlyphIndex( FT_GlyphIterator  iterator );

        // return character code (returns glyph index for 'type_glyph' type)
        FT_ULong  FT_GlyphIterator_GetCharCode( FT_GlyphIterator  iterator,
                                                FT_UInt          *aglyph_index 
);  // optional

        // test wether current glyph/char supports
        FT_Bool   FT_GlyphIterator_TestFormat( FT_GlyphIterator  iterator,
                                               FT_UInt32         format_tag );

        // typical use..

        FT_GlyphIterator  iterator;

        iterator = FT_GlyphIterator_New( face, my_type, my_kind );
        while ( iterator )
          FT_ULong  char_code;
          FT_UInt   glyph_index;

          char_code = FT_GlyphIterator_GetCharCode( iterator, &glyph_index );

          .. // store in custom table

          FT_GlyphIterator_Next( &iterator );

And there are probably many levels between these two. What would seem most
appropriate to most developers here ??


- David

reply via email to

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