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

📄 harfbuzz-gsub.c

📁 GTK+-2.0源码之pango-1.15.6.tar.gz
💻 C
📖 第 1 页 / 共 5 页
字号:
    goto Fail3;  for ( n = 0; n < count; n++ )  {    i[n] = GET_UShort();    if ( !d[i[n]] )      i[n] = 0;  }  FORGET_Frame();  if ( ACCESS_Frame( 2L ) )    goto Fail3;  cscr->LookaheadGlyphCount = GET_UShort();  FORGET_Frame();  if ( cscr->LookaheadGlyphCount > ccsf2->MaxLookaheadLength )    ccsf2->MaxLookaheadLength = cscr->LookaheadGlyphCount;  cscr->Lookahead = NULL;  count = cscr->LookaheadGlyphCount;  if ( ALLOC_ARRAY( cscr->Lookahead, count, FT_UShort ) )    goto Fail3;  l = cscr->Lookahead;  d = ccsf2->LookaheadClassDef.Defined;  if ( ACCESS_Frame( count * 2L ) )    goto Fail2;  for ( n = 0; n < count; n++ )  {    l[n] = GET_UShort();    if ( !d[l[n]] )      l[n] = 0;  }  FORGET_Frame();  if ( ACCESS_Frame( 2L ) )    goto Fail2;  cscr->SubstCount = GET_UShort();  FORGET_Frame();  cscr->SubstLookupRecord = NULL;  count = cscr->SubstCount;  if ( ALLOC_ARRAY( cscr->SubstLookupRecord, count,		    HB_SubstLookupRecord ) )    goto Fail2;  slr = cscr->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 FT_Err_Ok;Fail1:  FREE( slr );Fail2:  FREE( l );Fail3:  FREE( i );Fail4:  FREE( b );  return error;}static void  Free_ChainSubClassRule( HB_ChainSubClassRule*  cscr,				     FT_Memory               memory ){  FREE( cscr->SubstLookupRecord );  FREE( cscr->Lookahead );  FREE( cscr->Input );  FREE( cscr->Backtrack );}/* SubClassSet */static FT_Error  Load_ChainSubClassSet(		   HB_ChainContextSubstFormat2*  ccsf2,		   HB_ChainSubClassSet*          cscs,		   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;  HB_ChainSubClassRule*  cscr;  base_offset = FILE_Pos();  if ( ACCESS_Frame( 2L ) )    return error;  count = cscs->ChainSubClassRuleCount = GET_UShort();  FORGET_Frame();  cscs->ChainSubClassRule = NULL;  if ( ALLOC_ARRAY( cscs->ChainSubClassRule, count,		    HB_ChainSubClassRule ) )    return error;  cscr = cscs->ChainSubClassRule;  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_ChainSubClassRule( ccsf2, &cscr[n],					   stream ) ) != FT_Err_Ok )      goto Fail;    (void)FILE_Seek( cur_offset );  }  return FT_Err_Ok;Fail:  for ( m = 0; m < n; m++ )    Free_ChainSubClassRule( &cscr[m], memory );  FREE( cscr );  return error;}static void  Free_ChainSubClassSet( HB_ChainSubClassSet*  cscs,				    FT_Memory              memory ){  FT_UShort               n, count;  HB_ChainSubClassRule*  cscr;  if ( cscs->ChainSubClassRule )  {    count = cscs->ChainSubClassRuleCount;    cscr  = cscs->ChainSubClassRule;    for ( n = 0; n < count; n++ )      Free_ChainSubClassRule( &cscr[n], memory );    FREE( cscr );  }}static FT_Error GSUB_Load_EmptyOrClassDefinition( HB_ClassDefinition*  cd,					     FT_UShort             limit,					     FT_ULong              class_offset,					     FT_ULong              base_offset,					     FT_Stream             stream ){  FT_Error error;  FT_ULong               cur_offset;  cur_offset = FILE_Pos();  if ( class_offset )    {      if ( !FILE_Seek( class_offset + base_offset ) )	error = _HB_OPEN_Load_ClassDefinition( cd, limit, stream );    }  else     error = _HB_OPEN_Load_EmptyClassDefinition ( cd, stream );  if (error == FT_Err_Ok)    (void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */  return error;}/* ChainContextSubstFormat2 */static FT_Error  Load_ChainContextSubst2(		   HB_ChainContextSubstFormat2*  ccsf2,		   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;  FT_ULong               backtrack_offset, input_offset, lookahead_offset;  HB_ChainSubClassSet*  cscs;  base_offset = FILE_Pos() - 2;  if ( ACCESS_Frame( 2L ) )    return error;  new_offset = GET_UShort() + base_offset;  FORGET_Frame();  cur_offset = FILE_Pos();  if ( FILE_Seek( new_offset ) ||       ( error = _HB_OPEN_Load_Coverage( &ccsf2->Coverage, stream ) ) != FT_Err_Ok )    return error;  (void)FILE_Seek( cur_offset );  if ( ACCESS_Frame( 8L ) )    goto Fail5;  backtrack_offset = GET_UShort();  input_offset     = GET_UShort();  lookahead_offset = GET_UShort();  /* `ChainSubClassSetCount' is the upper limit for input class values,     thus we read it now to make an additional safety check. No limit     is known or needed for the other two class definitions          */  count = ccsf2->ChainSubClassSetCount = GET_UShort();  FORGET_Frame();  if ( ( error = GSUB_Load_EmptyOrClassDefinition( &ccsf2->BacktrackClassDef, 65535,					      backtrack_offset, base_offset,					      stream ) ) != FT_Err_Ok )      goto Fail5;  if ( ( error = GSUB_Load_EmptyOrClassDefinition( &ccsf2->InputClassDef, count,					      input_offset, base_offset,					      stream ) ) != FT_Err_Ok )      goto Fail4;  if ( ( error = GSUB_Load_EmptyOrClassDefinition( &ccsf2->LookaheadClassDef, 65535,					      lookahead_offset, base_offset,					      stream ) ) != FT_Err_Ok )    goto Fail3;  ccsf2->ChainSubClassSet   = NULL;  ccsf2->MaxBacktrackLength = 0;  ccsf2->MaxInputLength     = 0;  ccsf2->MaxLookaheadLength = 0;  if ( ALLOC_ARRAY( ccsf2->ChainSubClassSet, count, HB_ChainSubClassSet ) )    goto Fail2;  cscs = ccsf2->ChainSubClassSet;  for ( n = 0; n < count; n++ )  {    if ( ACCESS_Frame( 2L ) )      goto Fail1;    new_offset = GET_UShort() + base_offset;    FORGET_Frame();    if ( new_offset != base_offset )      /* not a NULL offset */    {      cur_offset = FILE_Pos();      if ( FILE_Seek( new_offset ) ||	   ( error = Load_ChainSubClassSet( ccsf2, &cscs[n],					    stream ) ) != FT_Err_Ok )	goto Fail1;      (void)FILE_Seek( cur_offset );    }    else    {      /* we create a ChainSubClassSet table with no entries */      ccsf2->ChainSubClassSet[n].ChainSubClassRuleCount = 0;      ccsf2->ChainSubClassSet[n].ChainSubClassRule      = NULL;    }  }  return FT_Err_Ok;Fail1:  for ( m = 0; m < n; m++ )    Free_ChainSubClassSet( &cscs[m], memory );  FREE( cscs );Fail2:  _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef, memory );Fail3:  _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef, memory );Fail4:  _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef, memory );Fail5:  _HB_OPEN_Free_Coverage( &ccsf2->Coverage, memory );  return error;}static void  Free_ChainContextSubst2( HB_ChainContextSubstFormat2*  ccsf2,				 FT_Memory                      memory ){  FT_UShort              n, count;  HB_ChainSubClassSet*  cscs;  if ( ccsf2->ChainSubClassSet )  {    count = ccsf2->ChainSubClassSetCount;    cscs  = ccsf2->ChainSubClassSet;    for ( n = 0; n < count; n++ )      Free_ChainSubClassSet( &cscs[n], memory );    FREE( cscs );  }  _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef, memory );  _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef, memory );  _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef, memory );  _HB_OPEN_Free_Coverage( &ccsf2->Coverage, memory );}/* ChainContextSubstFormat3 */static FT_Error  Load_ChainContextSubst3(		   HB_ChainContextSubstFormat3*  ccsf3,		   FT_Stream                      stream ){  FT_Error error;  FT_Memory memory = stream->memory;  FT_UShort               n, nb = 0, ni =0, nl = 0, m, count;  FT_UShort               backtrack_count, input_count, lookahead_count;  FT_ULong                cur_offset, new_offset, base_offset;  HB_Coverage*           b;  HB_Coverage*           i;  HB_Coverage*           l;  HB_SubstLookupRecord*  slr;  base_offset = FILE_Pos() - 2L;  if ( ACCESS_Frame( 2L ) )    return error;  ccsf3->BacktrackGlyphCount = GET_UShort();  FORGET_Frame();  ccsf3->BacktrackCoverage = NULL;  backtrack_count = ccsf3->BacktrackGlyphCount;  if ( ALLOC_ARRAY( ccsf3->BacktrackCoverage, backtrack_count,		    HB_Coverage ) )    return error;  b = ccsf3->BacktrackCoverage;  for ( nb = 0; nb < backtrack_count; nb++ )  {    if ( ACCESS_Frame( 2L ) )      goto Fail4;    new_offset = GET_UShort() + base_offset;    FORGET_Frame();    cur_offset = FILE_Pos();    if ( FILE_Seek( new_offset ) ||	 ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != FT_Err_Ok )      goto Fail4;    (void)FILE_Seek( cur_offset );  }  if ( ACCESS_Frame( 2L ) )    goto Fail4;  ccsf3->InputGlyphCount = GET_UShort();  FORGET_Frame();  ccsf3->InputCoverage = NULL;  input_count = ccsf3->InputGlyphCount;  if ( ALLOC_ARRAY( ccsf3->InputCoverage, input_count, HB_Coverage ) )    goto Fail4;  i = ccsf3->InputCoverage;  for ( ni = 0; ni < input_count; ni++ )  {    if ( ACCESS_Frame( 2L ) )      goto Fail3;    new_offset = GET_UShort() + base_offset;    FORGET_Frame();    cur_offset = FILE_Pos();    if ( FILE_Seek( new_offset ) ||	 ( error = _HB_OPEN_Load_Coverage( &i[ni], stream ) ) != FT_Err_Ok )      goto Fail3;    (void)FILE_Seek( cur_offset );  }  if ( ACCESS_Frame( 2L ) )    goto Fail3;  ccsf3->LookaheadGlyphCount = GET_UShort();  FORGET_Frame();  ccsf3->LookaheadCoverage = NULL;  lookahead_count = ccsf3->LookaheadGlyphCount;  if ( ALLOC_ARRAY( ccsf3->LookaheadCoverage, lookahead_count,		    HB_Coverage ) )    goto Fail3;  l = ccsf3->LookaheadCoverage;  for ( nl = 0; nl < lookahead_count; nl++ )  {    if ( ACCESS_Frame( 2L ) )      goto Fail2;    new_offset = GET_UShort() + base_offset;    FORGET_Frame();    cur_offset = FILE_Pos();    if ( FILE_Seek( new_offset ) ||	 ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != FT_Err_Ok )      goto Fail2;    (void)FILE_Seek( cur_offset );  }  if ( ACCESS_Frame( 2L ) )    goto Fail2;  ccsf3->SubstCount = GET_UShort();  FORGET_Frame();  ccsf3->SubstLookupRecord = NULL;  count = ccsf3->SubstCount;  if ( ALLOC_ARRAY( ccsf3->SubstLookupRecord, count,		    HB_SubstLookupRecord ) )    goto Fail2;  slr = ccsf3->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 FT_Err_Ok;Fail1:  FREE( slr );Fail2:  for ( m = 0; m < nl; m++ )    _HB_OPEN_Free_Coverage( &l[m], memory );  FREE( l );Fail3:  for ( m = 0; m < ni; m++ )    _HB_OPEN_Free_Coverage( &i[m], memory );  FREE( i );Fail4:  for ( m = 0; m < nb; m++ )    _HB_OPEN_Free_Coverage( &b[m], memory );  FREE( b );  return error;}static void  Free_ChainContextSubst3( HB_ChainContextSubstFormat3*  ccsf3,				 FT_Memory                      memory ){  FT_UShort      n, count;  HB_Coverage*  c;  FREE( ccsf3->SubstLookupRecord );  if ( ccsf3->LookaheadCoverage )  {    count = ccsf3->LookaheadGlyphCount;    c     = ccsf3->LookaheadCoverage;    for ( n = 0; n < count; n++ )      _HB_OPEN_Free_Coverage( &c[n], memory );    FREE( c );  }  if ( ccsf3->InputCoverage )  {    count = ccsf3->InputGlyphCount;    c     = ccsf3->InputCoverage;    for ( n = 0; n < count; n++ )      _HB_OPEN_Free_Coverage( &c[n], memory );    FREE( c );  }  if ( ccsf3->BacktrackCoverage )  {    count = ccsf3->BacktrackGlyphCount;    c     = ccsf3->BacktrackCoverage;    for ( n = 0; n < count; n++ )      _HB_OPEN_Free_Coverage( &c[n], memory );    FREE( c );  }}/* ChainContextSubst */static FT_Error  Load_ChainContextSubst( HB_GSUB_SubTable* st,					 FT_Stream         stream ){  FT_Error error;  HB_ChainContextSubst*  ccs = &st->chain;  if ( ACCESS_Frame( 2L ) )    return error;  ccs->SubstFormat = GET_UShort();  FORGET_Frame();  switch ( ccs->SubstFormat )  {  case 1:    return Load_ChainContextSubst1( &ccs->ccsf.ccsf1, stream );  case 2:    return Load_ChainContextSubst2( &ccs->ccsf.ccsf2, stream );  case 3:    return Load_ChainContextSubst3( &ccs->ccsf.ccsf3, stream );  default:    return HB_Err_Invalid_GSUB_SubTable_Format;  }  return FT_Err_Ok;               /* never reached */}static void  Free_ChainContextSubst( HB_GSUB_SubTable* st,				     FT_Memory         memory ){  HB_ChainContextSubst*  ccs = &st->chain;  switch ( ccs->SubstFormat )  {  case 1:    Free_ChainContextSubst1( &ccs->ccsf.ccsf1, memory );    break;  case 2:    Free_ChainContextSubst2( &ccs->ccsf.ccsf2, memory );    break;  case 3:    Free_ChainContextSubst3( &ccs->ccsf.ccsf3, memory );    break;  }}static FT_Error  Lookup_ChainContextSubst1( HB_GSUBHeader*               gsub,					    HB_ChainContextSubstFormat1* ccsf1,					    HB_Buffer

⌨️ 快捷键说明

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