In accepted answer link is broken and it contained old version of DOMPDF.
To work with unicode symbols in DOMPDF 0.6 you have two alternatives: use existed fonts or create your own font.
- Use existed font (applied for DOMPDF 0.6):
- Download archive and extract.
- Copy extracted files in your dompdf fonts folder
/dompdf/lib/fonts/
.
- Edit
dompdf_font_family_cache.dist.php
with snippet 1.
- In CSS use
font-family: times;
.
Snippet 1:
/* ... */
'times' => array (
'normal' => DOMPDF_FONT_DIR . 'times',
'bold' => DOMPDF_FONT_DIR . 'timesbd',
'italic' => DOMPDF_FONT_DIR . 'timesi',
'bold_italic' => DOMPDF_FONT_DIR . 'timesbi'
),
'times-roman' => array (
'normal' => DOMPDF_FONT_DIR . 'times',
'bold' => DOMPDF_FONT_DIR . 'timesbd',
'italic' => DOMPDF_FONT_DIR . 'timesi',
'bold_italic' => DOMPDF_FONT_DIR . 'timesbi'
),
/* ... */
- If you want to use your own TTF font (say,
Arial.ttf
):
- Run:
ttf2afm -o Arial.afm Arial.ttf
. (I did it in Ubuntu.)
- Run:
ttf2ufm -a -F Arial.ttf
. (I did it in Windows using exe from UFPDF, but I guess you can use /dompdf/lib/ttf2ufm/bin/ttf2ufm.exe
.)
- Copy
Arial.*
files in /dompdf/lib/fonts/
.
- Add to
dompdf_font_family_cache.dist.php
snippet 2.
- In CSS use
font-family: arial;
.
Snippet 2:
/* ... */
'arial' => array (
'normal' => DOMPDF_FONT_DIR . 'Arial',
'bold' => DOMPDF_FONT_DIR . 'Arial',
'italic' => DOMPDF_FONT_DIR . 'Arial',
'bold_italic' => DOMPDF_FONT_DIR . 'Arial'
)
/* ... */
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…