freetype-devel
[Top][All Lists]
Advanced

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

Re[2]: [Devel] Character mapping - HELP?


From: Peter Sakhno
Subject: Re[2]: [Devel] Character mapping - HELP?
Date: Tue, 6 Mar 2001 11:07:07 +0300

Hi, all!

> Symbol (and some others like Wingding) is a special font. It is noticed
> by Windows (through I_do_not_remember_which_mechanism) as needing some
> sort of translation, primarly for backward compatibility reasons.
>
> If you analyse the font (the .TTF) itself, you should see that it is
> encoded as 0xF020 -> 0xF0FF (IIRC), with a special note that the charmap
> is 3,0, and not 3,1 as usual with Microsoft fonts.
>
> Althought I believe you can correctly write using this range in Windows,
> if you pass values in the 32-255 (0x20 - 0xFF) range, behind the scene
> Windows do some kind of remapping. I never checked that carefully, but
> I remember reading that it takes the lowest encoded character (i.e.
> 0xF020 in my example, but I believe this may varies), and map the space
> character (0x20) to this glyph; and the others follow.

Yes, You are right.
Here is a piece of code I use to render Glyphs from Webding.ttf

...
int FaceSetCharMap(FT_UShort nEncodingID) //
{
  // nEncodingID: 0 - for Symbol 1 - for Other, See TTF Documentation
  // for 'cmap' table

  const FT_UShort nWinPlatformID = 3;
  FT_Bool         found=0;
  int n;
  for(n=0; n<m_pCurrenFace->face->num_charmaps && !found; n++)
    if(m_pCurrenFace->face->charmaps[n]->platform_id==nWinPlatformID &&
       m_pCurrenFace->face->charmaps[n]->encoding_id==nEncodingID)
      found=1;

  if(!found)
    return -1;

  /* now, select the charmap for the face object */
  if(FT_Set_Charmap(m_pCurrenFace->face,m_pCurrenFace->face->charmaps[n-1]))
    return 1;

  m_pCurrenFace->bSymb=(!nEncodingID)?1:0;

  return 0;
}

int SymbolLoad(FT_ULong ulCharCode...)
{
  // ulCharCode: from 0 to 256
  if(!m_pCurrenFace)
    return -1;

  // REMAPPING!
  FT_ULong code=(m_pCurrenFace->bSymb)?0xF000+ulCharCode:ulCharCode;
  if(!(m_SlotGlf.glyph_index=FT_Get_Char_Index(m_pCurrenFace->face,code)))
    return 1;

  // load glyph to face slot
  if(FT_Load_Glyph(m_pCurrenFace->face,m_SlotGlf.glyph_index,FT_LOAD_DEFAULT))
    return 1;

  // copy glyph to outer slot
  if(FT_Get_Glyph(m_pCurrenFace->face->glyph,&(m_SlotGlf.image)))
    return 1;

  ...
}
...

And it works!
Hope thil will help.

Peter Sakhno.





reply via email to

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