1 // Copyright 2014 PDFium Authors. All rights reserved. 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_INCLUDE_FXGE_FX_FREETYPE_H_ 8 #define CORE_INCLUDE_FXGE_FX_FREETYPE_H_ 9 10 #include <ft2build.h> 11 #include <freetype.h> 12 #include <ftglyph.h> 13 #include <ftlcdfil.h> 14 #include <ftmm.h> 15 #include <ftoutln.h> 16 #include <tttables.h> 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 #define FXFT_ENCODING_UNICODE FT_ENCODING_UNICODE 21 #define FXFT_ENCODING_ADOBE_STANDARD FT_ENCODING_ADOBE_STANDARD 22 #define FXFT_ENCODING_ADOBE_EXPERT FT_ENCODING_ADOBE_EXPERT 23 #define FXFT_ENCODING_ADOBE_LATIN_1 FT_ENCODING_ADOBE_LATIN_1 24 #define FXFT_ENCODING_APPLE_ROMAN FT_ENCODING_APPLE_ROMAN 25 #define FXFT_ENCODING_ADOBE_CUSTOM FT_ENCODING_ADOBE_CUSTOM 26 #define FXFT_ENCODING_MS_SYMBOL FT_ENCODING_MS_SYMBOL 27 #define FXFT_ENCODING_GB2312 FT_ENCODING_GB2312 28 #define FXFT_ENCODING_BIG5 FT_ENCODING_BIG5 29 #define FXFT_ENCODING_SJIS FT_ENCODING_SJIS 30 #define FXFT_ENCODING_JOHAB FT_ENCODING_JOHAB 31 #define FXFT_ENCODING_WANSUNG FT_ENCODING_WANSUNG 32 #define FXFT_LOAD_NO_SCALE FT_LOAD_NO_SCALE 33 #define FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH \ 34 FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 35 #define FXFT_RENDER_MODE_LCD FT_RENDER_MODE_LCD 36 #define FXFT_RENDER_MODE_MONO FT_RENDER_MODE_MONO 37 #define FXFT_RENDER_MODE_NORMAL FT_RENDER_MODE_NORMAL 38 #define FXFT_LOAD_IGNORE_TRANSFORM FT_LOAD_IGNORE_TRANSFORM 39 #define FXFT_LOAD_NO_BITMAP FT_LOAD_NO_BITMAP 40 #define FXFT_LOAD_NO_HINTING FT_LOAD_NO_HINTING 41 #define FXFT_PIXEL_MODE_MONO FT_PIXEL_MODE_MONO 42 #define FXFT_STYLE_FLAG_ITALIC FT_STYLE_FLAG_ITALIC 43 #define FXFT_STYLE_FLAG_BOLD FT_STYLE_FLAG_BOLD 44 #define FXFT_FACE_FLAG_SFNT FT_FACE_FLAG_SFNT 45 #define FXFT_FACE_FLAG_TRICKY (1L << 13) 46 typedef FT_MM_Var* FXFT_MM_Var; 47 typedef FT_Bitmap* FXFT_Bitmap; 48 #define FXFT_Matrix FT_Matrix 49 #define FXFT_Vector FT_Vector 50 #define FXFT_Outline_Funcs FT_Outline_Funcs 51 typedef FT_Open_Args FXFT_Open_Args; 52 typedef FT_StreamRec FXFT_StreamRec; 53 typedef FT_StreamRec* FXFT_Stream; 54 typedef FT_BBox FXFT_BBox; 55 typedef FT_Glyph FXFT_Glyph; 56 typedef FT_CharMap FXFT_CharMap; 57 #define FXFT_GLYPH_BBOX_PIXELS FT_GLYPH_BBOX_PIXELS 58 #define FXFT_Open_Face(library, args, index, face) \ 59 FT_Open_Face((FT_Library)(library), args, index, (FT_Face*)(face)) 60 #define FXFT_Done_Face(face) FT_Done_Face((FT_Face)(face)) 61 #define FXFT_Done_FreeType(library) FT_Done_FreeType((FT_Library)(library)) 62 #define FXFT_Init_FreeType(library) FT_Init_FreeType((FT_Library*)(library)) 63 #define FXFT_New_Memory_Face(library, base, size, index, face) \ 64 FT_New_Memory_Face((FT_Library)(library), base, size, index, (FT_Face*)(face)) 65 #define FXFT_New_Face(library, filename, index, face) \ 66 FT_New_Face((FT_Library)(library), filename, index, (FT_Face*)(face)) 67 #define FXFT_Get_Face_FreeType(face) ((FT_Face)face)->driver->root.library 68 #define FXFT_Select_Charmap(face, encoding) \ 69 FT_Select_Charmap((FT_Face)face, (FT_Encoding)encoding) 70 #define FXFT_Set_Charmap(face, charmap) \ 71 FT_Set_Charmap((FT_Face)face, (FT_CharMap)charmap) 72 #define FXFT_Load_Glyph(face, glyph_index, flags) \ 73 FT_Load_Glyph((FT_Face)face, glyph_index, flags) 74 #define FXFT_Get_Char_Index(face, code) FT_Get_Char_Index((FT_Face)face, code) 75 #define FXFT_Get_Glyph_Name(face, index, buffer, size) \ 76 FT_Get_Glyph_Name((FT_Face)face, index, buffer, size) 77 #define FXFT_Get_Name_Index(face, name) FT_Get_Name_Index((FT_Face)face, name) 78 #define FXFT_Has_Glyph_Names(face) \ 79 (((FT_Face)face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES) 80 #define FXFT_Get_Postscript_Name(face) FT_Get_Postscript_Name((FT_Face)face) 81 #define FXFT_Load_Sfnt_Table(face, tag, offset, buffer, length) \ 82 FT_Load_Sfnt_Table((FT_Face)face, tag, offset, buffer, length) 83 #define FXFT_Get_First_Char(face, glyph_index) \ 84 FT_Get_First_Char((FT_Face)face, glyph_index) 85 #define FXFT_Get_Next_Char(face, code, glyph_index) \ 86 FT_Get_Next_Char((FT_Face)face, code, glyph_index) 87 #define FXFT_Clear_Face_External_Stream(face) \ 88 (((FT_Face)face)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM) 89 #define FXFT_Get_Face_External_Stream(face) \ 90 (((FT_Face)face)->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM) 91 #define FXFT_Is_Face_TT_OT(face) \ 92 (((FT_Face)face)->face_flags & FT_FACE_FLAG_SFNT) 93 #define FXFT_Is_Face_Tricky(face) \ 94 (((FT_Face)face)->face_flags & FXFT_FACE_FLAG_TRICKY) 95 #define FXFT_Is_Face_fixedwidth(face) \ 96 (((FT_Face)face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH) 97 #define FXFT_Get_Face_Stream_Base(face) ((FT_Face)face)->stream->base 98 #define FXFT_Get_Face_Stream_Size(face) ((FT_Face)face)->stream->size 99 #define FXFT_Get_Face_Family_Name(face) ((FT_Face)face)->family_name 100 #define FXFT_Get_Face_Style_Name(face) ((FT_Face)face)->style_name 101 #define FXFT_Get_Face_Numfaces(face) ((FT_Face)face)->num_faces 102 #define FXFT_Get_Face_Faceindex(face) ((FT_Face)face)->face_index 103 #define FXFT_Is_Face_Italic(face) \ 104 (((FT_Face)face)->style_flags & FT_STYLE_FLAG_ITALIC) 105 #define FXFT_Is_Face_Bold(face) \ 106 (((FT_Face)face)->style_flags & FT_STYLE_FLAG_BOLD) 107 #define FXFT_Get_Face_Charmaps(face) ((FT_Face)face)->charmaps 108 #define FXFT_Get_Glyph_HoriBearingX(face) \ 109 ((FT_Face)face)->glyph->metrics.horiBearingX 110 #define FXFT_Get_Glyph_HoriBearingY(face) \ 111 ((FT_Face)face)->glyph->metrics.horiBearingY 112 #define FXFT_Get_Glyph_Width(face) ((FT_Face)face)->glyph->metrics.width 113 #define FXFT_Get_Glyph_Height(face) ((FT_Face)face)->glyph->metrics.height 114 #define FXFT_Get_Face_CharmapCount(face) ((FT_Face)face)->num_charmaps 115 #define FXFT_Get_Charmap_Encoding(charmap) ((FT_CharMap)charmap)->encoding 116 #define FXFT_Get_Face_Charmap(face) ((FT_Face)face)->charmap 117 #define FXFT_Get_Charmap_PlatformID(charmap) ((FT_CharMap)charmap)->platform_id 118 #define FXFT_Get_Charmap_EncodingID(charmap) ((FT_CharMap)charmap)->encoding_id 119 #define FXFT_Get_Face_UnitsPerEM(face) ((FT_Face)face)->units_per_EM 120 #define FXFT_Get_Face_xMin(face) ((FT_Face)face)->bbox.xMin 121 #define FXFT_Get_Face_xMax(face) ((FT_Face)face)->bbox.xMax 122 #define FXFT_Get_Face_yMin(face) ((FT_Face)face)->bbox.yMin 123 #define FXFT_Get_Face_yMax(face) ((FT_Face)face)->bbox.yMax 124 #define FXFT_Get_Face_Height(face) ((FT_Face)face)->height 125 #define FXFT_Get_Face_UnderLineThickness(face) \ 126 ((FT_Face)face)->underline_thickness 127 #define FXFT_Get_Face_UnderLinePosition(face) \ 128 ((FT_Face)face)->underline_position 129 #define FXFT_Get_Face_MaxAdvanceWidth(face) ((FT_Face)face)->max_advance_width 130 #define FXFT_Get_Face_Ascender(face) ((FT_Face)face)->ascender 131 #define FXFT_Get_Face_Descender(face) ((FT_Face)face)->descender 132 #define FXFT_Get_Glyph_HoriAdvance(face) \ 133 ((FT_Face)face)->glyph->metrics.horiAdvance 134 #define FXFT_Get_MM_Axis(var, index) &((FT_MM_Var*)var)->axis[index] 135 #define FXFT_Get_MM_Axis_Min(axis) ((FT_Var_Axis*)axis)->minimum 136 #define FXFT_Get_MM_Axis_Max(axis) ((FT_Var_Axis*)axis)->maximum 137 #define FXFT_Get_MM_Axis_Def(axis) ((FT_Var_Axis*)axis)->def 138 #define FXFT_Alloc(library, size) \ 139 ((FT_Library)library)->memory->alloc(((FT_Library)library)->memory, size) 140 #define FXFT_Free(face, p) \ 141 ((FT_Face)face)->memory->free(((FT_Face)face)->memory, p) 142 #define FXFT_Get_Glyph_Outline(face) &((FT_Face)face)->glyph->outline 143 #define FXFT_Get_Outline_Bbox(outline, cbox) FT_Outline_Get_CBox(outline, cbox) 144 #define FXFT_Render_Glyph(face, mode) \ 145 FT_Render_Glyph(((FT_Face)face)->glyph, (enum FT_Render_Mode_)mode) 146 #define FXFT_Get_MM_Var(face, p) FT_Get_MM_Var((FT_Face)face, p) 147 #define FXFT_Set_MM_Design_Coordinates(face, n, p) \ 148 FT_Set_MM_Design_Coordinates((FT_Face)face, n, p) 149 #define FXFT_Set_Pixel_Sizes(face, w, h) FT_Set_Pixel_Sizes((FT_Face)face, w, h) 150 #define FXFT_Set_Transform(face, m, d) FT_Set_Transform((FT_Face)face, m, d) 151 #define FXFT_Outline_Embolden(outline, s) FT_Outline_Embolden(outline, s) 152 #define FXFT_Get_Glyph_Bitmap(face) &((FT_Face)face)->glyph->bitmap 153 #define FXFT_Get_Bitmap_Width(bitmap) ((FT_Bitmap*)bitmap)->width 154 #define FXFT_Get_Bitmap_Rows(bitmap) ((FT_Bitmap*)bitmap)->rows 155 #define FXFT_Get_Bitmap_PixelMode(bitmap) ((FT_Bitmap*)bitmap)->pixel_mode 156 #define FXFT_Get_Bitmap_Pitch(bitmap) ((FT_Bitmap*)bitmap)->pitch 157 #define FXFT_Get_Bitmap_Buffer(bitmap) ((FT_Bitmap*)bitmap)->buffer 158 #define FXFT_Get_Glyph_BitmapLeft(face) ((FT_Face)face)->glyph->bitmap_left 159 #define FXFT_Get_Glyph_BitmapTop(face) ((FT_Face)face)->glyph->bitmap_top 160 #define FXFT_Outline_Decompose(outline, funcs, params) \ 161 FT_Outline_Decompose(outline, funcs, params) 162 #define FXFT_Set_Char_Size(face, char_width, char_height, horz_resolution, \ 163 vert_resolution) \ 164 FT_Set_Char_Size(face, char_width, char_height, horz_resolution, \ 165 vert_resolution) 166 #define FXFT_Get_Glyph(slot, aglyph) FT_Get_Glyph(slot, aglyph) 167 #define FXFT_Glyph_Get_CBox(glyph, bbox_mode, acbox) \ 168 FT_Glyph_Get_CBox(glyph, bbox_mode, acbox) 169 #define FXFT_Done_Glyph(glyph) FT_Done_Glyph(glyph) 170 #define FXFT_Library_SetLcdFilter(library, filter) \ 171 FT_Library_SetLcdFilter((FT_Library)(library), filter) 172 int FXFT_unicode_from_adobe_name(const char* glyph_name); 173 void FXFT_adobe_name_from_unicode(char* name, wchar_t unicode); 174 #ifdef __cplusplus 175 }; 176 #endif 177 178 #endif // CORE_INCLUDE_FXGE_FX_FREETYPE_H_ 179