📄 ttapi.c
字号:
((FT_Size)ins)->generic.data = data; return TT_Err_Ok; } /***********************************************************************/ /* */ /* <Function> TT_Get_Instance_Pointer */ /* */ /* <Description> */ /* Each instance object contains a typeless pointer, which use is */ /* left to client applications (or the high-level library). This */ /* API is used to retrieve this generic pointer. It is ignored by */ /* the driver. */ /* */ /* <Input> */ /* instance :: handle to source instance object */ /* */ /* <Return> */ /* value of generic pointer. NULL if invalid instance */ /* */ /* <MT-Note> */ /* No. */ EXPORT_FUNC void* TT_Get_Instance_Pointer( TT_Instance instance ) { if ( !instance ) return NULL; else return ((FT_Size)instance)->generic.data; } /***********************************************************************/ /* */ /* <Function> TT_Done_Instance */ /* */ /* <Description> */ /* Destroys a given instance object. All instances are destroyed */ /* automatically when their parent face object is discarded. */ /* However, this API can be used to save memory. */ /* */ /* <Input> */ /* instance :: handle to target instance object */ /* */ /* <Return> */ /* TrueType error code. 0 means success */ /* */ /* <MT-Note> */ /* No. */ EXPORT_FUNC TT_Error TT_Done_Instance( TT_Instance ins ) { FT_Done_Size( (FT_Size)ins ); return TT_Err_Ok; } /***********************************************************************/ /* */ /* <Function> TT_Set_Instance_Transform_Flags */ /* */ /* <Description> */ /* Nothing. This function has been deprecated... */ /* */ /* <Input> */ /* instance :: handle to target instance object */ /* rotated :: 'rotation' flag.. */ /* stretched :: 'stretch' flag.. */ /* */ /* <Return> */ /* Always 0. */ /* */ /* <Note> */ /* This function has been deprecated !! Do not use it, it doesn't */ /* do anything now.. */ /* */ EXPORT_FUNC TT_Error TT_Set_Instance_Transform_Flags( TT_Instance instance, TT_Bool rotated, TT_Bool stretched ) { (void)instance; /* the parameters are unused, the (void) prevents */ (void)rotated; /* warnings from pedantic compilers.. */ (void)stretched; return TT_Err_Ok; } /***********************************************************************/ /* */ /* <Function> */ /* */ /* <Description> */ /* */ /* */ /* <Input> */ /* */ /* */ /* <Output> */ /* */ /* */ /* <Return> */ /* TrueType error code. 0 means success */ /* */ /* */ /* <MT-Note> */ /* */ /* */ /* */ /* <Note> */ /* */ /* */ /* *//******************************************************************* * * Function : TT_New_Glyph * * Description : Creates a new glyph object related to a given * face. * * Input : face the face handle * glyph address of target glyph handle * * Output : Error code. * * MT-Safe : YES! * ******************************************************************/ EXPORT_FUNC TT_Error TT_New_Glyph( TT_Face face, TT_Glyph* aglyph ) { return FT_New_GlyphSlot( (FT_Face)face, (FT_GlyphSlot*)aglyph ); }/******************************************************************* * * Function : TT_Done_Glyph * * Description : Destroys a given glyph object. * * Input : glyph the glyph handle * * Output : Error code. * * MT-Safe : YES! * ******************************************************************/ EXPORT_FUNC TT_Error TT_Done_Glyph( TT_Glyph glyph ) { FT_Done_GlyphSlot( (FT_GlyphSlot)glyph ); return TT_Err_Ok; }/******************************************************************* * * Function : TT_Load_Glyph * * Description : Loads a glyph. * * Input : instance the instance handle * glyph the glyph handle * glyphIndex the glyph index * loadFlags flags controlling how to load the glyph * (none, scaled, hinted, both) * * Output : Error code. * * MT-Safe : YES! * ******************************************************************/ EXPORT_FUNC TT_Error TT_Load_Glyph( TT_Instance instance, TT_Glyph glyph, TT_UShort glyphIndex, TT_UShort loadFlags ) { TT_Int result, flags; flags = 0; /* Convert load flags */ if ( (loadFlags & TTLOAD_SCALE_GLYPH) == 0 ) flags = FT_LOAD_NO_SCALE; else if ( (loadFlags & TTLOAD_HINT_GLYPH) == 0 ) flags = FT_LOAD_NO_HINTING; else flags = FT_LOAD_DEFAULT; flags |= FT_LOAD_NO_BITMAP | /* prevent bitmap loading for */ FT_LOAD_LINEAR; /* compatibility purposes.. */ return FT_Load_Glyph( (FT_GlyphSlot)glyph, (FT_Size)instance, glyphIndex, flags, &result ); }/******************************************************************* * * Function : TT_Get_Glyph_Outline * * Description : Returns the glyph's outline data. * * Input : glyph the glyph handle * outline address where the glyph outline will be returned * * Output : Error code. * * MT-Safe : YES! Reads only semi-permanent data. * ******************************************************************/ EXPORT_FUNC TT_Error TT_Get_Glyph_Outline( TT_Glyph glyph, TT_Outline* outline ) { FT_GlyphSlot slot = (FT_GlyphSlot)glyph; if (!glyph) return TT_Err_Invalid_Glyph_Handle; /* the structures TT_Outline and FT_Outline are equivalent */ *((FT_Outline*)outline) = slot->outline; return TT_Err_Ok; }/******************************************************************* * * Function : TT_Get_Glyph_Metrics * * Description : Extracts the glyph's horizontal metrics information. * * Input : glyph glyph object handle * metrics address where metrics will be returned * * Output : Error code. * * MT-Safe : NO! Glyph containers can't be shared. * ******************************************************************/ EXPORT_FUNC TT_Error TT_Get_Glyph_Metrics( TT_Glyph glyph, TT_Glyph_Metrics* metrics ) { FT_GlyphSlot slot = (FT_GlyphSlot)glyph; if (!glyph) return TT_Err_Invalid_Glyph_Handle; /* TT_Glyph_Metrics and FT_Glyph_Metrics are slightly different */ metrics->bbox.xMin = slot->metrics.horiBearingX; metrics->bbox.xMax = slot->metrics.horiBearingX + slot->metrics.width; metrics->bbox.yMax = slot->metrics.horiBearingY; metrics->bbox.yMin = slot->metrics.horiBearingY - slot->metrics.height; metrics->bearingX = slot->metrics.horiBearingX; metrics->bearingY = slot->metrics.horiBearingY; metrics->advance = slot->metrics.horiAdvance;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -