Example #1
0
HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef ) 
{  
  Free_LigCaretList( &gdef->LigCaretList );
  Free_AttachList( &gdef->AttachList );
  _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef );
  _HB_OPEN_Free_ClassDefinition( &gdef->MarkAttachClassDef );
  
  Free_NewGlyphClasses( gdef );

  FREE( gdef );

  return HB_Err_Ok;
}
Example #2
0
static FT_Error  GDEF_Destroy( void*  ext,
			       PFace  face )
{
  HB_GDEFHeader*  gdef = (HB_GDEFHeader*)ext;


  /* by convention */

  if ( !gdef )
    return FT_Err_Ok;

  if ( gdef->loaded )
  {
    Free_LigCaretList( &gdef->LigCaretList, memory );
    Free_AttachList( &gdef->AttachList, memory );
    _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef, memory );
    _HB_OPEN_Free_ClassDefinition( &gdef->MarkAttachClassDef, memory );

    Free_NewGlyphClasses( gdef, memory );
  }

  return FT_Err_Ok;
}
Example #3
0
FT_Error  HB_Load_GDEF_Table( FT_Face          face,
			      HB_GDEFHeader** retptr )
{
  FT_Error         error;
  FT_Memory        memory = face->memory;
  FT_Stream        stream = face->stream;
  FT_ULong         cur_offset, new_offset, base_offset;

  HB_GDEFHeader*  gdef;


  if ( !retptr )
    return FT_Err_Invalid_Argument;

  if (( error = _hb_ftglue_face_goto_table( face, TTAG_GDEF, stream ) ))
    return error;

  if (( error = HB_New_GDEF_Table ( face, &gdef ) ))
    return error;

  base_offset = FILE_Pos();

  /* skip version */

  if ( FILE_Seek( base_offset + 4L ) ||
       ACCESS_Frame( 2L ) )
    goto Fail0;

  new_offset = GET_UShort();

  FORGET_Frame();

  /* all GDEF subtables are optional */

  if ( new_offset )
  {
    new_offset += base_offset;

    /* only classes 1-4 are allowed here */

    cur_offset = FILE_Pos();
    if ( FILE_Seek( new_offset ) ||
	 ( error = _HB_OPEN_Load_ClassDefinition( &gdef->GlyphClassDef, 5,
					 stream ) ) != FT_Err_Ok )
      goto Fail0;
    (void)FILE_Seek( cur_offset );
  }

  if ( ACCESS_Frame( 2L ) )
    goto Fail1;

  new_offset = GET_UShort();

  FORGET_Frame();

  if ( new_offset )
  {
    new_offset += base_offset;

    cur_offset = FILE_Pos();
    if ( FILE_Seek( new_offset ) ||
	 ( error = Load_AttachList( &gdef->AttachList,
				    stream ) ) != FT_Err_Ok )
      goto Fail1;
    (void)FILE_Seek( cur_offset );
  }

  if ( ACCESS_Frame( 2L ) )
    goto Fail2;

  new_offset = GET_UShort();

  FORGET_Frame();

  if ( new_offset )
  {
    new_offset += base_offset;

    cur_offset = FILE_Pos();
    if ( FILE_Seek( new_offset ) ||
	 ( error = Load_LigCaretList( &gdef->LigCaretList,
				      stream ) ) != FT_Err_Ok )
      goto Fail2;
    (void)FILE_Seek( cur_offset );
  }

  /* OpenType 1.2 has introduced the `MarkAttachClassDef' field.  We
     first have to scan the LookupFlag values to find out whether we
     must load it or not.  Here we only store the offset of the table. */

  if ( ACCESS_Frame( 2L ) )
    goto Fail3;

  new_offset = GET_UShort();

  FORGET_Frame();

  if ( new_offset )
    gdef->MarkAttachClassDef_offset = new_offset + base_offset;
  else
    gdef->MarkAttachClassDef_offset = 0;

  *retptr = gdef;

  return FT_Err_Ok;

Fail3:
  Free_LigCaretList( &gdef->LigCaretList, memory );
  
Fail2:
  Free_AttachList( &gdef->AttachList, memory );

Fail1:
  _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef, memory );

Fail0:
  FREE( gdef );

  return error;
}