D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
mpdf
/
examples
/
Filename :
example53_new_mPDF_v5-0_fonts.php
back
Copy
<?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>Fonts in mPDF Version 5.x</h2> <p style="color: red"><b>Note:</b> This example will only display correctly if you have all the fonts installed in mPDF</p> <p>mPDF version 5 supports Truetype fonts, reading and embedding directly from the .ttf font files. Fonts must follow the Truetype specification and use Unicode mapping to the characters. Truetype collections (.ttc files) and Opentype files (.otf) in Truetype format are also supported.</p> <h4>Easy to add new fonts</h4> <ol> <li>Upload the Truetype font file to the fonts directory (/ttfonts)</li> <li>Define the font file details in the configuration file (config_fonts.php)</li> <li>Access the font by specifying it in your HTML code as the CSS font-family</li> </ol> <div>These are some examples of Windows fonts:</div> <div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE;"> <div style="font-family: Arial">Arial - The quick, sly fox jumped over the lazy brown dog.</div> <div style="font-family: \'Comic Sans MS\'">Comic Sans MS - The quick, sly fox jumped over the lazy brown dog.</div> <div style="font-family: \'Trebuchet MS\'">Trebuchet - The quick, sly fox jumped over the lazy brown dog.</div> <div style="font-family: Calibri">Calibri - The quick, sly fox jumped over the lazy brown dog.</div> <div style="font-family: Quillscript">QuillScript - The quick, sly fox jumped over the lazy brown dog.</div> <div style="font-family: \'Lucida Console\'">Lucidaconsole - The quick, sly fox jumped over the lazy brown dog.</div> <div style="font-family: Tahoma">Tahoma - The quick, sly fox jumped over the lazy brown dog.</div> </div> <h4>Full Unicode support</h4> <p>The DejaVu fonts distributed with mPDF contain an extensive set of characters, but it is easy to add fonts to access uncommon characters.</p> <div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE;"> <dl> <dt>Georgian (DejaVuSansCondensed)</dt> <dd style="font-family:\'Dejavu Sans Condensed\';">Ⴀ Ⴁ Ⴂ Ⴃ Ⴄ Ⴅ Ⴆ Ⴇ Ⴈ Ⴉ Ⴊ Ⴋ Ⴌ Ⴍ Ⴎ Ⴏ Ⴐ Ⴑ Ⴒ Ⴓ</dd> <dt>Runic (Junicode)</dt> <dd style="font-family:junicode;">ᚠ ᚡ ᚢ ᚣ ᚤ ᚥ ᚦ ᚧ ᚨ ᚩ ᚪ ᚫ ᚬ ᚭ ᚮ ᚯ ᚰ ᚱ ᚲ ᚳ ᚴ ᚵ ᚶ ᚷ ᚸ ᚹ ᚺ ᚻ ᚼ</dd> <dt>Greek Extended (Quivira)</dt> <dd style="font-family:quivira;">ἀ ἁ ἂ ἃ ἄ ἅ ἆ ἇ Ἀ Ἁ Ἂ Ἃ Ἄ Ἅ Ἆ Ἇ ἐ ἑ ἒ ἓ ἔ ἕ </dd> <dt>IPA Extensions (Quivira)</dt> <dd style="font-family:quivira;">ɐ ɑ ɒ ɓ ɔ ɕ ɖ ɗ ɘ ə ɚ ɛ ɜ ʣ ʤ ʥ ʦ ʧ ʨ ʩ ʪ ʫ </dd> <dt>Letterlike Symbols (Symbola)</dt> <dd style="font-family:symbola;">℀ ℁ ℂ ℃ ℄ ℅ ℆ ℇ ℈ ℉ ℊ ℋ ℌ ℍ ℎ ℏ ℐ ℑ ℒ ℓ ℔ ℕ № ℗ ℘ ℙ ℚ ℛ ℜ </dd> <dt>Mathematical Operators (Symbola)</dt> <dd style="font-family:symbola;">∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ </dd> <dt>Miscellaneous Technical (Symbola)</dt> <dd style="font-family:symbola;">⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇⌎ ⌏ ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ </dd> <dt>Enclosed Alphanumerics (Quivira)</dt> <dd style="font-family:quivira;">① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯</dd> <dt>Miscellaneous Symbols (DejaVuSansCondensed)</dt> <dd style="font-family:\'Dejavu Sans Condensed\';">☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ ☐ ☑ ☒ </dd> <dt>Supplemental Arrows-B (Symbola)</dt> <dd style="font-family:symbola;">⤀ ⤁ ⤂ ⤃ ⤄ ⤅ ⤆ ⤇ ⤈ ⤉ ⤊ ⤋ ⤐ ⤑ ⤔ ⤕ ⤖ ⤗ ⤘ ⥶ ⥷ ⥸ ⥹ ⥺ ⥻ ⥼ ⥽ </dd> </dl> </div> The online manual lists a number of open-source fonts available to cover uncommon characters: <a href="http://mpdf1.com/manual/index.php?tid=451">http://mpdf1.com/manual/index.php?tid=451</a> <pagebreak /> <h2>Complex scripts</h2> <p>Although all characters may be displayed, there are various reasons why a script may not appear as expected.</p> <h4>Right-to-left languages (Hebrew, Arabic etc.)</h4> Arabic languages and Hebrew are written in a right-to-left direction (RTL). mPDF recognises both Arabic and Hebrew languages and reverses text direction automatically. <div style="border:0.2mm solid #000088; padding: 0.5em; background-color: #EEEEEE; font-size: 18pt; font-family:tahoma; text-align: center;"> ألسّلام عليكم שלום </div> Arabic languages (but not Hebrew) also change the form of the letter depending on its position in the text e.g. these are the initial, medial, final, and isolated forms of arabic letter \'ain\': <div style="font-family:xbriyaz; border:0.2mm solid #000088; padding: 0.5em; background-color: #EEEEEE; font-size: 18pt; text-align: center;"> ع ـع ـعـ عـ </div> The isolated characters are contained in the Unicode block \'Arabic\' U+0600 - U+06FF.<br /> The initial, medial and final forms are contained in Unicode Blocks \'Arabic Presentation Forms\' A and B (U+FB50 - U+FDFF, U+FE70 - U+FEFE). Note that quite a large number of fonts contain the isolated characters but not the presentation forms. Fonts used with mPDF must contain the \'Arabic Presentation Forms\' in order to display arabic text correctly. mPDF automatically converts letters to their initial/medial/final forms in several languages: arabic, persian/farsi, urdu, sindhi and pashto. <p>Arabic text is used for many different languages e.g. persian/farsi, urdu, pashto etc. These languages often contain letters unique to that language. \'Arabic\' fonts do not always contain the full set of arabic charcters necessary for all languages. </p> <p>Other RTL languages (using other alphabets) are reversed in order, but not otherwise processed, by mPDF e.g. Syriac, Thaana, N\'Ko, and Samaritan.</p> <h4>Indic languages</h4> Indic languages are also complex scripts which require some processing of characters before display. For example some vowels consist of 2 characters, to be placed before and after the adjacent consonant e.g. <div style="font-family:ind_ml_1_001; border:0.2mm solid #000088; padding: 0.5em; background-color: #EEEEEE; font-size: 18pt; text-align: center;"> <div style="font-family: sans; font-size:normal">U+0D1C + U+0D4C [vowel AU] = [written together as &#x0D1C;&#x0D4C;]</div> ജ + ൌ = ജൌ</div> <p style="margin-bottom: 0">Consonant conjuncts are where two adjacent characters are written as a single \'conjunct\' form e.g.</p> <div style="font-family:ind_hi_1_001; border:0.2mm solid #000088; padding: 0.5em; background-color: #EEEEEE; font-size: 18pt; text-align: center;"> प + ॡ = पॣ</div> <p style="margin-bottom: 0">mPDF can support some of these languages, but requires specially prepared font files that are unique to mPDF.<br /> Supported languages: Bengali, Devanāgarī, Gujarāti, Gurmukhi, Kannada, Malayalam, Oriya, Tamil, Telugu</p> <div style="border:0.2mm solid #000088; padding: 0.5em; background-color: #EEEEEE; font-size: 18pt;"> <span style="font-family:ind_bn_1_001;">আসসালামু আলাইকুম </span> <span style="font-family:ind_gu_1_001;">નમસ્તે </span> <span style="font-family:ind_ml_1_001;">നമസ്കാരം </span> <span style="font-family:ind_hi_1_001;">नमस्ते </span> <span style="font-family:ind_ta_1_001;">வணக்கம்! </span> </div> Complex scripts <b>not</b> supported: Khmer, Sinhala, Tibetan, Myanmar (Burmese), Balinese <h4>Vertical writing</h4> <div>Vertical writing is not supported by mPDF (e.g. Mongolian and Phags-pa) although the individual characters can be displayed using suitable fonts.</div> <pagebreak /> <h4>Combining diacritics</h4> <p>In Unicode, letters with diacritics (e.g. ÁáȦȧÄä) are usually represented as a single character e.g. Unicode U+0196 is an A Umlaut. There are 4 blocks in Unicode of diacritics or \'marks\' which can be used to combine with adjacent letters: Combining Diacritical Marks (U+0300 - U+036F), Combining Diacritical Marks Supplement (U+1DC0 - U+1DFF), Combining Marks for Symbols(U+20D0 - U+20FF) and Combining Half Marks (U+FE20 - U+FE2F). </p> <p>Software applications use special positioning information stored in OpenType font files to resposition the diacritic/mark depending on the context. mPDF does not support this repositioning and is dependent on the font design and original placement of the diacritic: </p> <div style="border:0.2mm solid #000088; padding: 0.5em; background-color: #EEEEEE; font-size: 14pt;"> <div style="font-family:\'Dejavu Sans Condensed\';">Á á Ȧ ȧ Ä ä ï (Precomposed characters: DejaVu Sans Condensed)</div> <div style="font-family:\'Dejavu Sans Condensed\';">Á á Ȧ ȧ Ä ä ï (Using diacritics: DejaVu Sans Condensed)</div> <div style="font-family:\'Arial Unicode MS\';">Á á Ȧ ȧ Ä ä ï (Arial Unicode MS)</div> <div style="font-family:\'Times New Roman\';">Á á Ȧ ȧ Ä ä ï (Times New Roman)</div> <div style="font-family:\'Courier new\';">Á á Ȧ ȧ Ä ä ï (Courier New)</div> </div> <p><b>It is recommended to use precomposed characters whenever possible with mPDF.</b></p> <pagebreak /> <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 version 5 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="http://mpdf1.com/manual/index.php?tid=451">http://mpdf1.com/manual/index.php?tid=451</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 edit the value $this->useAdobeCJK=false in config.php or use new mPDF(\'-aCJK\'), and edit the config_cp.php configuration file.</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>The following text includes characters from both BMP and SIP:</p> <div style="border:0.2mm solid #000088; padding: 1em; background-color: #EEEEEE;"> <div style="font-family:mingliu;"> 鼂 鼦 齄 齐 齢 齩 𣊉 𣊊 </div> <div style="font-family:mingliu_hkscs;"> 鼂 鼦 齄 齐 齢 齩 𣊉 𣊊 </div> <div style="font-family:pmingliu;"> 鼂 鼦 齄 齐 齢 齩 𣊉 𣊊 </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 /> "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 /> <br /> ...<br /> ); </div> <p>This is the 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> '; //============================================================== //============================================================== //============================================================== if ($_REQUEST['html']) { echo $html; exit; } if ($_REQUEST['source']) { $file = __FILE__; header("Content-Type: text/plain"); header("Content-Length: ". filesize($file)); header("Content-Disposition: attachment; filename='".$file."'"); readfile($file); exit; } //============================================================== //============================================================== //============================================================== //============================================================== //============================================================== include("../mpdf.php"); $mpdf=new mPDF(); $mpdf->WriteHTML($html); $mpdf->Output(); exit; //============================================================== //============================================================== //============================================================== ?>