⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ttcmap.c

📁 下载来的一个看图软件的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
  Found1:    /* if the idRangeOffset is 0, we can compute the glyph index */    /* directly                                                  */    if ( seg4->idRangeOffset == 0 )      result = (FT_UInt)( charCode + seg4->idDelta ) & 0xFFFFU;    else    {      /* otherwise, we must use the glyphIdArray to do it */      index1 = (FT_UInt)( seg4->idRangeOffset / 2                          + ( charCode - seg4->startCount )                          + ( seg4 - cmap4->segments )                          - segCount );      if ( index1 < (FT_UInt)cmap4->numGlyphId &&           cmap4->glyphIdArray[index1] != 0    )        result = ( cmap4->glyphIdArray[index1] + seg4->idDelta ) & 0xFFFFU;    }    return result;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    code_to_next4                                                      */  /*                                                                       */  /* <Description>                                                         */  /*    Find the next encoded character.  Uses format 4.                   */  /*                                                                       */  /* <Input>                                                               */  /*    charCode :: The wanted character code.                             */  /*                                                                       */  /*    cmap     :: A pointer to a cmap table in format 4.                 */  /*                                                                       */  /* <Return>                                                              */  /*    Next encoded character.  0 if none exists.                         */  /*                                                                       */  FT_CALLBACK_DEF( FT_ULong )  code_to_next4( TT_CMapTable  cmap,                 FT_ULong      charCode )  {    FT_UInt             index1, segCount;    TT_CMap4            cmap4;    TT_CMap4SegmentRec  *seg4, *limit;    cmap4    = &cmap->c.cmap4;    segCount = cmap4->segCountX2 / 2;    limit    = cmap4->segments + segCount;    charCode++;    for ( seg4 = cmap4->segments; seg4 < limit; seg4++ )    {      /* The ranges are sorted in increasing order.  If we are out of */      /* the range here, the char code isn't in the charmap, so exit. */      if ( charCode <= (FT_UInt)seg4->endCount )        goto Found;    }    return 0;  Found:    if ( charCode < (FT_ULong) seg4->startCount )      charCode = seg4->startCount;    /* if the idRangeOffset is 0, all chars in the map exist */    if ( seg4->idRangeOffset == 0 )      return ( charCode );    while ( charCode <= (FT_UInt) seg4->endCount )    {      /* otherwise, we must use the glyphIdArray to do it */      index1 = (FT_UInt)( seg4->idRangeOffset / 2                          + ( charCode - seg4->startCount )                          + ( seg4 - cmap4->segments )                          - segCount );      if ( index1 < (FT_UInt)cmap4->numGlyphId &&           cmap4->glyphIdArray[index1] != 0    )        return ( charCode );      charCode++;    }    return 0;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    code_to_index6                                                     */  /*                                                                       */  /* <Description>                                                         */  /*    Converts the character code into a glyph index.  Uses format 6.    */  /*                                                                       */  /* <Input>                                                               */  /*    charCode :: The wanted character code.                             */  /*                                                                       */  /*    cmap6    :: A pointer to a cmap table in format 6.                 */  /*                                                                       */  /* <Return>                                                              */  /*    Glyph index into the glyphs array.  0 if the glyph does not exist. */  /*                                                                       */  FT_CALLBACK_DEF( FT_UInt )  code_to_index6( TT_CMapTable  cmap,                  FT_ULong      charCode )  {    TT_CMap6  cmap6;    FT_UInt   result = 0;    cmap6     = &cmap->c.cmap6;    charCode -= cmap6->firstCode;    if ( charCode < (FT_UInt)cmap6->entryCount )      result = cmap6->glyphIdArray[charCode];    return result;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    code_to_next6                                                      */  /*                                                                       */  /* <Description>                                                         */  /*    Find the next encoded character.  Uses format 6.                   */  /*                                                                       */  /* <Input>                                                               */  /*    charCode :: The wanted character code.                             */  /*                                                                       */  /*    cmap     :: A pointer to a cmap table in format 6.                 */  /*                                                                       */  /* <Return>                                                              */  /*    Next encoded character.  0 if none exists.                         */  /*                                                                       */  FT_CALLBACK_DEF( FT_ULong )  code_to_next6( TT_CMapTable  cmap,                 FT_ULong      charCode )  {    TT_CMap6  cmap6;    charCode++;    cmap6 = &cmap->c.cmap6;    if ( charCode < (FT_ULong) cmap6->firstCode )      charCode = cmap6->firstCode;    charCode -= cmap6->firstCode;    while ( charCode < (FT_UInt)cmap6->entryCount )    {      if ( cmap6->glyphIdArray[charCode] != 0 )        return charCode + cmap6->firstCode;      charCode++;    }    return 0;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    code_to_index8_12                                                  */  /*                                                                       */  /* <Description>                                                         */  /*    Converts the (possibly 32bit) character code into a glyph index.   */  /*    Uses format 8 or 12.                                               */  /*                                                                       */  /* <Input>                                                               */  /*    charCode :: The wanted character code.                             */  /*                                                                       */  /*    cmap8_12 :: A pointer to a cmap table in format 8 or 12.           */  /*                                                                       */  /* <Return>                                                              */  /*    Glyph index into the glyphs array.  0 if the glyph does not exist. */  /*                                                                       */  FT_CALLBACK_DEF( FT_UInt )  code_to_index8_12( TT_CMapTable  cmap,                     FT_ULong      charCode )  {    TT_CMap8_12      cmap8_12;    TT_CMapGroupRec  *group, *limit;    cmap8_12 = &cmap->c.cmap8_12;    limit    = cmap8_12->groups + cmap8_12->nGroups;    /* first, check against the last used group */    group = cmap8_12->last_group;    /* the following is equivalent to performing two tests, as in       */    /*                                                                  */    /*  if ( charCode >= group->startCharCode &&                        */    /*       charCode <= group->endCharCode   )                         */    /*                                                                  */    /* This is a bit strange, but it is faster, and the idea behind the */    /* cache is to significantly speed up charcode to glyph index       */    /* conversion.                                                      */    if ( (FT_ULong)( charCode           - group->startCharCode ) <         (FT_ULong)( group->endCharCode - group->startCharCode ) )      goto Found1;    for ( group = cmap8_12->groups; group < limit; group++ )    {      /* the ranges are sorted in increasing order.  If we are out of */      /* the range here, the char code isn't in the charmap, so exit. */      if ( charCode > group->endCharCode )        continue;      if ( charCode >= group->startCharCode )        goto Found;    }    return 0;  Found:    cmap8_12->last_group = group;  Found1:    return (FT_UInt)( group->startGlyphID +                      ( charCode - group->startCharCode ) );  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    code_to_next8_12                                                   */  /*                                                                       */  /* <Description>                                                         */  /*    Find the next encoded character.  Uses format 8 or 12.             */  /*                                                                       */  /* <Input>                                                               */  /*    charCode :: The wanted character code.                             */  /*                                                                       */  /*    cmap     :: A pointer to a cmap table in format 8 or 12.           */  /*                                                                       */  /* <Return>                                                              */  /*    Next encoded character.  0 if none exists.                         */  /*                                                                       */  FT_CALLBACK_DEF( FT_ULong )  code_to_next8_12( TT_CMapTable  cmap,                    FT_ULong      charCode )  {    TT_CMap8_12      cmap8_12;    TT_CMapGroupRec  *group, *limit;    charCode++;    cmap8_12 = &cmap->c.cmap8_12;    limit    = cmap8_12->groups + cmap8_12->nGroups;    for ( group = cmap8_12->groups; group < limit; group++ )    {      /* the ranges are sorted in increasing order.  If we are out of */      /* the range here, the char code isn't in the charmap, so exit. */      if ( charCode <= group->endCharCode )        goto Found;    }    return 0;  Found:    if ( charCode < group->startCharCode )      charCode = group->startCharCode;    return charCode;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    code_to_index10                                                    */  /*                                                                       */  /* <Description>                                                         */  /*    Converts the (possibly 32bit) character code into a glyph index.   */  /*    Uses format 10.                                                    */  /*                                                                       */  /* <Input>                                                               */  /*    charCode :: The wanted character code.                             */  /*                                                                       */  /*    cmap10   :: A pointer to a cmap table in format 10.                */  /*                                                                       */  /* <Return>                                                              */  /*    Glyph index into the glyphs array.  0 if the glyph does not exist. */  /*                                                                       */  FT_CALLBACK_DEF( FT_UInt )  code_to_index10( TT_CMapTable  cmap,                   FT_ULong      charCode )  {    TT_CMap10  cmap10;    FT_UInt    result = 0;    cmap10    = &cmap->c.cmap10;    charCode -= cmap10->startCharCode;    /* the overflow trick for comparison works here also since the number */    /* of glyphs (even if numChars is specified as ULong in the specs) in */    /* an OpenType font is limited to 64k                                 */    if ( charCode < cmap10->numChars )      result = cmap10->glyphs[charCode];    return result;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    code_to_next10                                                     */  /*                                                                       */  /* <Description>                                                         */  /*    Find the next encoded character.  Uses format 10.                  */  /*                                                                       */  /* <Input>                                                               */  /*    charCode :: The wanted character code.                             */  /*                                                                       */  /*    cmap     :: A pointer to a cmap table in format 10.                */  /*                                                                       */  /* <Return>                                                              */  /*    Next encoded character.  0 if none exists.                         */  /*                                                                       */  FT_CALLBACK_DEF( FT_ULong )  code_to_next10( TT_CMapTable  cmap,                  FT_ULong      charCode )  {    TT_CMap10  cmap10;    charCode++;    cmap10 = &cmap->c.cmap10;    if ( charCode < cmap10->startCharCode )      charCode = cmap10->startCharCode;    charCode -= cmap10->startCharCode;    /* the overflow trick for comparison works here also since the number */    /* of glyphs (even if numChars is specified as ULong in the specs) in */    /* an OpenType font is limited to 64k                                 */    while ( charCode < cmap10->numChars )    {      if ( cmap10->glyphs[charCode] )        return ( charCode + cmap10->startCharCode );      charCode++;    }    return 0;  }/* END */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -