freetype-devel
[Top][All Lists]
Advanced

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

[Devel] About CFF font in PDF


From: 王毅
Subject: [Devel] About CFF font in PDF
Date: Mon, 3 Sep 2001 16:14:18 +0800

Hi,

 

In order to call cff_get_char_index() function successfully, I added a CFF_Build_Unicode_Charmap() function to build a charmap for the font, as I listed below:

 

  static

      FT_Error  CFF_Build_Unicode_Charmap( CFF_Face            face,

      FT_ULong            base_offset,

      PSNames_Interface*  psnames )

  {

      ……

      /* allocate the charmap */

      face->num_charmaps = 1;

      if (ALLOC(face->charmaps, face->num_charmaps * sizeof(TT_CharMapRec)))

          goto Exit;

     

      charmap = face->charmaps;

      charmap->root.face = (FT_Face)face;

     

      cmap = &(charmap->cmap);

      cmap->format = 0;

      cmap->loaded = TRUE;

      cmap->platformID = 3;

      cmap->platformEncodingID = 1;

      cmap->offset = 0;

     

      cmap0 = &(cmap->c.cmap0);

      if (ALLOC(cmap0->glyphIdArray, 256 * sizeof(FT_Byte)))

          goto Fail;

     

      cmap0->glyphIdArray[0] = 0;

      for (i = 1; i < font->num_glyphs; i++)

      {

          nGlyphNameID = font->charset.sids[i];

          for (j = 1; j < 256; j++)

          {

              if (font->encoding.sids[j] == nGlyphNameID)

              {

                  cmap0->glyphIdArray[i] = (FT_Byte)font->encoding.codes[j];

                  break;

              }

          }

      }

     

      cmap->get_index = CFF_Code_To_Index;

      goto Exit;

     

Fail:

      FREE(face->charmaps);

     

Exit:

      return error;

  }

 

But in PDF, the Font Encoding defines a char code to char name mapping, as I listed below:

 

<<

/Type /Encoding

/Differences [ 1 /G54 /G68 /G65 /G20 /G71 /G75 /G69 /G63 /G6B /G62 /G72 /G6F /G77 /G6E /G66 /G78 /G6A /G6D /G70 /G73 /G76 /G74 /G6C /G61 /G7A /G79 /G64 /G67 /G2E /G30 /G31 /G32 /G33 /G34 /G35 /G36 /G37 /G38 /G39 /G21 /G40 /G23 /G24 /G25 /G5E /G26 /G2A /G28 /G29 /G5F /G2B /G7C /G2D /G3D /G5C /G7B /G7D /G5B /G5D /G3C /G3E /G3F /G2F /G41 /G42 ]

>>

 

FT2 only provides a FT_Get_Char_Index(FT_Face face, FT_ULong charcode) function and I cant use the mapping as a parameter, so I cant get the proper glyph index for certain code. I think I should have a FT_Get_Char_Code(FT_Face face, FT_String* charname) function to do this.

 

Im waiting for your option.

 

Jacky/09/03

 


reply via email to

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