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