freetype-devel
[Top][All Lists]
Advanced

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

[Devel] FreeType2 problem with Chinese fonts


From: Moonhyoung Lee
Subject: [Devel] FreeType2 problem with Chinese fonts
Date: Tue, 20 Mar 2001 02:05:07 +0900

Hi.

I have a strange problem with FreeType2 for use with Chinese fonts.

1. Composite glyphs are not scaled correctly.

FT_Load_Glyph() returns incorrect outline data if FT_LOAD_NO_SCALE flag is not 
set.
The outline returned by FT_Load_Glyph() is a composite of each base glyph with 
no scaling(?) applied.
So it's completely useless.

   err = FT_New_Face (library, "kaiu.ttf", 0, &face);
   ...
   err = FT_Load_Glyph (
              face,               /* handle to face object */
              1346,               /* glyph index */
              FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE);   /* load flags */

   ** kaiu.ttf is included in Chinese Windows 98.

So. I tried to set the font size to 16 points, and scaled it.

   err = FT_New_Face (library, "kaiu.ttf", 0, &face);
   ...
   err = FT_Set_Char_Size (
              face,               /* handle to face object           */
              0,                  /* char_width in 1/64th of points  */
              16 * 64,            /* char_height in 1/64th of points */
              72,                 /* horizontal device resolution    */
              72);                /* vertical device resolution      */
   err = FT_Load_Glyph (
              face,               /* handle to face object */
              1346,               /* glyph index */
              FT_LOAD_NO_BITMAP);   /* load flags */

This works, but the coordinates returned are not exactly match to original due 
to some
round off errors.

ttfdump program output tells glyph number 1346 is a composite, but there's no 
scaling of each glyph.
I'm not sure, but the scaling is applied by means of instructions (???)

$ ttfdump -t glyf -g 1346 kaiu.ttf

Glyf   1346.
         numberOfContours:       -1  (Composite)
         xMin:                   0
         yMin:                   -51
         xMax:                   1024
         yMax:                   973

         0: Flags:       0x23
            Glyf Index:  395
            X WOffset:   108
            Y WOffset:   668
            Others:                                                        

         1: Flags:       0x23
            Glyf Index:  266
            X WOffset:   48
            Y WOffset:   468
            Others:                                                        

         2: Flags:       0x23
            Glyf Index:  423
            X WOffset:   56
            Y WOffset:   436
            Others:                                                        

         3: Flags:       0x23
            Glyf Index:  282
            X WOffset:   284
            Y WOffset:   672
            Others:                                                        

         4: Flags:       0x23
            Glyf Index:  350
            X WOffset:   456
            Y WOffset:   684
            Others:                                                        

         5: Flags:       0x102
            Glyf Index:  402
            X BOffset:   108
            Y BOffset:   112
            Others:                                                        


         Length of Instructions: 62

2. Advance values returned by face->glyph->metrics.horiAdvance is not correct
   for Roman characters.

   They are all 1024.
   Here's the code:

   err = FT_New_Face (library, "kaiu.ttf", 0, &face);
   err = FT_Set_Char_Size (
              face,               /* handle to face object           */
              0,                  /* char_width in 1/64th of points  */
              16 * 64,            /* char_height in 1/64th of points */
              72,                 /* horizontal device resolution    */
              72);                /* vertical device resolution      */

   err = FT_Set_Charmap (face, face->charmaps[1]); /* select Unicode encoding */

   index = FT_Get_Char_Index (face, 'i');

   err = FT_Load_Glyph (
              face,               /* handle to face object */
              index,              /* glyph index */
              FT_LOAD_NO_BITMAP);

   printf ("Index %d, Advance %d\n", index, face->glyph->metrics.horiAdvance);

   The output is "Index 106, Advance 1024". All character advance values are 
1024.
   face->glyph->advance.x is also 1024.

   ttfdump output is:

   $ ttfdump -t hmtx kaiu.ttf

   'hmtx' Table - Horizontal Metrics
   ---------------------------------
   ..
          105. advWid:  512, LSBear:   12
          106. advWid:  512, LSBear:  124
          107. advWid:  512, LSBear:  144


I've been struggling with this problems a lot. Please someone take a look at 
this, and
give me some advice.

Thanks in advance.


reply via email to

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