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.
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
7 #ifndef PUBLIC_FPDF_SYSFONTINFO_H_
8 #define PUBLIC_FPDF_SYSFONTINFO_H_
12 /* Character sets for the font */
13 #define FXFONT_ANSI_CHARSET 0
14 #define FXFONT_DEFAULT_CHARSET 1
15 #define FXFONT_SYMBOL_CHARSET 2
16 #define FXFONT_SHIFTJIS_CHARSET 128
17 #define FXFONT_HANGEUL_CHARSET 129
18 #define FXFONT_GB2312_CHARSET 134
19 #define FXFONT_CHINESEBIG5_CHARSET 136
21 /* Font pitch and family flags */
22 #define FXFONT_FF_FIXEDPITCH 1
23 #define FXFONT_FF_ROMAN (1<<4)
24 #define FXFONT_FF_SCRIPT (4<<4)
26 /* Typical weight values */
27 #define FXFONT_FW_NORMAL 400
28 #define FXFONT_FW_BOLD 700
36 * Interface: FPDF_SYSFONTINFO
37 * Interface for getting system font information and font mapping
39 typedef struct _FPDF_SYSFONTINFO {
41 * Version number of the interface. Currently must be 1.
47 * Give implementation a chance to release any data after the interface is no longer used
50 * Implementation Required:
53 * Called by Foxit SDK during the final cleanup process.
55 * pThis - Pointer to the interface structure itself
59 void (*Release)(struct _FPDF_SYSFONTINFO* pThis);
63 * Enumerate all fonts installed on the system
66 * Implementation Required:
69 * Implementation should call FPDF_AddIntalledFont() function for each font found.
70 * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK.
72 * pThis - Pointer to the interface structure itself
73 * pMapper - An opaque pointer to internal font mapper, used when calling FPDF_AddInstalledFont
77 void (*EnumFonts)(struct _FPDF_SYSFONTINFO* pThis, void* pMapper);
81 * Use the system font mapper to get a font handle from requested parameters
84 * Implementation Required:
85 * Yes only if GetFont method is not implemented.
87 * If the system supports native font mapper (like Windows), implementation can implement this method to get a font handle.
88 * Otherwise, Foxit SDK will do the mapping and then call GetFont method.
89 * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK.
91 * pThis - Pointer to the interface structure itself
92 * weight - Weight of the requested font. 400 is normal and 700 is bold.
93 * bItalic - Italic option of the requested font, TRUE or FALSE.
94 * charset - Character set identifier for the requested font. See above defined constants.
95 * pitch_family - A combination of flags. See above defined constants.
96 * face - Typeface name. Currently use system local encoding only.
97 * bExact - Pointer to an boolean value receiving the indicator whether mapper found the exact match.
98 * If mapper is not sure whether it's exact match, ignore this paramter.
100 * An opaque pointer for font handle, or NULL if system mapping is not supported.
102 void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis, int weight, int bItalic, int charset, int pitch_family,
103 const char* face, int* bExact);
107 * Get a handle to a particular font by its internal ID
110 * Implementation Required:
111 * Yes only if MapFont method is not implemented.
113 * If the system mapping not supported, Foxit SDK will do the font mapping and use this method to get a font handle.
115 * pThis - Pointer to the interface structure itself
116 * face - Typeface name. Currently use system local encoding only.
118 * An opaque pointer for font handle.
120 void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face);
123 * Method: GetFontData
124 * Get font data from a font
127 * Implementation Required:
130 * Can read either full font file, or a particular TrueType/OpenType table
132 * pThis - Pointer to the interface structure itself
133 * hFont - Font handle returned by MapFont or GetFont method
134 * table - TrueType/OpenType table identifier (refer to TrueType specification).
135 * 0 for the whole font file.
136 * buffer - The buffer receiving the font data. Can be NULL if not provided
137 * buf_size - Buffer size, can be zero if not provided
139 * Number of bytes needed, if buffer not provided or not large enough,
140 * or number of bytes written into buffer otherwise.
142 unsigned long (*GetFontData)(struct _FPDF_SYSFONTINFO* pThis, void* hFont,
143 unsigned int table, unsigned char* buffer, unsigned long buf_size);
146 * Method: GetFaceName
147 * Get face name from a font handle
150 * Implementation Required:
153 * pThis - Pointer to the interface structure itself
154 * hFont - Font handle returned by MapFont or GetFont method
155 * buffer - The buffer receiving the face name. Can be NULL if not provided
156 * buf_size - Buffer size, can be zero if not provided
158 * Number of bytes needed, if buffer not provided or not large enough,
159 * or number of bytes written into buffer otherwise.
161 unsigned long (*GetFaceName)(struct _FPDF_SYSFONTINFO* pThis, void* hFont, char* buffer, unsigned long buf_size);
164 * Method: GetFontCharset
165 * Get character set information for a font handle
168 * Implementation Required:
171 * pThis - Pointer to the interface structure itself
172 * hFont - Font handle returned by MapFont or GetFont method
174 * Character set identifier. See defined constants above.
176 int (*GetFontCharset)(struct _FPDF_SYSFONTINFO* pThis, void* hFont);
180 * Delete a font handle
183 * Implementation Required:
186 * pThis - Pointer to the interface structure itself
187 * hFont - Font handle returned by MapFont or GetFont method
191 void (*DeleteFont)(struct _FPDF_SYSFONTINFO* pThis, void* hFont);
195 * Struct: FPDF_CharsetFontMap
196 * Provides the name of a font to use for a given charset value.
198 typedef struct FPDF_CharsetFontMap_
200 int charset; // Character Set Enum value, see FXFONT_*_CHARSET above.
201 const char* fontname; // Name of default font to use with that charset.
202 } FPDF_CharsetFontMap;
205 * Function: FPDF_GetDefaultTTFMap
206 * Returns a pointer to the default character set to TT Font name map. The
207 * map is an array of FPDF_CharsetFontMap structs, with its end indicated
208 * by a { -1, NULL } entry.
212 * Pointer to the Charset Font Map.
214 DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap();
217 * Function: FPDF_AddInstalledFont
218 * Add a system font to the list in Foxit SDK.
220 * This function is only called during the system font list building process.
222 * mapper - Opaque pointer to Foxit font mapper
223 * face - The font face name
224 * charset - Font character set. See above defined constants.
228 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, const char* face, int charset);
231 * Function: FPDF_SetSystemFontInfo
232 * Set the system font info interface into Foxit SDK
234 * Platform support implementation should implement required methods of FFDF_SYSFONTINFO interface,
235 * then call this function during SDK initialization process.
237 * pFontInfo - Pointer to a FPDF_SYSFONTINFO structure
241 DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo);
244 * Function: FPDF_GetDefaultSystemFontInfo
245 * Get default system font info interface for current platform
247 * For some platforms Foxit SDK implement a default version of system font info interface.
248 * The default implementation can be used in FPDF_SetSystemFontInfo function.
252 * Pointer to a FPDF_SYSFONTINFO structure describing the default interface.
253 * Or NULL if the platform doesn't have a default interface.
254 * Application should call FPDF_FreeMemory to free the returned pointer.
256 DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo();
262 #endif // PUBLIC_FPDF_SYSFONTINFO_H_