Fonts and Encodings
The type of fonts
There are three kind of fonts that is available
in Haru.
The application invokes HPDF_GetFont() to get font-hangle. Except base14-fonts, an application have
to invoke the following functions to load font before invoking HPDF_GetFont() .
The font loading functions
Type of Font |
Description |
|
1 |
Base14 Font |
It is buildin font of PDF. This
font can be used for all viewer applications. |
2 |
Type1 Font |
One of font formats used by
PostScript. |
3 | TrueType Font |
Outline font fotmat widely used.
|
4 |
CID Font |
Font format for multi byte character developed by Adobe. |
The application invokes HPDF_GetFont() to get font-hangle. Except base14-fonts, an application have
to invoke the following functions to load font before invoking HPDF_GetFont() .
The font loading functions
- HPDF_LoadType1FontFromFile()
- HPDF_LoadTTFontFromFile()
- HPDF_LoadTTFontFromFile2()
- HPDF_UseCNSFonts()
- HPDF_UseCNTFonts()
- HPDF_UseJPFonts()
- HPDF_UseKRFonts()
Base14 Font
Base14 fonts are built-in font of PDF, and all
the Viewer applications can display these fonts. An application can get
a font-handle of a base14 font any time by invoking HPDF_GetFont() .
The size of pdf files which use base14 fonts become smaller than those which use other type of fonts. Moreover, a processing that creates the PDF file is fast because of that there is no overhead that loads the font.
However, base14 fonts are only available to display latin1 character set. To use other character set, an application have to use other type of font.
The Base14 Fonts
The size of pdf files which use base14 fonts become smaller than those which use other type of fonts. Moreover, a processing that creates the PDF file is fast because of that there is no overhead that loads the font.
However, base14 fonts are only available to display latin1 character set. To use other character set, an application have to use other type of font.
The Base14 Fonts
- Courie
- Courier-Bold
- Courier-Oblique
- Courier-BoldOblique
- Helvetica
- Helvetica-Bold
- Helvetica-Oblique
- Helvetica-BoldOblique
- Times-Roman
- Times-Bold
- Times-Italic
- Times-BoldItalic
- Symbol
- ZapfDingbats
Type1 Font
Type1 font is a fotmat of outline fonts
developed by Adobe. An AFM file is necessary to use an external type1
font on Haru.
When an application uses an external type1 font, an application has to invoke HPDF_LoadType1FontFromFile() before invoking HPDF_GetFont() .
The return value of HPDF_LoadType1FontFromFile() is used as font-name parameter of HPDF_GetFont() .
If a PFA/PFB file is specified at invoking HPDF_LoadType1FontFromFile(), the glyf data of the font is embedded to the PDF file. Otherwise, only metrics data in AFM file is embedded.
font_name = HPDF_LoadType1FontFromFile (pdf, "a010013l.afm", "a010013l.pfb");
hfont = HPDF_GetFont (pdf, font_name, "CP1250");
HPDF_Page_SetFontAndSize (page, hfont, 10.5);
When an application uses an external type1 font, an application has to invoke HPDF_LoadType1FontFromFile() before invoking HPDF_GetFont() .
The return value of HPDF_LoadType1FontFromFile() is used as font-name parameter of HPDF_GetFont() .
If a PFA/PFB file is specified at invoking HPDF_LoadType1FontFromFile(), the glyf data of the font is embedded to the PDF file. Otherwise, only metrics data in AFM file is embedded.
font_name = HPDF_LoadType1FontFromFile (pdf, "a010013l.afm", "a010013l.pfb");
hfont = HPDF_GetFont (pdf, font_name, "CP1250");
HPDF_Page_SetFontAndSize (page, hfont, 10.5);
TrueType Font
Haru can use TrueType font. There are two types
of format of truetype font.
The first format whose extension is ".ttf" includes only one font-data in the file. The function HPDF_LoadTTFontFromFile() is available to load this type of font.
The second format whose extension is ".ttc" includes multiple font-data in the file. The function HPDF_LoadTTFontFromFile2() is available to load this type of font. HPDF_LoadTTFontFromFile2() has a parameter which is used to specify the index of the font to load.
If the parameter "embedding" is set to HPDF_TRUE when invoking HPDF_LoadTTFontFromFile() or HPDF_LoadTTFontFromFile2(), the subset of a font is embeded into a PDF file. If not, only the marix data is stored into a PDF file. In this case a viewer application may use an alternative font if it cannot find font.
font_name = HPDF_LoadTTFontFromFile (pdf, ”/usr/local/fonts/arial.ttf”, HPDF_TRUE);
hfont = HPDF_GetFont (pdf, font_name, "CP1250");
HPDF_Page_SetFontAndSize (page, hfont, 10.5);
The first format whose extension is ".ttf" includes only one font-data in the file. The function HPDF_LoadTTFontFromFile() is available to load this type of font.
The second format whose extension is ".ttc" includes multiple font-data in the file. The function HPDF_LoadTTFontFromFile2() is available to load this type of font. HPDF_LoadTTFontFromFile2() has a parameter which is used to specify the index of the font to load.
If the parameter "embedding" is set to HPDF_TRUE when invoking HPDF_LoadTTFontFromFile() or HPDF_LoadTTFontFromFile2(), the subset of a font is embeded into a PDF file. If not, only the marix data is stored into a PDF file. In this case a viewer application may use an alternative font if it cannot find font.
font_name = HPDF_LoadTTFontFromFile (pdf, ”/usr/local/fonts/arial.ttf”, HPDF_TRUE);
hfont = HPDF_GetFont (pdf, font_name, "CP1250");
HPDF_Page_SetFontAndSize (page, hfont, 10.5);
NOTE:
Haru can use only TrueType fonts which has cmap of unicode and following tables.
"OS/2", "cmap", "cvt ", "fpgm", "glyf", "head", "hhea", "hmtx", "loca", "maxp", "name", "post", "prep"
Haru can use only TrueType fonts which has cmap of unicode and following tables.
"OS/2", "cmap", "cvt ", "fpgm", "glyf", "head", "hhea", "hmtx", "loca", "maxp", "name", "post", "prep"
CID Font
The CIDFont is a font for multi byte character
developed by Adobe.
Two simplified Chinese fonts, one traditional Chinese fonts, four Japanese fonts, and four Korean fonts are available on Haru.
An application have to invoke the following functions once before using CID fonts.
HPDF_UseJPFonts (pdf);
HPDF_UseJPEncodings (pdf);
hfont = HPDF_GetFont (pdf, "MS-Mincyo", "90ms-RKSJ-H");
HPDF_Page_SetFontAndSize (page, hfont, 10.5);
Two simplified Chinese fonts, one traditional Chinese fonts, four Japanese fonts, and four Korean fonts are available on Haru.
An application have to invoke the following functions once before using CID fonts.
Function Name | Description |
|
1 |
HPDF_UseCNSFonts() |
It makes simplified Chinese
fonts(SimSun,SimHei) to available. |
2 |
HPDF_UseCNTFonts() |
It makes traditional Chinese fonts(MingLiU) to available. |
3 |
HPDF_UseJPFonts() |
It makes Japanese fonts(MS-Mincyo,MS-Gothic,MS-PMincyo,MS-PGothic) to available. |
4 |
HPDF_UseKRFonts() |
It makes Korean fonts (Batang,Dotum,BatangChe,DotumChe) to available. |
HPDF_UseJPFonts (pdf);
HPDF_UseJPEncodings (pdf);
hfont = HPDF_GetFont (pdf, "MS-Mincyo", "90ms-RKSJ-H");
HPDF_Page_SetFontAndSize (page, hfont, 10.5);
The encodings for single-byte character set
In HPDF, the following character sets for
single-byte character set are
available.
An application can get an encoding handle by using HPDF_GetEncoder();
An application can get an encoding handle by using HPDF_GetEncoder();
Type
of Font |
Description |
|
1 |
StandardEncoding |
It is the default encoding of PDF |
2 |
MacRomanEncoding |
The standard encoding of Mac OS |
3 | WinAnsiEncoding |
The standerd encoding of Windwos. |
4 |
FontSpecific |
Use the built-in encoding of a
font. |
5 |
ISO8859-2 |
Latin Alphabet No.2 |
6 |
ISO8859-3 | Latin Alphabet No.3 |
7 |
ISO8859-4 | Latin Alphabet No.4 |
8 |
ISO8859-5 | Latin Cyrillic Alphabet |
9 |
ISO8859-6 | Latin Arabic Alphabet |
10 |
ISO8859-7 | Latin Greek Alphabet |
11 |
ISO8859-8 | Latin Hebrew Alphabet |
12 |
ISO8859-9 | Latin Alphabet No. 5 |
13 |
ISO8859-10 | Latin Alphabet No. 6 |
14 |
ISO8859-11 | Thai, TIS 620-2569 character set |
15 |
ISO8859-13 | Latin Alphabet No. 7 |
16 |
ISO8859-14 | Latin Alphabet No. 8 |
17 |
ISO8859-15 | Latin Alphabet No. 9 |
18 |
ISO8859-16 | Latin Alphabet No. 10 |
19 |
CP1250 |
Microsoft Windows Codepage 1250
(EE) |
20 |
CP1251 | Microsoft Windows Codepage 1251
(Cyrl) |
21 |
CP1252 | Microsoft Windows Codepage 1252
(ANSI) |
22 |
CP1253 | Microsoft Windows Codepage 1253
(Greek) |
23 |
CP1254 | Microsoft Windows Codepage 1254
(Turk) |
24 |
CP1255 | Microsoft Windows Codepage 1255
(Hebr) |
25 |
CP1256 | Microsoft Windows Codepage 1256
(Arab |
26 |
CP1257 | Microsoft Windows Codepage 1257
(BaltRim) |
27 |
CP1258 | Microsoft Windows Codepage 1258
(Viet) |
28 |
KOI8-R |
Russian Net Character Set |
The encodings for multi-byte character set
In HPDF, the following character sets for multi-byte character set are
available.
An application have to invoke the following functions once before using encodings for multi-byte character set.
Type
of Encodingss |
Description |
|
1 |
GB-EUC-H |
EUC-CN encoding |
2 |
GB-EUC-V |
Vertical writing virsion of
GB-EUC-H |
3 |
GBK-EUC-H |
Microsoft Code Page 936
(lfCharSet 0x86) GBK encoding |
4 |
GBK-EUC-V |
Vertical writing virsion of
GBK-EUC-H |
5 |
ETen-B5-H |
Microsoft Code Page 950
(lfCharSet 0x88) Big Five character set with ETen extensions |
6 |
ETen-B5-V |
Vertical writing virsion of
ETen-B5-H |
7 |
90ms-RKSJ-H |
Microsoft Code Page 932, JIS X
0208 character |
8 |
90ms-RKSJ-V |
Vertical writing virsion of 90ms-RKSJ-V |
9 |
90msp-RKSJ-H |
Microsoft Code Page 932, JIS X
0208 character (proportional) |
10 |
EUC-H |
JIS X 0208 character set, EUC-JP
encoding |
11 |
EUC-V |
Vertical writing virsion of EUC-H |
12 |
KSC-EUC-H |
KS X 1001:1992 character set,
EUC-KR encoding |
13 |
KSC-EUC-V |
Vertical writing virsion of KSC-EUC-V |
14 |
KSCms-UHC-H |
Microsoft Code Page 949
(lfCharSet 0x81), KS X 1001:1992 character set plus 8822 additional
hangul, Unified Hangul Code (UHC) encoding (proportional) |
15 |
KSCms-UHC-HW-H |
Microsoft Code Page 949
(lfCharSet 0x81), KS X 1001:1992 character set plus 8822 additional
hangul, Unified Hangul Code (UHC) encoding (fixed width) |
16 |
KSCms-UHC-HW-V |
Vertical writing virsion of KSCms-UHC-HW-H |
An application have to invoke the following functions once before using encodings for multi-byte character set.
Function Name | Description |
|
1 |
HPDF_UseCNSEncodings() |
It makes simplified Chinese
Encodings(GB-EUC-H, GB-EUC-V, GBK-EUC-H, GBK-EUC-V) to available. |
2 |
HPDF_UseCNTEncodings() |
It makes traditional Chinese Encodings(ETen-B5-H, ETen-B5-V) to available. |
3 |
HPDF_UseJPEncodings() |
It makes Japanese Encodings(90ms-RKSJ-H, 90ms-RKSJ-V, 90msp-RKSJ-H, EUC-H, EUC-V) to available. |
4 |
HPDF_UseKREncodings() |
It makes Korean Encodings (KSC-EUC-H, KSC-EUC-V, KSCms-UHC-H, KSCms-UHC-HW-H, KSCms-UHC-HW-V) to available. |