📄 ttapi.c
字号:
get_metrics( &face->horizontal, firstGlyph + n, &left_bearing, &advance_width ); if ( leftBearings ) leftBearings[n] = left_bearing; if ( widths ) widths[n] = advance_width; } } /* check for vertical data if topBearings or heights is non-NULL */ if ( !topBearings && !heights ) return TT_Err_Ok; if ( !face->vertical_info ) return TT_Err_No_Vertical_Data; /* store the top side bearings */ { TT_UShort n; TT_Short top_bearing; TT_UShort advance_height; for ( n = 0; n <= num; n++ ) { get_metrics( (TT_HoriHeader*)&face->vertical, firstGlyph + n, &top_bearing, &advance_height ); if ( topBearings ) topBearings[n] = top_bearing; if ( heights ) heights[n] = advance_height; } } return TT_Err_Ok; } /***********************************************************************/ /* */ /* <Function> TT_New_Instance */ /* */ /* <Description> */ /* Creates a new instance object from a given face */ /* */ /* <Input> */ /* face :: handle to source/parent face object */ /* */ /* <Output> */ /* instance :: handle to fresh object. Set to NULL in case of */ /* error. */ /* */ /* <Return> */ /* TrueType error code. 0 means success */ /* */ /* <MT-Note> */ /* Yes. */ /* */ /* <Note> */ /* Any new instance uses a default resolution of 96x96 dpi, and */ /* a default point size of 10 pts. You can change these anytime */ /* with TT_Set_Instance_Resolutions/CharSize/CharSizes/PixelSizes */ /* (see below). */ /* */ EXPORT_FUNC TT_Error TT_New_Instance( TT_Face face, TT_Instance* instance ) { return FT_New_Size( (FT_Face)face, (FT_Size*)instance ); } /***********************************************************************/ /* */ /* <Function> TT_Set_Instance_Resolutions */ /* */ /* <Description> */ /* Sets an instance resolutions in dot-per-inches. Default values */ /* for "new" instances are 96x96 dpi, but these can be changed any */ /* time by calling this API. */ /* */ /* <Input> */ /* instance :: handle to target instance object */ /* xResolution :: horizontal device resolution in dpi. */ /* yResolution :: vertical device resolution in dpi. */ /* */ /* <Return> */ /* TrueType error code. 0 means success */ /* */ /* <MT-Note> */ /* You should set the charsize or pixel size immediately after */ /* call in multi-htreaded programs. This will force the instance */ /* data to be resetted. Otherwise, you may encounter corruption */ /* when loading two glyphs from the same instance concurrently! */ /* */ /* Happily, 99.99% will do just that :-) */ /* */ /* */ /* */ EXPORT_FUNC TT_Error TT_Set_Instance_Resolutions( TT_Instance ins, TT_UShort xResolution, TT_UShort yResolution ) { return FT_Set_Resolutions( (FT_Size)ins, xResolution, yResolution ); } /***********************************************************************/ /* */ /* <Function> TT_Set_Instance_CharSizes */ /* */ /* <Description> */ /* Same as TT_Set_Instance_CharSize, but used to specify distinct */ /* horizontal and vertical coordinates. */ /* */ /* <Input> */ /* instance :: handle to target instance object */ /* charWidth :: horizontal character size (26.6 points) */ /* charHeight :: vertical character size (26.6 points) */ /* */ /* <Return> */ /* TrueType error code. 0 means success */ /* */ /* <MT-Note> */ /* No. */ /* */ /* <Note> */ /* There is no check for overflow; with other words, the product */ /* of glyph dimensions times the device resolution must have */ /* reasonable values. */ /* */ EXPORT_FUNC TT_Error TT_Set_Instance_CharSizes( TT_Instance ins, TT_F26Dot6 charWidth, TT_F26Dot6 charHeight ) { return FT_Set_Char_Sizes( (FT_Size)ins, charWidth, charHeight ); } /***********************************************************************/ /* */ /* <Function> TT_Set_Instance_CharSize */ /* */ /* <Description> */ /* Sets an instance's character size. The size is in fractional */ /* (26.6) point units. This function sets the horizontal and */ /* vertical sizes to be equal. Use TT_Set_Instance_CharSizes */ /* for distinct X and Y char sizes. */ /* */ /* The default charsize of a new instance object is 10 pts. */ /* */ /* <Input> */ /* instance :: handle to target instance object */ /* charSize :: character size expressed in 26.6 fixed float */ /* points. 1 point = 1/72 dpi. */ /* */ /* <Return> */ /* TrueType error code. 0 means success */ /* */ /* <MT-Note> */ /* No. */ /* */ EXPORT_FUNC TT_Error TT_Set_Instance_CharSize( TT_Instance instance, TT_F26Dot6 charSize ) { return TT_Set_Instance_CharSizes( instance, charSize, charSize ); } /***********************************************************************/ /* */ /* <Function> TT_Set_Instance_PixelSizes */ /* */ /* <Description> */ /* This function is used to set an instance's pixel sizes directly */ /* It ignores the instance's resolutions fields, and you'll have to */ /* specify the corresponding pointsize in 26.6 fixed float point */ /* units. The latter is a requirement of the TrueType bytecode */ /* interpreter but can be ignored (or more safely, set to the */ /* maximum pixel size multiplied by 64). */ /* */ /* <Input> */ /* instance :: handle to target instance object */ /* pixelWidth :: horizontal pixel width (integer value) */ /* pixelHeight :: vertical pixel height (integer value) */ /* pointSize :: corresponding point size (26.6 points) */ /* */ /* <Return> */ /* TrueType error code. 0 means success. */ /* */ /* <MT-Note> */ /* No. */ /* */ EXPORT_FUNC TT_Error TT_Set_Instance_PixelSizes( TT_Instance ins, TT_UShort pixelWidth, TT_UShort pixelHeight, TT_F26Dot6 pointSize ) { /* The point size is now ignored by the driver */ (void)pointSize; return FT_Set_Pixel_Sizes( (FT_Size)ins, pixelWidth, pixelHeight ); } /***********************************************************************/ /* */ /* <Function> TT_Get_Instance_Metrics */ /* */ /* <Description> */ /* Returns an instance's metrics into caller space. */ /* */ /* <Input> */ /* instance :: handle to source instance object */ /* */ /* <Output> */ /* metrics :: target instance metrics structure */ /* */ /* <Return> */ /* TrueType error code. 0 means success */ /* */ /* <MT-Note> */ /* No. */ /* */ /* <Note> */ /* The TT_Instance_Metrics structure differs slightly from the */ /* FT_Instance_Metrics one, which is why we re-implement this */ /* function, rather than call a driver method for this.. */ /* */ EXPORT_FUNC TT_Error TT_Get_Instance_Metrics( TT_Instance ins, TT_Instance_Metrics* metrics ) { TT_Size size = (TT_Size)ins; if (!ins) return TT_Err_Invalid_Instance_Handle; metrics->x_scale = size->root.metrics.x_scale; metrics->y_scale = size->root.metrics.y_scale; metrics->x_resolution = size->root.metrics.x_resolution; metrics->y_resolution = size->root.metrics.y_resolution; metrics->x_ppem = size->root.metrics.x_ppem; metrics->y_ppem = size->root.metrics.y_ppem; metrics->pointSize = size->root.metrics.pointSize; return TT_Err_Ok; } /***********************************************************************/ /* */ /* <Function> TT_Set_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 set this generic pointer. It is ignored by the */ /* driver. */ /* */ /* <Input> */ /* instance :: handle to the target instance object */ /* data :: value of the generic pointer */ /* */ /* <Return> */ /* TrueType error code. 0 means success */ /* */ /* <MT-Note> */ /* No. */ /* */ EXPORT_FUNC TT_Error TT_Set_Instance_Pointer( TT_Instance ins, void* data ) { if ( !ins ) return TT_Err_Invalid_Instance_Handle; else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -