MPDF 6.0 Demo
MPDF 6.0 Demo
Advanced Typography
Many TrueType fonts contain OpenType Layout (OTL) tables. These Advanced Typographic tables
contain additional information that extend the capabilities of the fonts to support high-quality
international typography:
OTL fonts support ligatures, positional forms, alternates, and other substitutions.
OTL fonts include information to support features for two-dimensional positioning and glyph
attachment.
OTL fonts contain explicit script and language information, so a text-processing application can
adjust its behavior accordingly.
mPDF 6 introduces the power and flexibility of the OpenType Layout font model into PDF. mPDF 6
supports GSUB, GPOS and GDEF tables for now. mPDF 6 does not support BASE and JSTF at present.
Other mPDF 6 features to enhance complex scripts:
Note: There are other smart-font technologies around to deal with complex scripts, namely Graphite
fonts (SIL International) and Apple Advanced Typography (AAT by Apple/Mac). mPDF 6 does not
support these.
Support for OTL fonts allows the faithful display of almost all complex scripts:
Tibetan (བ་ས་བ་གས།)
র + ◌্ + খ + ◌্ + ম + ◌্ + ক + ◌্ + ষ + ◌্ + র + ি◌ + ◌ু = িু
cf. http://www.microsoft.com/typography/OpenTypeDev/bengali/intro.htm
Ligatures
GSUB features: locl ccmp pref blwf abvf pstf pres abvs blws psts haln rlig calt liga clig mset (all
scripts)
GSUB features: isol fina fin2 fin3 medi med2 init nukt akhn rphf rkrf half vatu cjct cfar (for
appropriate scripts e.g. Indic, Arabic)
GPOS features: abvm blwm mark mkmk curs cpsp dist requ [kern]
NB 'requ' is not listed in the Microsoft registry of Feature tags; however it is found in the Arial Unicode
MS font (it repositions the baseline for punctuation in Kannada script).
Kern is used in some fonts to reposition marks etc. and is essential for correct display, so in mPDF
kern is on by default when any non-Latin script is used.
٣٤ ﻣﻦ٢ اﻟﺼﻔﺤﺔ ٣٤ of ٢ Page
Mark repositioning (and diacritics)
Á á ï A á ı̈
Complex syllables
Note that the text displayed is dependent on the font's design/capabilities. These are both "correct"
representations of the same string, using:
ۚ ْﺗَﺴْـَٔﻤُﻮٓا۟ أَوْ ﻛَﺒِﻴﺮًا إِﻟَﻰٰٓ ٱﻟﻠَّﻪِ وَأَدْﻧَﻰٰٓ أَﻟَّﺎ إِﻟَّﺂ ﺑَﻴْﻨَﻜُﻢْ ﻋَﻠَﻴْﻜُﻢْ أَﻟَّﺎ ﻳَﻌْﺘُﻢ
With GSUB and GPOS:
َ َ َ ْ َ ُ َ ََ َ َُٓ َ َ َ َ
ۢ ٍ أﺟ
ﻞ ﺘﻢ ﺑِﺪﻳﻦ ِإﻳﻦ َءاﻣﻨﻮا۟ ِإذا ﺗﺪاﻳٱ ِ ﺎ ﻬ ﻳ
ـ
ٍ
ُۚ ﻤۭﻰ ﻓَ ْٱﻛﺘُﺒُﻮه ﻣ َﺴ
َ َ َ َْ ُ َ َ َ ُ َ َ َ
ۢ ٍ أﺟ
ـﻞ ﺘﻢ ﺑِـﺪﻳﻦ ِإَـﻮا۟ ِإذا ﺗـﺪاﻳ
ٓ ﻳـﻦ َءاﻣﻨ َ ٱ ِ ﺎ ﻬ َﻳ
ــ
ٍ
ُۚ ﻤۭﻰ ﻓَ ْٱﻛﺘُﺒُﻮه ﻣ َﺴ
There are a number of factors which determine how the input text is displayed in an application.
The font's capabilities/design (this example shows the same text input shown in 2 fonts):
font-variant-position
font-variant-caps
font-variant-ligatures
font-variant-numeric
font-variant-alternates - Only [normal | historical-forms] supported (i.e. most are NOT supported)
e.g. stylistic, styleset, character-variant, swash, ornaments, annotation (use font-feature-settings
for these)
font-variant - as above, and except for: east-asian-variant-values, east-asian-width-values, ruby
font-language-override
font-feature-settings
/* convert both upper and lowercase to small caps (affects punctuation also) */
.allsmallcaps { font-feature-settings: "c2sc", "smcp"; }
Note the automatic line breaking used in Lao, Thai, Khmer and Tibetan text.
SYRIAC - Estrangelo Edessa
ܕܐܬܐ ̱ܗܘܐܝ ܐܘ ܐ ܐ ܗܕܐ ܕܘܬܘܒ ܐܬ
(ܐܐ ܬܘܕ ܬ )ܐ ܕ ܐ ܆ܪ
ܐ ܕ ܕܪܐ ܕ ܐ ܝ ܐܘܐ ܕ ܕ ܕ
ܝ ܪ ܐܢ ܐܘܐ ܕ ܙ ܕ ܘܬܘܒ ܐܬ. ܕ ܬ
. ܡ473 ܐ ܐܣ ܕܢ( ܕ)
MYANMAR (Burmese) Padauk Book (SIL Font)
ြမန်မာအေခ တရားဝင် အားြဖင့ ် ြပည်ေထာင် စ သမ တ ြမန်မာိ င် ငံေတာ်သည် အေှ ေ
့ တာင် အာှတွ င် ဧရိ ယာအား
ြဖင့ ် ဒ တိ ယ အကျယ်ဝန်းဆ ံ း[၁] တိ င် းြပည် ြဖစ်သည်။ ၁၉၄၈ ခ ှ စ် ဇန်နဝါရီ ၄ ရက်တွ င် ဂရိ တ်ဗိ တိန်ိင် ငံထံ မှ
(အဂ လိ ပ်လိ "Myanmar" အြဖစ်ှ င့ ် ) ြပည်ေထာင် စြမန်မာိ င် ငံေတာ်အြဖစ် လွ တ်လပ်ေရးကိ ရှိခဲ့သည်။ ေနာက်
ပိ င် းတွ င် ြပည်ေထာင် စ ဆိ ှယ်လစ် သမ တြမန်မာိ င် ငံေတာ်အြဖစ် ၁၉၇၄ ခ ှ စ် ဇန်နဝါရီ ၄ ရက်တွ င် လည်းေကာင် း၊
ြပည်ေထာင် စ ြမန်မာိ င် ငံေတာ်အြဖစ် ၁၉၈၈ခ ှ စ် စက်တင် ဘာ ၂၃ ရက်တွ င် လည်းေကာင် း၊ ြပည်ေထာင် စ ြမန်မာ
ိ င် ငံေတာ်အြဖစ် ၁၉၈၉ ခ ှ စ် ဇွ န် ၁၈ ရက်တွ င် လည်းေကာင် း အမည်များေြပာင် းလဲခဲ့သည်။ အာဏာရစစ်အစိ းရ
အား အသိ အမှတ် မပေသာ အဖွဲ အ
့ စည်းများက ဘားမား ("Burma") ဟ သာ အသိ အမှတ်ပ သ ံ းစွဲခဲ့သည်။ ိ င်
ငံ ေတာ်အလံ ကိ လည်း ယခင် ိ င် ငံေတာ် ေအးချမ်းသာယာေရးှ င့ ် ဖွံ ့ ဖိ းေရးေကာင် စီအစိ းရလက်ထက် ၂၀၀၈ ခ ှ စ် ဖွဲ ့
စည်းပ ံ အေြခခံ ဥပေဒတွ င် ြပာန်းထားသည့် ြပည်ေထာင် စ သမ တ ြမန်မာိ င် ငံေတာ်အလံ ြဖင့ ် ၂၀၁၀ ခ ှ စ်
ေအာက်တိ ဘာလ ၂၁ ရက်ေန့ တွင် အလံ စတင် လင့် ထြခင် း အခမ်းအနားများကိ ိ င် ငံတဝှ မ်း ကျင် းပကာ အစားထိ း၍
ေြပာင် းလဲ အသ ံ းခဲ့ ပသည်။
KHMER
ង នី េះ
យុវជនក់នប់េយប់ំេភង
របស់បល
៉ូ ស
ិ និងបីក់េផងេទតរងរបួស េកុងរបឈមមុខក់
อยูแลวในอัลบัม
้ บรรจุอยูดวย ทัง้ เพลง "ซัมติง" และเพลง "คัมทูเกตเตอร" ที่อยูในอัลบัม
้ แอบบีโรด และ
บีตเทิลส
SINHALA
නඩත් කායයන් කිපීයාව ප්රශස්ත මටමකින් පවත්වා ගැනීම සදහා අත්යවශ්ය අංගයකි. උපෙදස් රාව
මගින් තවත් අත් නඩත් කායයන් තැනීෙදී පරිස්ස ය යුය. ඔබට හැකි ට සංධානාත්මක වන්න, එෙහත්
සෑමටම ශාල පින්රය ඇලතින් තබා ගන්න: අප ෙමතැනට පැණ සින්ෙන් ශ්වෙකා්ෂයක් තැනීම සදහායි.
ඔබ සිතන්ෙන් නඩත් කිරීවලට වඩා අෙනත් පැතිවලින් කිපීයාවට දායක මට න, කණාකර
කිපීයා:කිපීයාවට දායක ම බලන්න. ඉක්මනින් අවශ්ය සහ ඉතා වැදගත් වන කායයන් කිපීයා:අතපසු වූ
වැඩ හීදි ෙසායාගැනීමට අවස්ථාව ඇත.
TIBETAN
༄།ཏ།ༀགགརགརསཾག། ༀམ།ༀ།ༀམཔ།ༀཿ་
བཔ།ༀམིཝན།ༀཝཾ།ༀ་ མཔ།ༀབ།ༀ།ༀཾ་ །
ༀི།ༀམེ།
TAI THAM
Lao, Thai and Khmer text does not have space between words. By default, mPDF 6 uses word
dictionaries to determine appropriate opportunites for line-breaks. Users may turn this function off
using the configurable variable useDictionaryLBR.
Alternatively users can insert the character U+200B (zero-width space) in the text to mark line-
breaking opportunities manually.
Similarly for Tibetan script, mPDF 6 uses a simple algorithm to identify line-breaking opportunities
after the characters U+0F0B (Tsheg) or U+0F0D. This can be overriden using the configurable
variable useTibetanLBR.
Myanmar Fonts
Myanmar (Burmese) on the web is quite frequently written for fonts which are not strictly unicode-
compliant. This includes common applications such as WordPress and a number of official Burmese
government websites.
Ayar fonts (http://www.ayarunicodegroup.org) are based on text input where the vowel preceeds the
consonant (which is contrary to Unicode specification).
ZawGyi-One is another very common font in use. This font has some characters incorrectly coded e.g.
U+103A as U+1039.
There are also fonts available which are fully unicode compliant, such as Padauk, Tharlon, Myanmar3,
and Microsoft's Myanmar Text.
As long as you select the right font for the input text, all of them work fine in mPDF:
Tharlon: ဒရကပငမ ဧရဖငက ယနကဒအဖစ ရညနပဆနကတ တရလ ဧရဟ
ယနကဒ မဖစကငန ဘလမဖစရတလဆတ အတပ ရငပမယ။ ယနကဒဖစဖ - ၁။ ယနကဒ
ကဒပ ငန ကကညရပမယ။ ၂။ ယနကဒ စလစပ (Encoding) န ကကညရပမယ။
from http://www.myanmarlanguage.org/unicode
mPDF 6 supports use of the lang selector in CSS. All of the following are supported:
:lang(fr)
p:lang(fr)
span:lang("syr")
[lang="fr"]
[lang='fr']
p[lang=fr]
p[lang="zh-TW"]
should be of equal specificity, and thus apply whichever comes later in the CSS stylesheet. mPDF 6
however gives :lang priority over .class
The use of the lang attribute and CSS selector is now the recommended method for
handling multi-lingual documents in mPDF 6.
when OTL tables are being used for a font, the language from the lang attribute is used to select
which OTL features are applied;
used in conjunction with CSS lang selector to allow CSS styles to be applied;
can be used in conjunction with autoLangToFont and autoScriptToLang (see below)
IETF tags should be used for lang which comply with the following:
Note: This functionality of mPDF has changed considerably in mPDF v6 and is not backwards
compatible.
mPDF 6 has two functions which can be used together or separately:
autoScriptToLang - marks up HTML text using the lang attribute, based on the Unicode script block in
question, and configurable values in config_script2lang.php.
autoLangToFont - selects the font to use, based on the HTML lang attribute, using configurable values
in config_lang2font.php.
For automatic font selection, ideally we would choose the font based on the language in use. However
it is actually impossible to determine the language used from a string of HTML text. The Unicode
script block can be ascertained, and sometimes this tells us the language e.g. Telugu. However,
Cyrillic script is used for example in many different languages. So the best we can do is base it on the
script used. However, mPDF 6 does this in two stages via the "lang" attribute, because this allows the
options of using either of the stages alone or together:
↓ autoScriptToLang (config_script2lang.php) ↓
↓ autoLangToFont (config_lang2fonts.php) ↓
autoScriptToLang
$mpdf->autoScriptToLang = true;
$mpdf->baseScript = 1;
$mpdf->autoVietnamese = true;
$mpdf->autoArabic = true;
$mpdf->baseScript = 1; tells mPDF which Script to ignore. It is set by default to "1" which is for Latin
script. In this mode, all scripts except Latin script are marked up with "lang" attribute. To select other
scripts as the base, see the file /classes/ucdn.php
Using autoScriptToLang, mPDF detects text runs based on Unicode script block; using the values in
config_script2lang.php it then encloses the text run within a span tag with the appropriate language
attribute. For many scripts, the language cannot be determined: see the example above which
recognises Cyrillic script and marks it up using und-Cyrl, which is a valid IETF tag, coding for
language="undetermined", script="Cyrillic".
Two optional refinements are added: Vietnamese text can often be recognised by the presence of
certain characters which do not appear in other Latin script langauges, and similarly analysis of the
text can attempt to distinguish Arabic, Farsi, Pashto, Urdu and Sindhi. If active, the text will then be
marked with a specific language tag e.g. "vi", "pa", "ur", "fa" etc.
These features can be disabled or enabled (default) using the variables $mpdf->autoVietnamese
$mpdf->autoArabic, either in config.php or at runtime.
$mpdf->autoLangToFont = true;
You can edit the values in config_lang2font.php to specify which fonts are used for which "lang".
Using text with multiple languages
Recommended ways to use multiple languages in mPDF:
1. If you have full control over the HTML, mark-up the text with the "lang" atribute and use CSS (:lang
selector preferably); this method means that the language information can also be used by OTL for
language dependent substitutions.
2. If you have no control over (user) HTML input and want to output faithfully, use both
autoScriptToLang and autoLangToFont
It is preferable not to use autoScriptToLang and autoLangToFont unless they are necessary: they will
result in increased processing time, and OTL tables will not be able to use language dependent
substitutions when undefined languages are set e.g "und-Cyrl".
Updating from previous mPDF versions
As a brief summary, to update from previous versions of mPDF:
Use $this->autoScriptToLang=true instead of $this->SetAutoFont()
Use $this->autoLangToFont instead of $this->useLang
The algorithm to handle bi-directional text (right to left) has been completely rewritten. Text is now
processed across the whole paragraph ignoring inline tags. There is also full support for the methods
to control/override the display.
1) The following Unicode characters are supported, and can be inserted directly in the text as HTML
entities:
LRE U+202A LEFT-TO-RIGHT EMBEDDING ‪
RLE U+202B RIGHT-TO-LEFT EMBEDDING ‫
LRO U+202D LEFT-TO-RIGHT OVERRIDE ‭
RLO U+202E RIGHT-TO-LEFT OVERRIDE ‮
PDF U+202C POP DIRECTIONAL FORMATTING ‬
LRI U+2066 LEFT-TO-RIGHT ISOLATE ⁦
RLI U+2067 RIGHT-TO-LEFT ISOLATE ⁧
FSI U+2068 FIRST STRONG ISOLATE ⁨
PDI U+2069 POP DIRECTIONAL ISOLATE ⁩
LRM U+200E LEFT-TO-RIGHT MARK ‎
RLM U+200F RIGHT-TO-LEFT MARK ‏
2) The following HTML tags are supported:
3) The CSS property "unicode-bidi" is supported with the following (CSS3) values: normal | embed |
NB dir="auto" is not supported generally, but it is supported for <bdi> (has the same effect as if
omitted) to use First Strong Isolate (FSI).
Directionality can now be set on individual table cells <td style="direction:rtl;unicode-bidi:embed;">
or <td dir="rtl">
Equivalent methods
The following are equivalent methods:
EMBED
<span dir="rtl">...</span>
‫...‬
<span style="direction: rtl; unicode-bidi: embed">...</span>
OVERRIDE
<bdo dir="rtl">...</bdo>
‮...‬
<span dir="rtl" style="unicode-bidi: bidi-override">...</span>
<span style="direction: rtl; unicode-bidi: bidi-override">...</span>
ISOLATE
<bdi dir="ltr">...</bdi>
⁧...⁩
<span dir="rtl" style="unicode-bidi: isolate">...</span>
<span style="direction: rtl; unicode-bidi: isolate">...</span>
First Strong Isolate (FSI)
<bdi>...</bdi>
<bdi dir="auto">...</bdi>
⁨...⁩
<span dir="rtl" style="unicode-bidi: plaintext">...</span>
<span style="direction: rtl; unicode-bidi: plaintext">...</span>
First strong isolate (FSI)
FSI is useful when including text within a paragraph where the directionality of the text is unknown.
For example, if you are printing out a catalogue from a database of book titles and the number of
readers, when some book titles are in right-to-left script, you may use this template:
Kerning is a bit complicated! CSS3 allows for 2 methods of specifying kerning. In mPDF 6, these 2
methods have exactly the same effect:
font-kerning: normal;
font-feature-settings: 'kern' on;
Most fonts contain both or none, but they may exist independently.
If kerning is set to be active (by either of the CSS methods):
if the useOTL value means that OTL GPOS tables are applied, then this method will be used;
if not, then the separate kern table will be used - if it exists.
In Latin script, kerning will only be applied if specified by CSS. The configurable variable useKerning
determines behaviour if font-kerning: auto is used (the default).
When using OTL tables, kerning is set to be on by default for non-LATIN script; this is because a
number of fonts use information in the kern feature to reposition glyphs which are essential for
correct display in complex scripts.
Limitation: if useOTL is set, but not for Latin script (e.g. = 0x02), and the text string contains more
than one script, then kerning will not be applied to the Latin script text e.g. [Cyrillic text][Latin
text][Cyrillic text]. This is because mPDF uses the presence of any repositioning applied to determine
if kerning has been applied, otherwise using the alternative kern tables.
Small-Caps
will appear as superscript (only) if the font is OTL-capable and contains specific glyphs for superscript.
Note that font-variant:super will also be recognised as font-variant is now considered the shorthand
version cf. above.
If the font has useOTL enabled (to any value), and the font OTL tables contain the "sups" feature, then
the OTL feature will be used to substitute purpose-designed glyphs from the font.
The same for subscript using font-variant-position:sub.
If you wish to use a superscript/subscript which will work with any font, continue to use the tags
<sup> and <sub> which (through the default CSS in config.php) will generate superscript using CSS
vertical-align=super and font-size=55%.
In config_fonts.php there are 2 new variables which affect OTL features e.g.:
mPDF is published with a large collection of fonts, and all configured to use their full OTL capabilities.
useOTL
useOTL should be set to an integer between 0 and 255. Each bit will enable OTL features for a
different group of scripts:
Bit dec hex Enabled
1 1 0x01 GSUB/GPOS - Latin script
2 2 0x02 GSUB/GPOS - Cyrillic script
3 4 0x04 GSUB/GPOS - Greek script
4 8 0x08 GSUB/GPOS - CJK scripts (excluding Hangul-Jamo)
5 16 0x10 (Reserved)
6 32 0x20 (Reserved)
7 64 0x40 (Reserved)
8 128 0x80 GSUB/GPOS - All other scripts (including all RTL scripts, complex scripts etc)
Setting useOTL to 0 (or omitting it) will disable all OTL features. Setting useOTL to 255 or 0xFF will
enable OTL for all scripts. Setting useOTL to 0x82 will enable OTL features for Cyrillic and complex
scripts.
Page ১৪ of ৩৪ ৩৪ পাতা থেক পাতা ১৪
In a font like Free Serif, it may be useful to enable OTL features for complex scripts, but disable OTL
for Latin scripts (to save processing time). However, see above - this may disable kerning in Latin
scripts in certain circumstances.
useKashida
useKashida should be set for arabic fonts if you wish to enable text justification using kashida. The
value should be an integer between 0 and 100 and represents the percentage of additional space
required to justify the text on a line as a ratio of kashida/inter-word spacing.
Choosing fonts to add to mPDF 6
Fonts with OTL need to have GDEF, GSUB and GPOS tables in the font file. Although TrueType font
files are binary files, the table names and script/feature tags are written as ASCII characters; open the
.ttf or .otf file in a text editor such as Windows Notepad, and you will see GDEF, GSUB and GPOS in
the first few lines if they are present. You can also search the file to see if the script tags are present
for your desired scripts cf. http://www.microsoft.com/typography/otspec/scripttags.htm.
Note: The OTL specification for Indic fonts was updated in 2005 to version 2. The v2 script tag for
Bengali is "bng2" whereas prior to this it was "beng". Many open-source font files are still written for
the old specification. This is supported by mPDF, although v2 fonts give better results.
Note: mPDF does not support Graphite or AAT font features.
Configuring new fonts for mPDF 6
To add a font, first copy the font file to the /ttfonts/ folder.
Then edit config_fonts.php to add. See the manual for details if you are not already familiar with this.
If you wish to use this font with autoLangToFont, you also need to edit config_lang2fonts.php
Setting OTL use at runtime
mPDF caches some font information in the /ttfontdata/ folder to improve performance. This is
regenerated if you change the value of useOTL for a font.
There may be circumstances when you wish to use OTL features with different scripts depending on
the document e.g. for everyday use you may want to disable OTL for FreeSerif to save processing
time, but on occasions use OTL for Indic and/or Arabic scripts. The recommended way to do this is to
create 2 instances of the font e.g. in config_fonts.php:
You could then either use this second font name in your stylesheets e.g.
$mpdf->fonttrans['freeserif'] = 'freeserif2';
<style>
div { border: 1px solid black; padding: 1em; }
.level1 { box-decoration-break: slice; }
.level2 { box-decoration-break: clone; }
.level3 { box-decoration-break: clone; }
</style>
<div class="level1">
<div class="level2">
<div class="level3">
<p style="page-break-after:always">...</p>
<p>....</p>
</div>
</div>
</div>
Line breaking
The algorithm for determining automatic line breaks has been completely rewritten, ignoring inline
tags (except for some cases of CJK line-breaking, and autohyphenation).
Line breaks will be allowed at:
Spaces U+0020
Word break U+200B
Hyphen-minus U+002D when CSS hyphens set to "manual" or "auto", except when in a URL, or
when following character is a > or numeral
Hard hyphen U+2010 when CSS hyphens set to "manual" or "auto"
Soft hyphen U+00AD "" when CSS hyphens set to "manual" or "auto"
Automatic hyphenation when CSS hyphens set to "auto"
Between CJK characters, except CJK numerals, before "CJK-following" or after "CJK-leading"
characters
Examples
Using the font metrics will give approximately the same result as the fixed value for many standard
Latin script fonts e.g. DejaVu Sans Condensed:
line-height: normal; based on font metrics
However, for some fonts the normal line-height using font metrics will be significantly taller, to
account for the design of the font glyphs e.g. Khmer font:
line-height: normal; based on font metrics; ង ង នី នី េះ យុវជន
line-height: normal; using fixed value; ង ង នី នី េះ យុវជន
For more information on how complex normal lineheights are, see Eric Meyers' website:
http://meyerweb.com/eric/thoughts/2008/05/06/line-height-abnormal/ and
http://typophile.com/node/13081
CSS control of line-height
There are also new controls for line-height using draft CSS3 properties. These can be set on all block
level elements (P, DIV etc) and tables (TABLE/TD/TH).
inline-line-height - [default] lineheight is initially calculated from the block-level font[-size]; the
height is expanded by any inline content, including the calculated lineheight of that inline content;
block-line-height - lineheight is fixed as the lineheight of the block-level font[-size];
max-height - lineheight is initially calculated from the block-level font; the height is expanded by
any inline content, EXCLUDING the calculated lineheight of that inline content;
grid-height - lineheight is initially calculated from the block-level font; the height is expanded - AS
MULTIPLES OF INITIAL LINEHEIGHT - by any inline content, EXCLUDING the calculated lineheight of
that inline content;
Page ১৮ of ৩৪ ৩৪ পাতা থেক পাতা ১৮
Note: XSL has a similar property with the same name, which uses different but equivalent values:
line-height instead of inline-line-height, font-height instead of block-line-height. It also uses
max-height. The value grid-height is new to the CSS3 property.
Examples
line-height: normal; DejaVu Sans Condensed
This property determines whether to include or disregard the adjusted top- and bottom-edge of any
characters that have a baseline-shift (e.g. superscript) when calculating lineheight.
Note: XSL has a similar property with a different name: line-height-shift-adjustment which uses the
same values.
Examples
In the table below, the line-height is set to 1em throughout the table; line-stacking-shift is set as
'disregard-shifts' in the first row, and has default setting (consider-shifts) in the second row.
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed
Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed Normal text DejaVu Sans Condensed
Normal text DejaVu Sans[53] Condensed
For more details see the CSS3 draft specification.
Note for Advanced users
There are actually three possible metrics that can be used in a TrueType font file. The differences are
summed up quite well in this article at http://typophile.com/node/13081. mPDF will by default use the
usWinAscent and usWinDescent values to determine a 'normal' line-height, with two variations:
if either the usWinAscent or usWinDescent are greater than the font bounding box (yMin yMax),
then the values are reduced to equal the yMin/yMax values. NB this works as a fix with Myanmar
Text (Windows 8 version) to give a line-height normal that is equivalent to that produced in
browsers.
if the USE_TYPO_METRICS bit is set on fsSelection (OS/2 table), this is telling the font to use the
sTypo values and not the usWinAscent values. NB this works as a fix with Cambria Math font to
You can change the font metrics used by mPDF, by editing the defined constant (_FONT_DESCRIPTOR)
at the top of the mpdf.php file:
'winTypo' uses sTypoAscender etc from the OS/2 table and is the one officially recommended - BUT
'win' use usWinAscent etc from OS/2 and in practice seems to be used most commonly in Windows
environment; this is the default in mPDF;
'mac' uses Ascender etc from hhea table, and may be used to give results consistent with a
Mac/OSX environment.
Finally, you can override values for Ascent, Descent and Leading for any specific font, by setting
values in config_font.php e.g.
Note - The same values are used for all styles of the font-family. Descent values should be negative.
All values should be given using a 1000 units per em scale, regardless of the UnitsPerEm used in the
font design.
Notes
Remember that line-height for a TABLE has a default value (1.2) set in the config.php default CSS.
This is left in for backwards compatability. You can change this value to 'normal' for results consistent
with most browsers.
Line-height in a <textarea> is fixed and defined in classes/mpdfform.php (= 1.2)
Details of the font metrics can be seen by inspecting the temporary font files e.g.
/ttfontdata/[fontname].mtx.php.
When an Index is inserted in the PDF document, the Index is now generated (internally) as HTML code
in the following format:
<div class="mpdf_index_main">
<div class="mpdf_index_letter">A</div>
<div class="mpdf_index_entry">Aardvark<a class="mpdf_index_link"
href="#page37">37</a>
</div>
...
</div>
CSS stylesheets can thus be used to control the layout of the Index e.g.:
/* For Index */
div.mpdf_index_main {
line-height: normal;
font-family: sans-serif;
}
div.mpdf_index_letter {
line-height: normal;
font-family: sans-serif;
font-size: 1.8em;
font-weight: bold;
text-transform: uppercase;
page-break-after: avoid;
margin-top: 0.3em;
margin-collapse: collapse;
}
div.mpdf_index_entry {
line-height: normal;
font-family: sans-serif;
text-indent: -1.5em;
}
a.mpdf_index_link {
color: #000000;
text-decoration: none;
}
A default stylesheet for Indexes is included in mpdf.css (see note later for more information).
A
Alonso, Fernando
Ãlvarez, Isaac
Arroyo Molino, David
B
BenÃtez, Carlos
Entries in an Index can now be sorted using any of the Locale values available on your system. Set it
using the "collation" property/parameter e.g.:
NB You should always choose a UTF-8 collation, even when you are using Core fonts or e.g. charset-
in=win-1252, because mPDF handles all text internally as UTF-8 encoded.
You can see which Locales are available on your (Unix) system: <?php system('locale -a') ?>
Note: Index collation will probably not work on Windows servers because of the problems setting
Locales under Windows.
If you have set your index to use Dividing letters, you can also determine how letters are grouped
under a dividing letter. In the example index above, we want à to be grouped under the letter a/A. Set
the "collation-group" using:
Values should be selected from the available file names in folder /collations/.
Note: This will not affect the overall order of entries, which is determined by the value of "collation".
Note: The groupings do not always match the order set by locale. This is because the data for
collations has come from different sources. The files in /collations/ can be edited.
The array consists of [index]: unicode decimal value of character => unicode decimal value of
character to group under: e.g. Ã [A tilde] (U+00C3) (decimal 195) => a (U+0061) (decimal 97). The
target character should always be the lowercase form.
Non-ASCII chcracters in Index entries
Note: htmlspecials_encode should be used to encode the text of content in <indexentry> - although
not when using $mpdf->IndexEntry().
Columns
Columns are no longer specified as part of the <indexinsert>, so a typical 2-column index might be
produced by:
A shorthand way of displaying subentries is set by default, which suppresses the main entry if > 1
subEntry. It can be disabled/enabled using the configurable variable $this->indexUseSubentries in
config.php.
This is the default appearance, with $this->indexUseSubentries = false; -
Mammals 73
- elephants 142
- humans 173
Marsupials
- kangaroos 75
- wombats 86
Index entries can also include simple mark-up tags and/or more than one colon e.g:
Lists are now handled as for other block level tags, so you can apply any CSS properties usable on
blocks (e.g. border, background, padding) to UL/OL and LI tags.
CSS property "list-style" is now handled properly as a shorthand, and there is full support for "list-
style-image", "list-style-type", and "list-style-position".
There are two modes for lists in mPDF 6: "mpdf" mode and "browser" mode. Mode is set using the
configurable variable $this->list_auto_mode in config.php
1) Browser mode gives the same display as most browsers. In this mode, the default list indentation is
set by padding "0 auto" in the default CSS in config.php. "auto" equates to the value of
$this->list_indent_default in config.php - this is a "magic" value for padding, which is applied to either
left or right depending on directionality of the list (rtl/ltr).
2) mPDF mode gives results compatible with previous versions of mPDF. In this mode, the indentation
is calculated differently: the outside edge of the list item is considered to be the outside edge of the
bullet or number. For numbered lists, mPDF calculates the width of the largest number and this width
is used to set the outside edge. The default list indentation of "auto" in mPDF mode is set by
$this->list_indent_default_mpdf. This value is added to the automatic calculated indentation. For
backwards compatibility, $this->list_indent_first_level = 0; can be used to prevent any indentation of
the first list level.
The automatic indentation only works for bullets or numbered lists, and is ignored if "list-style-
position: inside" is set, or images are used for markers.
Browser mode is set as the default - for backwards compatibility, change this to "mpdf".
List top & bottom margins
The default in browsers is to add a top and bottom margin to the outermost list only. This can be
defined using CSS as:
$this->list_marker_offset = '5.5pt';
$this->list_symbol_size = '3.6pt';
To specify size and offset proportional to the list item's font size (compatible with previous versions of
mPDF), use:
$this->list_marker_offset = '0.45em';
$this->list_symbol_size = '0.31em';
I. First item
II. Second item
I. Next list level
II. Second item
This demonstrates the same default settings, but list numbering is set to start at 32. Note how the
indentation is adjusted to fit the maximum width of the numbering.
This demonstrates the appearance when list_auto_mode is set to 'browser', compatible with
browsers. Indentation is set to 40px (list_indent_default)
I. First item
II. Second item
I. Next list level
II. Second item
This demonstrates the same as the previous example, but list numbering is set to start at 32. Note
that the default indentation remains fixed at 40px (list_indent_default)
Image transform
The CSS property "transform" is supported on images (only). All transform functions are supported
except matrix() i.e. translate(), translateX(), translateY(), skew(), skewX(), skewY(), scale(), scaleX(),
scaleY(), and rotate()
Transforms cannot be used when using columns or Keep-with-table (use_kwt).
The CSS property background-color is now supported on images.
In the following examples, note the difference between transform (which is applied after layout) and
image-orientation (which is applied before layout):
CSS overline
The CSS property "text-decoration: overline" is supported. Note that since mPDF 5.7.3 text-decoration
use the parent inline block baseline/fontsize/color for child inline elements, and allows nested use of
these values and superscript/subscript.
Headers and Footers are all now written internally as HTMLheaders/footers. The use of non-HTML
headers and footers is depracated, but remains supported. Non-HTML headers and footers are
converted in mPDF to HTML equivalents.
Layout: This may mean that there will be a change in the resulting PDF. The main change is that an
HTML table is created with three cells for left, right and middle; if you had a very long Left header
item, it will not overwrite the center item, but it may wrap center onto 2 lines.
Naming: Default non-HTML headers will not clash with HTML headers, but named non-HTML headers
WILL clash with (and overwrite) HTML headers of the same (equivalent) name e.g. html_MyFooter ==
MyFooter (non-HTML).
Aliases: {nb} or {nbpg} now only work in Headers or Footers, and not in the main text. {PAGENO}
and {DATE ...} continue to only work in Headers or Footers.
ToC: Can now set the pagenumbering/style/reset/suppress for the ToC separately (see section on
ToC).
The following are all depracated (but still supported) in favour of HTMLheader/footers:
SetHeader()
SetFooter()
<pageheader>
<pagefooter>
DefHeaderByName()
DefFooterByName()
<setpageheader>
<setpagefooter>
SetHeaderByName()
SetFooterByName()
If document direction is RTL (body dir=rtl, html dir=rtl), then you need to set directionality before
setting non-HTML headers e.g.
Page numbering can now be applied and controlled for the pages containing a ToC.
There are three new parameters to control pagenumbering in the ToC: toc-resetpagenum, toc-
pagenumstyle, and toc-suppress. These are set as attributes in <tocpagebreak> or as the last 3
parameters in TOCpagebreak(); they set the pagenumbering and pagenumbering style for the ToC,
and whether to suppress pagenumbers in ToC.
The default setting for all is to continue pagenumbering and pagenumstyle (and suppression) from
pages preceding the ToC.
Note: Page numbering will always reset following a ToC. By default it will set it to 1, unless a value
for resetpagenum is specified in TOCpagebreak or <tocpagebreak>.
Backwards compatibility: page numbers are no longer suppressed by default in ToC.
Although "suppress" and "toc-suppress" are supported, the recommended way to control whether
page numbering appears is by using different headers and footers for each section.
Note: If you have 2 ToCs immediately following each other, and wish to use pagenumstyle or suppress
to control the following text, then you need to set those values on both of the <tocpagebreak>
elements.
The default CSS styles for ToCs and Indexes are now set in mpdf.css (see later).
See notes later on page numbering.
Setting up mPDF 6
mPDF 6 has changed significantly from earlier version and it is recommended that a fresh install is
used. You may wish to copy your previous config_* files and use them to update the new config files.
config_fonts.php - values of "indic" and "unAglyphs" from previous versions are now redundant.
config_lang2fonts.php - this is similar to the previous config_cp.php file; note however that $unifont
(NOT $unifonts) must be only one font (not a comma-separated list as before).
Included fonts - the Indic fonts e.g. ind_bn_001.ttf are no longer required (nor do they work properly
with mPDF 6).
useLang - this configurable variable, which used to be true by default, is now redundant. You may
need to set: $mpdf->autoLangToFont = true; for the same results.
SetAutoFont() - is now redundant. You may need to set: $mpdf->autoScriptToLang = true; for the
same results.
Indexes - have been largely redefined. See the section above.
Lists - have been rewritten. See the section above.
Headers and Footers - have been rewritten. See the section above.
A number of old depracated aliases will no longer be supported. Warning errors have been added to
prompt you to change to the updated form:
<pagebreak pagenumstyle="arabic-indic">
"1" - decimal
"A" = upper-latin or upper-alpha
"a" = lower-latin or lower-alpha
"I" = upper-roman
"i" = lower-roman
or any of the following: arabic-indic, hebrew, bengali, devanagari, gujarati, gurmukhi, kannada,
malayalam, oriya, persian, tamil, telugu, thai, urdu, cambodian, khmer, lao, cjk-decimal
Note: A suitable font must be used in the header/footer in order to display the numbers in the
selected script.
You can now set the pagenumberstyle from the beginning of the document by changing the
configurable variable:
Backwards Compatibility
For maximum backwards comaptibility with older versions of mPDF, change the following configurable
variables in the config.php file:
mPDF 6.0 Default (Browser Backwards Compatible
compatible)
Normal Line- $this->useFixedNormalLineHeight = false; $this->useFixedNormalLineHeight = true;
height $this->useFixedTextBaseline = false; $this->useFixedTextBaseline = true;
$this->adjustFontDescLineheight = 1.14; $this->normalLineheight = 1.33;
Lists $this->list_auto_mode = 'browser'; $this->list_auto_mode = 'mpdf';
$this->list_marker_offset = '5.5pt'; $this->list_marker_offset = '0.45em';
$this->list_symbol_size = '3.6pt'; $this->list_symbol_size = '0.31em';
More Information