-
Notifications
You must be signed in to change notification settings - Fork 148
/
example33_unicode_supplementary_planes.php
279 lines (229 loc) · 16.7 KB
/
example33_unicode_supplementary_planes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<?php
ini_set("memory_limit","128M");
$html = '
<style>
body {
font-family: sans-serif;
font-size: 10pt;
}
h4 {
font-variant: small-caps;
}
h5 {
margin-bottom: 0;
color: #110044;
}
dl {
margin: 0;
}
</style>
<h1></a>mPDF</h1>
<h2>Unicode Supplementary Planes</h2>
<p>The original Unicode allocated characters between x0000 and xFFFF (65,536 characters). This \'Basic Multilingual Plane\' supported most characters in common use, including a large number of Unified Chinese-Japanese-Korean characters (CJK). Later the Unicode standard was extended to 16 Planes. </p>
<p>The first plane (plane 0), the Basic Multilingual Plane (BMP), is where most characters have been assigned so far.</p>
<p>Plane 1, the Supplementary Multilingual Plane (SMP), is mostly used for historic scripts such as Linear B, but is also used for musical and mathematical symbols.</p>
<p>Plane 2, the Supplementary Ideographic Plane (SIP), is used for about 40,000 Unified Han (CJK) Ideographs.</p>
<p>mPDF supports fonts containing characters from all Unicode Planes. By choosing the correct font, almost every single character from Unicode 5 can be displayed in a PDF file.</p>
<h4>Unicode Supplementary Multilingual Plane (SMP or Plane 1) U+10000 - U+1FFFF</h4>
<h5>Gothic text</h5>
<div>
This paragraph shows Gothic text. These characters lie in the Unicode Supplementary Multilingual Plane U+10330 - U+1034F.
</div>
<div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE;">
<div style="font-family:damase">
𐌰 𐌱 𐌲 𐌳 𐌴 𐌵 𐌶 𐌷 𐌸 𐌹 𐌺 𐌻 𐌼 𐌽 𐌾 𐌿 𐍀 𐍁 𐍂 𐍃 𐍄 𐍅 𐍆 𐍇 𐍈 𐍉 𐍊
</div>
</div>
<div>
Font: MPH2BDamase (damase_v.2.ttf) available from: http://www.wazu.jp/gallery/views/View_MPH2BDamase.html
</div>
<h5>Egyptian Hieroglyphics</h5>
<div>
This paragraph shows Egyptian Hieroglyphics. These characters lie in the Unicode Supplementary Multilingual Plane U+13000 - U+1342F.
</div>
<div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE;">
<div style="font-family:aegyptus; font-size: 24pt">
𓀀 𓀁 𓀂 𓀃 𓀄 𓀅 𓀆 𓀇 𓀈 𓀉 𓀊 𓀋 𓀌 𓀍 𓀎 𓀏 𓀐 𓀑
</div>
</div>
<div>
Font: Aegyptus.otf available from: http://users.teilar.gr/~g1951d/
</div>
<p>SMP contains mainly ancient scripts - see <a href="https://mpdf.github.io/reference/codepages-glyphs/unicode-coverage-of-free-fonts.html">manual page</a> for full list.</p>
<p>mPDF uses a different method to embed fonts in the PDF file if they include characters from SMP or SIP, because the characters cannot be represented by a 4 character hex code 0000-FFFF. This method is less eficient than the default method, and it can be suppressed by adding the font name to the array \'BMPonly\' in the config_fonts.php configuration file. </p>
<p>Note that the DejaVu fonts distributed with mPDF and (GNU)FreeSans and FreeSerif fonts do contain a few characters in the SMP plane, but most users will not require them and by default they have been added to the array \'BMPonly\'.</p>
<pagebreak />
<h4>CJK characters</h4>
<p>Below are examples of all the CJK Unicode blocks contained in the Basic Multilingual Plane and Supplemental Ideographic Plane</p>
<div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE;">
<h5>Plane 0 (BMP)</h5>
<dl style="font-family:sun-exta;">
<dt>CJK Radicals Supplement</dt>
<dd>⺎ ⺏ ⺐ ⺑ ⺒ ⺓ ⺔ ⺕ ⺖ ⺗ ⺘ ⺙ ⺛ ⺜ ⺝ ⺞ ⺟ ⺠ ⺡ ⺢ ⺣ ⺤ ⺥ ⺦ ⺧ ⺨ ⺩ ⺪ </dd>
<dt>Kangxi Radicals</dt>
<dd>⼳ ⼴ ⼵ ⼶ ⼷ ⼸ ⼹ ⼺ ⼻ ⼼ ⼽ ⼾ ⼿ ⽀ ⽁ ⽂ ⽃ ⽄ ⽅ ⽆ ⽇ ⽈ ⽉ ⽊ ⽋ ⽌ ⽍ </dd>
<dt>Ideographic Description Characters</dt>
<dd>⿰ ⿱ ⿲ ⿳ ⿴ ⿵ ⿶ ⿷ ⿸ ⿹ ⿺ ⿻ </dd>
<dt>CJK Symbols and Punctuation</dt>
<dd> 〈 〉 《 》 「 」 『 』 【 】 〒 〓 〔 〕 〖 〗 〘 〙 〚 〛 〜 〝 〞 〦 〧 〨 〩 〪 </dd>
<dt>Hiragana</dt>
<dd>ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く ぐ け げ こ ご さ ざ </dd>
<dt>Katakana</dt>
<dd>゠ ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク グ ケ ゲ コ ゴ </dd>
<dt>Bopomofo</dt>
<dd>ㄅ ㄆ ㄇ ㄈ ㄉ ㄊ ㄋ ㄌ ㄍ ㄎ ㄏ ㄐ ㄑ ㄒ ㄓ ㄔ ㄕ ㄖ </dd>
<dt>Hangul Compatibility Jamo</dt>
<dd>ㄱ ㄲ ㄳ ㄴ ㄵ ㄶ ㄷ ㄸ ㄹ ㄺ ㄻ ㄼ ㄽ ㄾ ㄿ ㅀ ㅁ ㅂ </dd>
<dt>Kanbun</dt>
<dd>㆐ ㆑ ㆒ ㆓ ㆔ ㆕ ㆖ ㆗ ㆘ ㆙ ㆚ ㆛ ㆜ ㆝ ㆞ ㆟ </dd>
<dt>Bopomofo Extended</dt>
<dd>ㆠ ㆡ ㆢ ㆣ ㆤ ㆥ ㆦ ㆧ ㆨ ㆩ ㆪ ㆫ ㆬ ㆭ ㆮ ㆯ ㆰ ㆱ ㆲ ㆳ ㆴ ㆵ ㆶ ㆷ </dd>
<dt>Katakana Phonetic Extensions</dt>
<dd>ㇰ ㇱ ㇲ ㇳ ㇴ ㇵ ㇶ ㇷ ㇸ ㇹ ㇺ ㇻ ㇼ ㇽ ㇾ ㇿ </dd>
<dt>Enclosed CJK Letters and Months</dt>
<dd>㈄ ㈅ ㈆ ㈇ ㈈ ㈉ ㈊ ㈋ ㈌ ㈍ ㈎ ㈏ ㈐ ㈑ ㈒ ㈓ ㈔ ㈕ ㈖ ㈗ ㈘ ㈙ ㈚ ㈛ ㈜ </dd>
<dt>CJK Compatibility</dt>
<dd>㌀ ㌁ ㌂ ㌃ ㌄ ㌅ ㌆ ㌇ ㌈ ㌉ ㌊ ㌋ ㌌ ㌍ ㌎ ㌏ ㌐ ㌑ ㌒ ㌓ ㌔ ㌕ ㌖ ㌗ ㌘ </dd>
<dt>CJK Unified Ideographs Extension A</dt>
<dd>㐀 㐁 㐂 㐃 㐄 㐅 㐆 㐇 㐈 㐉 㐊 㐋 㐌 㐍 㐎 㐏 㐐 㐑 㐒 㐓 㐔 㐕 㐖 㐗 㐘 </dd>
<dt>CJK Unified Ideographs</dt>
<dd>一 丁 丂 七 丄 丅 丆 万 丈 三 上 下 丌 不 与 丏 丐 丑 丒 专 且 丕 世 丗 丘 </dd>
<dt>Yi Syllables</dt>
<dd>ꀀ ꀁ ꀂ ꀃ ꀄ ꀅ ꀆ ꀇ ꀈ ꀉ ꀊ ꀋ ꀌ ꀍ ꀎ ꀏ ꀐ ꀑ ꀒ ꀓ ꀔ ꀕ ꀖ ꀗ ꀘ ꀙ ꀚ </dd>
<dt>Yi Radicals</dt>
<dd>꒐ ꒑ ꒒ ꒓ ꒔ ꒕ ꒖ ꒗ ꒘ ꒙ ꒚ ꒛ ꒜ ꒝ ꒞ ꒟ ꒠ ꒡ ꒢ ꒣ ꒤ ꒥ ꒦ ꒧ ꒨ ꒩ </dd>
<dt>Hangul Syllables</dt>
<dd>가 각 갂 갃 간 갅 갆 갇 갈 갉 갊 갋 갌 갍 갎 갏 감 갑 값 갓 갔 강 갖 갗 갘 </dd>
<dt>CJK Compatibility Ideographs</dt>
<dd>豈 更 車 賈 滑 串 句 龜 契 金 喇 奈 懶 癩 羅 蘿 螺 裸 邏 樂 洛 烙 珞 落 酪 </dd>
</dl>
<h5>Plane 2 (SIP)</h5>
<dl style="font-family:sun-exta;">
<dt>CJK Unified Ideographs Extension B</dt>
<dd>𠀀 𠀁 𠀂 𠀃 𠀄 𠀅 𠀆 𠀇 𠀈 𠀉 𠀊 𠀋 𠀌 𠀍 𠀎 𠀏 𠀐 𠀑 𠀒 𠀓 </dd>
<dt>CJK Unified Ideographs Extension C</dt>
<dd>𪜀 𪜁 𪜂 𪜃 𪜄 𪜅 𪜆 𪜇 𪜈 𪜉 𪜊 𪜋 𪜌 𪜍 𪜎 𪜏 𪜐 𪜑 𪜒 𪜓 </dd>
<dt>CJK Compatibility Ideographs Supplement</dt>
<dd>丽 丸 乁 𠄢 你 侮 侻 倂 偺 備 僧 像 㒞 𠘺 免 兔 兤 具 𠔜 㒹 </dd>
</dl>
</div>
<pagebreak />
<h4>Using CJK fonts in mPDF</h4>
<p>Fonts containing CJK characters are large files, typically 10-30MB. Adobe provides a free download of an \'Asian font pack\' allowing you to create PDF files without including (embedding) the font information in the file. This keeps the file size to a minimum and minimises resource usage on your website generating the PDF file. However, users will have to download the Adobe font packs to read the file, and other PDF software will not display the text correctly.</p>
<p>mPDF allows you to embed subsets of CJK fonts keeping file size down, although there is increased memory usage to generate these files.</p>
<p>Some CJK fonts are broken up into 2 files because of the size of the files. One freely available font with almost complete coverage of all CJK characters (in both BMP and SIP) is \'Sun\' available from Alan Wood\'s excellent website: <a href="http://www.alanwood.net/unicode/fonts-east-asian.html">http://www.alanwood.net/unicode/fonts-east-asian.html</a>. This comes as 2 files, Sun-ExtA and Sun-ExtB (both about 20MB in size) containing the characters from BMP and SIP respectively.
</p>
<p>mPDF allows you to treat these as one font by defining the second file as an SIP-extension of the first in the config_fonts.php configuration file. The following text includes random characters from the BMP and SIP mixed together:</p>
<div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE;">
<div style="font-family:sun-extA;">
鼂 鼈 鼗 𣈏 𣈥 鼦 鼧 𣈯 𣈱 鼹 齄 𣈲 𣈳 齅 齐 𣈴 𣉖 齓 齚 𣉢 𣊁 齢 齩 𣊉 𣊊
</div>
</div>
<p>This is the entry in the config_fonts.php configuration file:</p>
<div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE; font-family: \'Courier new\'; font-size: 8.5pt;">
$this->fontdata = array(<br />
...<br />
"sun-exta" => array(<br />
\'R\' => "Sun-ExtA.ttf",<br />
\'sip-ext\' => \'sun-extb\',<br />
),<br />
"sun-extb" => array(<br />
\'R\' => "Sun-ExtB.ttf",<br />
),<br />
<br />
...<br />
);
</div>
<p>This is the HTML code - note only the sun-exta font-family needs to be referenced:</p>
<div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE; font-family: \'Courier new\'; font-size: 8.5pt;">
<div style="font-family:sun-extA;">
&#40706; &#40712; &#40727; &#x2320f; &#x23225; &#40742; &#40743; &#x2322f; &#x23231; &#40761; &#40772; &#x23232; &#x23233; &#40773; &#40784; &#x23234; &#x23256; &#40787; &#40794; &#x23262; &#x23281; &#40802; &#40809; &#x23289; &#x2328a;
</div>
</div>
<p>NB You may also need to set useAdobeCJK to false in $config constructor parameter or use <code>new \Mpdf\Mpdf([\'mode\' => \'-aCJK\']);</code>.</p>
<pagebreak />
<h4>TrueType Collections</h4>
<p>TrueType Collections (.ttc files) contain more than one font. mPDF treats each font separately by defining the TTCfontID array in the config_fonts.php configuration file. </p>
<p>This example uses the Windows MingLiU fonts, which consist of 2 files containing 6 fonts (note that mingliub is not a Bold variant): </p>
<p>Font collection file (mingliu.ttc) contains the following fonts:<br />
[1] MingLiU (mingliu) Regular<br />
[2] PMingLiU (pmingliu) Regular (Proportional)<br />
[3] MingLiU_HKSCS (mingliu_hkscs) Regular<br />
</p>
<p>Font collection file (mingliub.ttc) contains the following fonts:<br />
[1] MingLiU-ExtB (mingliu-extb) Regular<br />
[2] PMingLiU-ExtB (pmingliu-extb) Regular (Proportional)<br />
[3] MingLiU_HKSCS-ExtB (mingliu_hkscs-extb) Regular<br />
</p>
<p>This is a sample entry in the config_fonts.php configuration file:</p>
<div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE; font-family: \'Courier new\'; font-size: 8.5pt;">
$this->fontdata = array(<br />
"mingliu" => array(<br />
\'R\' => "mingliu.ttc",<br />
\'TTCfontID\' => array (<br />
\'R\' => 1,<br />
),<br />
\'sip-ext\' => \'mingliu-extb\',<br />
),<br />
"pmingliu" => array(<br />
\'R\' => "mingliu.ttc",<br />
\'TTCfontID\' => array (<br />
\'R\' => 2,<br />
),<br />
\'sip-ext\' => \'pmingliu-extb\',<br />
),<br />
"mingliu_hkscs" => array(<br />
\'R\' => "mingliu.ttc",<br />
\'TTCfontID\' => array (<br />
\'R\' => 3,<br />
),<br />
\'sip-ext\' => \'mingliu_hkscs-extb\',<br />
),<br />
"mingliu-extb" => array(<br />
\'R\' => "mingliub.ttc",<br />
\'TTCfontID\' => array (<br />
\'R\' => 1,<br />
),<br />
),<br />
"pmingliu-extb" => array(<br />
\'R\' => "mingliub.ttc",<br />
\'TTCfontID\' => array (<br />
\'R\' => 2,<br />
),<br />
),<br />
"mingliu_hkscs-extb" => array(<br />
\'R\' => "mingliub.ttc",<br />
\'TTCfontID\' => array (<br />
\'R\' => 3,<br />
),<br />
),<br />
);
</div>
<p>This is sample HTML code:</p>
<div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE; font-family: \'Courier new\'; font-size: 8.5pt;">
<div style="font-family:mingliu;">
&#40706; &#40742; &#40772; &#40784; &#40802; &#40809; &#x23289; &#x2328a;
</div>
<br />
<div style="font-family:mingliu_hkscs;">
&#40706; &#40742; &#40772; &#40784; &#40802; &#40809; &#x23289; &#x2328a;
</div>
<br />
<div style="font-family:pmingliu;">
&#40706; &#40742; &#40772; &#40784; &#40802; &#40809; &#x23289; &#x2328a;
</div>
</div>
';
//==============================================================
//==============================================================
//==============================================================
//==============================================================
//==============================================================
require_once __DIR__ . '/bootstrap.php';
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
//==============================================================
//==============================================================
//==============================================================