freetype-devel
[Top][All Lists]
Advanced

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

RE: [ft-devel] The font can't be parsed correctly


From: 丁力
Subject: RE: [ft-devel] The font can't be parsed correctly
Date: Fri, 14 Dec 2007 15:49:24 +0800

When I use the codes:
                ftErrorCode = FTC_SBitCache_Lookup(m_ftcSBitsCache, 
&m_ftcCurrentFont, nGlyphIndex, &sbit, DFE_Null);
                if (!ftErrorCode && sbit->buffer)
                {
                        pBmpChar->nRows = sbit->height;
                        pBmpChar->nWidth = sbit->width;
                        pBmpChar->nPitch = sbit->pitch;
                        pBmpChar->pBuffer = sbit->buffer;
                        pBmpChar->nGrays = sbit->max_grays + 1;
it displayed wrong.

And these codes are displayed correctly.
        ftErrorCode = FTC_ImageCache_Lookup(m_ftcImageCache, &m_ftcCurrentFont, 
nGlyphIndex, &glyph, DFE_Null);

        FT_Glyph  aglyf = DFE_Null;
        Glyph_To_Bitmap(glyph, pBmpChar, &nLeft, &nTop, &nAdvanceX, &nAdvanceY, 
&aglyf);

-----Original Message-----
From: Werner LEMBERG [mailto:address@hidden 
Sent: Monday, December 10, 2007 11:12 PM
To: address@hidden
Cc: address@hidden
Subject: Re: [ft-devel] The font can't be parsed correctly


> The first glyph in the font F4.1.ttf (index:3058, maybe the Chinese
> character "版") can not be parsed.

Uh, oh, another Type 1 operator (callothersubr)!  This font is simply
not a valid CFF!  It's pure luck that other parsers support it.
Hopefully, it's not your company which produces such weird CFFs!

Looking into src/psaux/t1decode.c, you can see that handling of
`callothersubr' is about 350 lines of code which I won't add to the
Type 2 handler: It's far too expensive to support such a feature which
is invalid anyway.

Hmm.  Maybe it's possible to switch from the Type 2 parser to the
Type 1 parser as soon as an invalid opcode has been found...  Any
volunteer to investigate this?  Perhaps you?

> The second, I use the function "FTC_SBitCache_Lookup" to get the
> bitmap, it is wrong.  And the "FTC_ImageCache_Lookup" is right.

A compilable code snippet, please, which demonstrates the problem.

> The third, can you tell me which files be changed for this problem?

From the ChangeLog file:

        * src/cff/cffgload.c (CFF_Operator): Add `cff_op_hsbw' and
        `cff_op_closepath.'
        (cff_argument_counts): Ditto.

        (cff_decoder_parse_charstrings): Handle Type 1 opcodes 9
        (closepath) and 13 (hsbw) which are invalid in Type 2
        charstrings.


    Werner

reply via email to

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