1 // Copyright 2014 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FXGE_FREETYPE_FX_FREETYPE_H_ 8 #define CORE_FXGE_FREETYPE_FX_FREETYPE_H_ 9 10 #include <ft2build.h> 11 12 #include <memory> 13 14 #include FT_FREETYPE_H 15 #include FT_GLYPH_H 16 #include FT_LCD_FILTER_H 17 #include FT_MULTIPLE_MASTERS_H 18 #include FT_OUTLINE_H 19 #include FT_TRUETYPE_TABLES_H 20 21 using FXFT_LibraryRec = struct FT_LibraryRec_; 22 using FXFT_FaceRec = struct FT_FaceRec_; 23 using FXFT_StreamRec = struct FT_StreamRec_; 24 using FXFT_MM_VarPtr = FT_MM_Var*; 25 26 struct FXFTFaceRecDeleter { operatorFXFTFaceRecDeleter27 inline void operator()(FXFT_FaceRec* pRec) { FT_Done_Face(pRec); } 28 }; 29 30 struct FXFTLibraryRecDeleter { operatorFXFTLibraryRecDeleter31 inline void operator()(FXFT_LibraryRec* pRec) { FT_Done_FreeType(pRec); } 32 }; 33 34 using ScopedFXFTFaceRec = std::unique_ptr<FXFT_FaceRec, FXFTFaceRecDeleter>; 35 using ScopedFXFTLibraryRec = 36 std::unique_ptr<FXFT_LibraryRec, FXFTLibraryRecDeleter>; 37 38 #define FXFT_Select_Charmap(face, encoding) \ 39 FT_Select_Charmap(face, static_cast<FT_Encoding>(encoding)) 40 #define FXFT_Render_Glyph(face, mode) \ 41 FT_Render_Glyph((face)->glyph, static_cast<enum FT_Render_Mode_>(mode)) 42 43 #define FXFT_Has_Glyph_Names(face) \ 44 (((face)->face_flags) & FT_FACE_FLAG_GLYPH_NAMES) 45 #define FXFT_Clear_Face_External_Stream(face) \ 46 ((face)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM) 47 #define FXFT_Get_Face_External_Stream(face) \ 48 (((face)->face_flags) & FT_FACE_FLAG_EXTERNAL_STREAM) 49 #define FXFT_Is_Face_TT_OT(face) (((face)->face_flags) & FT_FACE_FLAG_SFNT) 50 #define FXFT_Is_Face_Tricky(face) (((face)->face_flags) & FT_FACE_FLAG_TRICKY) 51 #define FXFT_Is_Face_fixedwidth(face) \ 52 (((face)->face_flags) & FT_FACE_FLAG_FIXED_WIDTH) 53 #define FXFT_Get_Face_Stream_Base(face) (face)->stream->base 54 #define FXFT_Get_Face_Stream_Size(face) (face)->stream->size 55 #define FXFT_Get_Face_Family_Name(face) (face)->family_name 56 #define FXFT_Get_Face_Style_Name(face) (face)->style_name 57 #define FXFT_Is_Face_Italic(face) (((face)->style_flags) & FT_STYLE_FLAG_ITALIC) 58 #define FXFT_Is_Face_Bold(face) (((face)->style_flags) & FT_STYLE_FLAG_BOLD) 59 #define FXFT_Get_Glyph_HoriBearingX(face) (face)->glyph->metrics.horiBearingX 60 #define FXFT_Get_Glyph_HoriBearingY(face) (face)->glyph->metrics.horiBearingY 61 #define FXFT_Get_Glyph_Width(face) (face)->glyph->metrics.width 62 #define FXFT_Get_Glyph_Height(face) (face)->glyph->metrics.height 63 #define FXFT_Get_Charmap_Encoding(charmap) (charmap)->encoding 64 #define FXFT_Get_Charmap_PlatformID(charmap) (charmap)->platform_id 65 #define FXFT_Get_Charmap_EncodingID(charmap) (charmap)->encoding_id 66 #define FXFT_Get_Face_UnitsPerEM(face) (face)->units_per_EM 67 #define FXFT_Get_Face_xMin(face) (face)->bbox.xMin 68 #define FXFT_Get_Face_xMax(face) (face)->bbox.xMax 69 #define FXFT_Get_Face_yMin(face) (face)->bbox.yMin 70 #define FXFT_Get_Face_yMax(face) (face)->bbox.yMax 71 #define FXFT_Get_Face_Height(face) (face)->height 72 #define FXFT_Get_Face_Ascender(face) (face)->ascender 73 #define FXFT_Get_Face_Descender(face) (face)->descender 74 #define FXFT_Get_Glyph_HoriAdvance(face) (face)->glyph->metrics.horiAdvance 75 #define FXFT_Get_MM_Axis(var, index) (var)->axis[index] 76 #define FXFT_Get_MM_Axis_Min(axis) (axis).minimum 77 #define FXFT_Get_MM_Axis_Max(axis) (axis).maximum 78 #define FXFT_Get_MM_Axis_Def(axis) (axis).def 79 #define FXFT_Free(face, p) (face)->memory->free((face)->memory, p) 80 #define FXFT_Get_Glyph_Outline(face) &((face)->glyph->outline) 81 #define FXFT_Get_Glyph_Bitmap(face) (face)->glyph->bitmap 82 #define FXFT_Get_Bitmap_Width(bitmap) (bitmap).width 83 #define FXFT_Get_Bitmap_Rows(bitmap) (bitmap).rows 84 #define FXFT_Get_Bitmap_PixelMode(bitmap) (bitmap).pixel_mode 85 #define FXFT_Get_Bitmap_Pitch(bitmap) (bitmap).pitch 86 #define FXFT_Get_Bitmap_Buffer(bitmap) (bitmap).buffer 87 #define FXFT_Get_Glyph_BitmapLeft(face) (face)->glyph->bitmap_left 88 #define FXFT_Get_Glyph_BitmapTop(face) (face)->glyph->bitmap_top 89 90 int FXFT_unicode_from_adobe_name(const char* glyph_name); 91 void FXFT_adobe_name_from_unicode(char* name, wchar_t unicode); 92 93 #endif // CORE_FXGE_FREETYPE_FX_FREETYPE_H_ 94