📄 ttapi.c
字号:
return TT_Err_Ok; }/******************************************************************* * * Function : TT_Get_Big_Glyph_Metrics * * Description : Extracts the glyph's big metrics information. * * Input : glyph glyph object handle * metrics address where big metrics will be returned * * Output : Error code. * * MT-Safe : NO! Glyph containers can't be shared. * ******************************************************************/ EXPORT_FUNC TT_Error TT_Get_Glyph_Big_Metrics( TT_Glyph glyph, TT_Big_Glyph_Metrics* metrics ) { FT_GlyphSlot slot = (FT_GlyphSlot)glyph; FT_Glyph_Metrics* met; FT_Glyph_Metrics* met2; if (!glyph) return TT_Err_Invalid_Glyph_Handle; met = &slot->metrics; met2 = &slot->metrics2; metrics->bbox.xMin = met->horiBearingX; metrics->bbox.xMax = met->horiBearingX + met->width; metrics->bbox.yMin = met->horiBearingY - met->height; metrics->bbox.yMax = met->horiBearingY; metrics->horiBearingX = met->horiBearingX; metrics->horiBearingY = met->horiBearingY; metrics->horiAdvance = met->horiAdvance; metrics->vertBearingX = met->vertBearingX; metrics->vertBearingY = met->vertBearingY; metrics->vertAdvance = met->vertAdvance; metrics->linearHoriAdvance = met2->horiAdvance; metrics->linearHoriBearingX = met2->horiBearingX; metrics->linearVertAdvance = met2->vertAdvance; metrics->linearVertBearingY = met2->vertBearingY; return TT_Err_Ok; }/******************************************************************* * * Function : TT_Get_Glyph_Bitmap * * Description : Produces a bitmap from a glyph outline. * * Input : glyph the glyph container's handle * map target pixmap description block * xOffset x offset in fractional pixels (26.6 format) * yOffset y offset in fractional pixels (26.6 format) * * Output : Error code. * * Note : Only use integer pixel offsets if you want to preserve * the fine hints applied to the outline. This means that * xOffset and yOffset must be multiples of 64! * * MT-Safe : NO! Glyph containers can't be shared. * ******************************************************************/ EXPORT_FUNC TT_Error TT_Get_Glyph_Bitmap( TT_Glyph glyph, TT_Raster_Map* map, TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ) { FT_Library library; TT_Error error; FT_GlyphSlot slot = (FT_GlyphSlot)glyph; FT_Outline outline; FT_Raster_Map bitmap; if ( !glyph ) return TT_Err_Invalid_Glyph_Handle; library = slot->face->resource->library; outline = slot->outline; /* XXX : For now, use only dropout mode 2 */ /* outline.dropout_mode = _glyph->scan_type; */ outline.dropout_mode = 2; bitmap.width = map->width; bitmap.rows = map->rows; bitmap.cols = map->cols; bitmap.flow = map->flow; bitmap.pix_bits = 1; bitmap.buffer = map->bitmap; FT_Translate_Outline( &outline, xOffset, yOffset ); error = FT_Get_Outline_Bitmap( library, &outline, &bitmap ); FT_Translate_Outline( &outline, -xOffset, -yOffset ); return error; }/******************************************************************* * * Function : TT_Get_Glyph_Pixmap * * Description : Produces a grayscaled pixmap from a glyph * outline. * * Input : glyph the glyph container's handle * map target pixmap description block * xOffset x offset in fractional pixels (26.6 format) * yOffset y offset in fractional pixels (26.6 format) * * Output : Error code. * * Note : Only use integer pixel offsets to preserve the fine * hinting of the glyph and the 'correct' anti-aliasing * (where vertical and horizontal stems aren't grayed). * This means that xOffset and yOffset must be multiples * of 64! * * You can experiment with offsets of +32 to get 'blurred' * versions of the glyphs (a nice effect at large sizes that * some graphic designers may appreciate :) * * MT-Safe : NO! Glyph containers can't be shared. * ******************************************************************/ EXPORT_FUNC TT_Error TT_Get_Glyph_Pixmap( TT_Glyph glyph, TT_Raster_Map* map, TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ) { FT_Library library; TT_Error error; FT_GlyphSlot slot = (FT_GlyphSlot)glyph; FT_Outline outline; FT_Raster_Map bitmap; if ( !glyph ) return TT_Err_Invalid_Glyph_Handle; library = slot->face->resource->library; outline = slot->outline; /* XXX : For now, use only dropout mode 2 */ /* outline.dropout_mode = _glyph->scan_type; */ outline.dropout_mode = 2; bitmap.width = map->width; bitmap.rows = map->rows; bitmap.cols = map->cols; bitmap.flow = map->flow; bitmap.pix_bits = 8; bitmap.buffer = map->bitmap; FT_Translate_Outline( &outline, xOffset, yOffset ); error = FT_Get_Outline_Bitmap( library, &outline, &bitmap ); FT_Translate_Outline( &outline, -xOffset, -yOffset ); return error; } /***********************************************************************/ /* */ /* <Function> TT_Get_Outline_Bitmap */ /* */ /* <Description> */ /* Renders an outline within a bitmap. The outline's image is */ /* simply or-ed to the target bitmap. */ /* */ /* <Input> */ /* engine :: handle to the TrueType driver object */ /* outline :: pointer to the source outline descriptor */ /* raster :: pointer to the target bitmap descriptor */ /* */ /* <Return> */ /* TrueType error code. 0 means success. */ /* */ /* <MT-Note> */ /* Yes. */ /* */ EXPORT_FUNC TT_Error TT_Get_Outline_Bitmap( TT_Engine engine, TT_Outline* outline, TT_Raster_Map* map ) { FT_Library library = (FT_Library)engine; FT_Raster_Map bitmap; if ( !engine ) return TT_Err_Invalid_Engine; if ( !outline || !map ) return TT_Err_Invalid_Argument; bitmap.width = map->width; bitmap.rows = map->rows; bitmap.cols = map->cols; bitmap.flow = map->flow; bitmap.pix_bits = 1; bitmap.buffer = map->bitmap; return FT_Get_Outline_Bitmap( library, (FT_Outline*)outline, &bitmap ); } /***********************************************************************/ /* */ /* <Function> TT_Get_Outline_Pixmap */ /* */ /* <Description> */ /* Renders an outline within a pixmap. The outline's image is */ /* simply or-ed to the target pixmap. */ /* */ /* <Input> */ /* engine :: handle to the TrueType driver object */ /* outline :: pointer to the source outline descriptor */ /* raster :: pointer to the target pixmap descriptor */ /* */ /* <Return> */ /* TrueType error code. 0 means success. */ /* */ /* <MT-Note> */ /* Yes. */ /* */ EXPORT_FUNC TT_Error TT_Get_Outline_Pixmap( TT_Engine engine, TT_Outline* outline, TT_Raster_Map* map ) { FT_Library library = (FT_Library)engine; FT_Raster_Map bitmap; if ( !engine ) return TT_Err_Invalid_Engine; if ( !outline || !map ) return TT_Err_Invalid_Argument; bitmap.width = map->width; bitmap.rows = map->rows; bitmap.cols = map->cols; bitmap.flow = map->flow; bitmap.pix_bits = 8; bitmap.buffer = map->bitmap; return FT_Get_Outline_Bitmap( library, (FT_Outline*)outline, &bitmap ); } /***********************************************************************/ /* */ /* <Function> TT_New_Outline */ /*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -