Define an interface for generating glyph bitmaps. This interface does not exist on desktop Windows system. But on alternative systems, including mobile system, this interface must be implemented in order to display non-embedded non-western fonts, like Chinese/Japanese/Korean characters. To make use of a glyph provider, call FPDF_SetGlyphProvider function.
More...
#include <fpdfview.h>
List of all members.
Public Attributes |
| void *(* | MapFont )(FPDF_BYTESTRING name, int codepage) |
| void(* | GetGlyphBBox )(void *font, int unicode, int cid, int *left, int *top, int *right, int *bottom) |
| int(* | GetGlyphBitmap )(void *font, int unicode, int cid, double size, int *left, int *top, int *width, int *height, void **buffer, int *stride) |
Detailed Description
Define an interface for generating glyph bitmaps. This interface does not exist on desktop Windows system. But on alternative systems, including mobile system, this interface must be implemented in order to display non-embedded non-western fonts, like Chinese/Japanese/Korean characters. To make use of a glyph provider, call FPDF_SetGlyphProvider function.
Member Data Documentation
Get bounding box of a glyph. The boundaries are measured in PDF font units, which is 1/1000 of the em size. For example, if a character's top boundary is at half of the em square, then the top value should be 500. It's OK to return a box larger than the actual bounding box of the character. So some implementation may just return a fixed bounding box for all glyphs. But returning a box smaller than the actually bounding box will cause some problem like during scrolling.
- Parameters:
-
| [in] | font | - The font handle returned by MapFont interface. |
| [in] | unicode | - The unicode of the character |
| [in] | cid | - The CID code (see Adobe CID specifications) of the character. 0 if not available. For most characters, implementation can ignore this parameter. However, if precise display of CJK characters is required, some special CID (like half width/full width, rotated, etc) needs special handling. |
| [in] | left | - [OUT] Pointer to returned left boundary |
| [in] | top | - [OUT] Pointer to returned top boundary |
| [in] | right | - [OUT] Pointer to returned right boundary |
| [in] | bottom | - [OUT] Pointer to returned bottom boundary |
This interface is the main interface for getting glyph bitmaps. The input include font handle, unicode and CID code, font size, then the implementation should allocate a sufficient buffer to hold the grayscale bitmap for the character, and return its position (relative to origin of the character), size, buffer, and stride to FPDFSDK. FPDFSDK then will use the returned bitmap and position information to display the glyph.
- Parameters:
-
| [in] | font | - The font handle returned by MapFont interface. |
| [in] | unicode | - The unicode of the character |
| [in] | cid | - The CID code of the character. See comments in GetCharBBox interface. |
| [in] | size | - The font size (size for em square). |
| [in] | left | - [OUT] Pointer to left offset of the bitmap, from the character origin. Negative means the bitmap should move to left of the origin, positive means the bitmap should move to right side of the origin. |
| [in] | top | - [OUT] Pointer to top offset of the bitmap, from the character origin. Negative means the bitmap should move downward from the origin, positive means the bitmap should move to upward from the origin. |
| [in] | width | - [OUT] Pointer to output width (number of pixels per scanline) |
| [in] | height | - [OUT] Pointer to output height (number of scanlines) |
| [in] | buffer | - [OUT] Pointer to another pointer which points to a buffer containing the glyph bitmap. This buffer must be allocated by FPDF_AllocMemory function. This buffer must contain scanlines of the bitmap from top to bottom. Each byte in the buffer represent a pixel of the glyph, 0 means not inside the glyph, 255 means fully inside the glyph. Implementation can also use gray scale (between 0-255) to identify pixels on the border of the glyph. Implementation doesn't need to free the buffer, FPDFSDK will do that. |
| [in] | stride | - [OUT] Pointer to output stride (number of bytes per scanline in the buffer). |
- Return values:
-
| Implementation | should return non-zero if success, 0 if error happens (like character not found). |
Map a font with particular name. The implementation can return any pointer to some internal font structure. Or it can return NULL if font mapping not supported (like if there is only one font available in the system). The result of this interface function will be passed back to other interface functions as "font handle".
- Parameters:
-
| [in] | name | - The single byte encoded name of the font. It might be a MBCS encoded name. |
| [in] | codepage | - The Windows code page identifier for the font, indicating the primary character set of the font. Currently it can be one of the followings: 0 - unknown character set, 932 - Japanese character set, 936 - Simplified Chinese character set, 949 - Korean character set, 950 - Traditional character set, 1200- Unicode character set, |
The documentation for this struct was generated from the following file: