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

📄 ftxgsub.c

📁 这个是Linux的qt源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    Free_Coverage( &ls->Coverage, memory );    return error;  }  void  Free_LigatureSubst( TTO_LigatureSubst*  ls,			    FT_Memory           memory )  {    FT_UShort         n, count;    TTO_LigatureSet*  lset;    if ( ls->LigatureSet )    {      count = ls->LigatureSetCount;      lset  = ls->LigatureSet;      for ( n = 0; n < count; n++ )        Free_LigatureSet( &lset[n], memory );      FREE( lset );    }    Free_Coverage( &ls->Coverage, memory );  }  static FT_Error  Lookup_LigatureSubst( TTO_LigatureSubst*  ls,                                         TTO_GSUB_String*    in,                                         TTO_GSUB_String*    out,                                         FT_UShort           flags,                                         FT_UShort           context_length,                                         TTO_GDEFHeader*     gdef )  {    FT_UShort      index, property;    FT_Error       error;    FT_UShort      numlig, i, j, is_mark, first_is_mark = FALSE;    FT_UShort*     s_in;    FT_UShort*     c;    TTO_Ligature*  lig;    error = Coverage_Index( &ls->Coverage, in->string[in->pos], &index );    if ( error )      return error;    if ( CHECK_Property( gdef, in->string[in->pos], flags, &property ) )      return error;    if ( property == TTO_MARK || property & IGNORE_SPECIAL_MARKS )      first_is_mark = TRUE;    if ( index >= ls->LigatureSetCount )       return TTO_Err_Invalid_GSUB_SubTable;    lig = ls->LigatureSet[index].Ligature;    for ( numlig = ls->LigatureSet[index].LigatureCount;          numlig;          numlig--, lig++ )    {      if ( in->pos + lig->ComponentCount > in->length )        continue;                         /* Not enough glyphs in input */      s_in = &in->string[in->pos];      c    = lig->Component;      is_mark = first_is_mark;      if ( context_length != 0xFFFF && context_length < lig->ComponentCount )        break;      for ( i = 1, j = 1; i < lig->ComponentCount; i++, j++ )      {        while ( in->pos + j < in->length		&& CHECK_Property( gdef, s_in[j], flags, &property ) )        {          if ( error && error != TTO_Err_Not_Covered )            return error;	  j++;        }        if ( !( property == TTO_MARK || property & IGNORE_SPECIAL_MARKS ) )          is_mark = FALSE;        if ( in->pos + j >= in->length || s_in[j] != c[i - 1] )          break;      }      if ( i == lig->ComponentCount )      {        if ( gdef && gdef->NewGlyphClasses )        {          /* this is just a guess ... */          error = Add_Glyph_Property( gdef, lig->LigGlyph,                                      is_mark ? TTO_MARK : TTO_LIGATURE );          if ( error && error != TTO_Err_Not_Covered )            return error;        }        if ( i == j )        {	  glyph_copy( in, i, out, lig->LigGlyph,		      in->glyph_properties[in->pos].component );        }        else        {	  glyph_copy( in, 1, out, lig->LigGlyph,		      in->glyph_properties[in->pos].component);          /* Now we must do a second loop to copy the skipped glyphs to             `out' and assign component values to it.  We start with the             glyph after the first component.  Glyphs between component             i and i+1 belong to component i.  Together with the ligID             value it is later possible to check whether a specific             component value really belongs to a given ligature.         */          for ( i = 0; i < lig->ComponentCount - 1; i++ )          {            while ( CHECK_Property( gdef, in->string[in->pos],                                    flags, &property ) )		glyph_copy( in, 1, out, in->string[in->pos], i);            (in->pos)++;          }        }        return TT_Err_Ok;      }    }    return TTO_Err_Not_Covered;  }  /* Do the actual substitution for a context substitution (either format     5 or 6).  This is only called after we've determined that the input     matches the subrule.                                                 */  static FT_Error  Do_ContextSubst( TTO_GSUBHeader*         gsub,                                    FT_UShort               GlyphCount,                                    FT_UShort               SubstCount,                                    TTO_SubstLookupRecord*  subst,                                    TTO_GSUB_String*        in,                                    TTO_GSUB_String*        out,                                    int                     nesting_level )  {    FT_Error  error;    FT_UShort i, old_pos;    i = 0;    while ( i < GlyphCount )    {      if ( SubstCount && i == subst->SequenceIndex )      {        old_pos = in->pos;        /* Do a substitution */        error = GSub_Do_Glyph_Lookup( gsub, subst->LookupListIndex, in, out,                                 GlyphCount, nesting_level );        subst++;        SubstCount--;        i += in->pos - old_pos;        if ( error == TTO_Err_Not_Covered )        {          /* XXX "can't happen" -- but don't count on it */	  glyph_copy( in, 1, out, in->string[in->pos],		      in->glyph_properties[in->pos].component);          i++;        }        else if ( error )          return error;      }      else      {        /* No substitution for this index */	  glyph_copy( in, 1, out, in->string[in->pos],		      in->glyph_properties[in->pos].component);          return error;        i++;      }    }    return TT_Err_Ok;  }  /* LookupType 5 */  /* SubRule */  static FT_Error  Load_SubRule( TTO_SubRule*  sr,                                 FT_Stream     stream )  {    FT_Error error;    FT_Memory memory = stream->memory;    FT_UShort               n, count;    FT_UShort*              i;    TTO_SubstLookupRecord*  slr;    if ( ACCESS_Frame( 4L ) )      return error;    sr->GlyphCount = GET_UShort();    sr->SubstCount = GET_UShort();    FORGET_Frame();    sr->Input = NULL;    count = sr->GlyphCount - 1;         /* only GlyphCount - 1 elements */    if ( ALLOC_ARRAY( sr->Input, count, FT_UShort ) )      return error;    i = sr->Input;    if ( ACCESS_Frame( count * 2L ) )      goto Fail2;    for ( n = 0; n < count; n++ )      i[n] = GET_UShort();    FORGET_Frame();    sr->SubstLookupRecord = NULL;    count = sr->SubstCount;    if ( ALLOC_ARRAY( sr->SubstLookupRecord, count, TTO_SubstLookupRecord ) )      goto Fail2;    slr = sr->SubstLookupRecord;    if ( ACCESS_Frame( count * 4L ) )      goto Fail1;    for ( n = 0; n < count; n++ )    {      slr[n].SequenceIndex   = GET_UShort();      slr[n].LookupListIndex = GET_UShort();    }    FORGET_Frame();    return TT_Err_Ok;  Fail1:    FREE( slr );  Fail2:    FREE( i );    return error;  }  static void  Free_SubRule( TTO_SubRule*  sr,			     FT_Memory     memory )  {    FREE( sr->SubstLookupRecord );    FREE( sr->Input );  }  /* SubRuleSet */  static FT_Error  Load_SubRuleSet( TTO_SubRuleSet*  srs,                                    FT_Stream        stream )  {    FT_Error error;    FT_Memory memory = stream->memory;    FT_UShort     n = 0, m, count;    FT_ULong      cur_offset, new_offset, base_offset;    TTO_SubRule*  sr;    base_offset = FILE_Pos();    if ( ACCESS_Frame( 2L ) )      return error;    count = srs->SubRuleCount = GET_UShort();    FORGET_Frame();    srs->SubRule = NULL;    if ( ALLOC_ARRAY( srs->SubRule, count, TTO_SubRule ) )      return error;    sr = srs->SubRule;    for ( n = 0; n < count; n++ )    {      if ( ACCESS_Frame( 2L ) )        goto Fail;      new_offset = GET_UShort() + base_offset;      FORGET_Frame();      cur_offset = FILE_Pos();      if ( FILE_Seek( new_offset ) ||           ( error = Load_SubRule( &sr[n], stream ) ) != TT_Err_Ok )        goto Fail;      (void)FILE_Seek( cur_offset );    }    return TT_Err_Ok;  Fail:    for ( m = 0; m < n; m++ )      Free_SubRule( &sr[m], memory );    FREE( sr );    return error;  }  static void  Free_SubRuleSet( TTO_SubRuleSet*  srs,				FT_Memory        memory )  {    FT_UShort     n, count;    TTO_SubRule*  sr;    if ( srs->SubRule )    {      count = srs->SubRuleCount;      sr    = srs->SubRule;      for ( n = 0; n < count; n++ )        Free_SubRule( &sr[n], memory );      FREE( sr );    }  }  /* ContextSubstFormat1 */  static FT_Error  Load_ContextSubst1( TTO_ContextSubstFormat1*  csf1,                                       FT_Stream                 stream )  {    FT_Error error;    FT_Memory memory = stream->memory;    FT_UShort        n = 0, m, count;    FT_ULong         cur_offset, new_offset, base_offset;    TTO_SubRuleSet*  srs;    base_offset = FILE_Pos() - 2L;    if ( ACCESS_Frame( 2L ) )      return error;    new_offset = GET_UShort() + base_offset;    FORGET_Frame();    cur_offset = FILE_Pos();    if ( FILE_Seek( new_offset ) ||         ( error = Load_Coverage( &csf1->Coverage, stream ) ) != TT_Err_Ok )      return error;    (void)FILE_Seek( cur_offset );    if ( ACCESS_Frame( 2L ) )      goto Fail2;    count = csf1->SubRuleSetCount = GET_UShort();    FORGET_Frame();    csf1->SubRuleSet = NULL;    if ( ALLOC_ARRAY( csf1->SubRuleSet, count, TTO_SubRuleSet ) )      goto Fail2;    srs = csf1->SubRuleSet;    for ( n = 0; n < count; n++ )    {      if ( ACCESS_Frame( 2L ) )        goto Fail1;      new_offset = GET_UShort() + base_offset;      FORGET_Frame();      cur_offset = FILE_Pos();      if ( FILE_Seek( new_offset ) ||           ( error = Load_SubRuleSet( &srs[n], stream ) ) != TT_Err_Ok )        goto Fail1;      (void)FILE_Seek( cur_offset );    }    return TT_Err_Ok;  Fail1:    for ( m = 0; m < n; m++ )      Free_SubRuleSet( &srs[m], memory );    FREE( srs );  Fail2:    Free_Coverage( &csf1->Coverage, memory );    return error;  }  static void  GSub_Free_Context1( TTO_ContextSubstFormat1* csf1,			      FT_Memory                memory )  {    FT_UShort        n, count;    TTO_SubRuleSet*  srs;    if ( csf1->SubRuleSet )    {      count = csf1->SubRuleSetCount;      srs   = csf1->SubRuleSet;      for ( n = 0; n < count; n++ )        Free_SubRuleSet( &srs[n], memory );      FREE( srs );    }    Free_Coverage( &csf1->Coverage, memory );  }  /* SubClassRule */  static FT_Error  Load_SubClassRule( TTO_ContextSubstFormat2*  csf2,                                      TTO_SubClassRule*         scr,                                      FT_Stream                 stream )  {    FT_Error error;    FT_Memory memory = stream->memory;    FT_UShort               n, count;    FT_UShort*              c;    TTO_SubstLookupRecord*  slr;    FT_Bool*                d;    if ( ACCESS_Frame( 4L ) )      return error;    scr->GlyphCount = GET_UShort();    scr->SubstCount = GET_UShort();    if ( scr->GlyphCount > csf2->MaxContextLength )      csf2->MaxContextLength = scr->GlyphCount;    FORGET_Frame();    scr->Class = NULL;    count = scr->GlyphCount - 1;        /* only GlyphCount - 1 elements */    if ( ALLOC_ARRAY( scr->Class, count, FT_UShort ) )      return error;    c = scr->Class;    d = csf2->ClassDef.Defined;    if ( ACCESS_Frame( count * 2L ) )      goto Fail2;    for ( n = 0; n < count; n++ )    {      c[n] = GET_UShort();      /* ### see comment in Load_ChainSubClassRule */      /* We check whether the specific class is used at all.  If not,         class 0 is used instead.                                     */      /*	if ( !d[c[n]] )	    c[n] = 0;      */    }    FORGET_Frame();    scr->SubstLookupRecord = NULL;    count = scr->SubstCount;    if ( ALLOC_ARRAY( scr->SubstLookupRecord, count, TTO_SubstLookupRecord ) )      goto Fail2;    slr = scr->SubstLookupRecord;    if ( ACCESS_Frame( count * 4L ) )      goto Fail1;    for ( n = 0; n < count; n++ )    {      slr[n].SequenceIndex   = GET_UShort();      slr[n].LookupListIndex = GET_UShort();    }    FORGET_Frame();    return TT_Err_Ok;  Fail1:    FREE( slr );  Fail2:    FREE( c );    return error;  }  static void  Free_SubClassRule( TTO_SubClassRule*  scr,				  FT_Memory          memory )  {    FREE( scr->SubstLookupRecord );    FREE( scr->Class );  }  /* SubClassSet */  static FT_Error  Load_SubClassSet( TTO_ContextSubstFormat2*  csf2,                                     TTO_SubClassSet*          scs,                                     FT_Stream                 stream )  {    FT_Error error;    FT_Memory memory = stream->memory;    FT_UShort          n = 0, m, count;    FT_ULong           cur_offset, new_offset, base_offset;    TTO_SubClassRule*  scr;    base_offset = FILE_Pos();    if ( ACCESS_Frame( 2L ) )      return error;    count = scs->SubClassRuleCount = GET_UShort();    FORGET_Frame();

⌨️ 快捷键说明

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