Re: custom font not working

4,079 views
Skip to first unread message

Susanna

unread,
Dec 17, 2012, 11:28:00 PM12/17/12
to dom...@googlegroups.com
Forgot to add, what happens in the rendered pdf is that the text that should be using the Ubuntu font is in Arial instead. I assume it just goes down the font-family list specified in the css until it finds one it can use.

BrianS

unread,
Jan 10, 2013, 4:16:24 PM1/10/13
to dom...@googlegroups.com
In 0.6.0 beta 3 you no longer need to use the web-based font prep tool (though you can if you want). You can use load_font.php on your own server since it now uses php-font-lib internally, or you can use @font-face.

Does your installation have a dompdf_font_family_cache file as well as dompdf_font_family_cache.dist? It sounds like the font is loading, but when dompdf later goes to use it it's not finding it. I recommend reinstalling the font using load_font.php or using the @font-face method (remember, you'll have to adjust the font URLs so that they use a valid path).


On Monday, December 17, 2012 11:16:14 PM UTC-5, Susanna wrote:
I am using dompdf 0.6.0 beta 3 on a Drupal 7 site (via the Print module). I'm trying to use the Ubuntu font from here:
http://www.fontsquirrel.com/fonts/ubuntu
I used the font tool at http://eclecticgeek.com/dompdf/load_font.php to generate ufm files from the ttf files. The font files I uploaded to ..../dompdf/lib/fonts/ are:
Ubuntu-B-webfont.ttf
Ubuntu-B-webfont.ufm
Ubuntu-BI-webfont.ttf
Ubuntu-BI-webfont.ufm
Ubuntu-I-webfont.ttf
Ubuntu-I-webfont.ufm
Ubuntu-R-webfont.ttf
Ubuntu-R-webfont.ufm

The entry in dompdf_font_family_cache.dist.php is:
  'ubuntu' =>
  array (
    'normal' => DOMPDF_FONT_DIR . 'Ubuntu-R-webfont',
    'bold' => DOMPDF_FONT_DIR . 'Ubuntu-B-webfont',
    'italic' => DOMPDF_FONT_DIR . 'Ubuntu-I-webfont',
    'bold_italic' => DOMPDF_FONT_DIR . 'Ubuntu-BI-webfont',
  ),

I also have the stylesheet from fontsquirrel.com's font face kit, which uses the @font-face method, but that isn't working either. My css looks like this:
.cs_subheading{
font-family:ubuntu,UbuntuRegular,Arial,Helvetica,sans-serif;
}

When I go back to drupal admin after generating a pdf, I get errors like this:
Notice: Undefined index: /home/********/public_html/************/sites/all/libraries/dompdf/lib/fonts/Ubuntu-R-webfont in Text_Renderer->render() (line 89 of /home/********/public_html/************/sites/all/libraries/dompdf/include/text_renderer.cls.php).

What am I doing wrong??

BrianS

unread,
Feb 25, 2013, 6:55:21 PM2/25/13
to dom...@googlegroups.com
Are your details the same? If you can provide some context to your problem we can attempt to help you resolve your problem.

On Monday, February 25, 2013 6:38:16 PM UTC-5, Jonathan wrote:
Susanna, were you ever able to fix this issue? I'm running into the very same problem. 

Thanks!

Jonathan Bourland

unread,
Feb 25, 2013, 7:10:21 PM2/25/13
to dom...@googlegroups.com
Hi Brian,

My details are more or less the same. Different font, of course. Actually generated it through load_font.php -- which was successful. It's a ufm. 

I've checked my config to make sure the fonts directory is readable and writable. Check. 

I have font_family_cache.php and font_family_cache.dist.php. 

Would be happy to provide any other details!
--
You received this message because you are subscribed to a topic in the Google Groups "dompdf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dompdf/wziuLJNe0g0/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to dompdf+un...@googlegroups.com.
To post to this group, send email to dom...@googlegroups.com.
Visit this group at http://groups.google.com/group/dompdf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jonathan Bourland

unread,
Feb 25, 2013, 7:13:35 PM2/25/13
to dom...@googlegroups.com
Some other context: I'm using a Mac. The library is called from a  Drupal module -- though I don't believe that's part of the issue. 

Thanks-
Jonathan 

<Sent by Carrier Pigeon>

On Feb 25, 2013, at 6:55 PM, BrianS <eclect...@gmail.com> wrote:

--

BrianS

unread,
Feb 26, 2013, 11:22:43 AM2/26/13
to dom...@googlegroups.com
I suspect that maybe something is missing in your configuration. It seems like the font is loading from dompdf_font_family_cache.php by dompdf, but cpdf isn't loading it. Are both the .UFM and .TTF files in your font directory?

Also, try setting $_dompdf_show_warnings = true and see what shows up in dompdf/lib/fonts/log.htm.

Jonathan

unread,
Feb 27, 2013, 11:16:01 AM2/27/13
to dom...@googlegroups.com
Hi Brian,

I started from scratch and tried to load the font two different ways and got the same result.

The base font file I'm working with is a .otf. I set $_dompdf_show_warnings to TRUE

Method 1: Loaded font from the web interface (dompdf/www/fonts.php). This created .ttf and .ufm files in the fonts directory, as expected (their file names were hashes). Tried to create a pdf and got the results listed below.

Method 2: I used load_font.php. This succeeded with the following results: 

Copying [path to original font]/Whitney OTF/Whitney-Book-Adv.otf to [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv.otf...
Generating Adobe Font Metrics for [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv...
Copying [path to original font]//Whitney OTF/Whitney-Bold-Adv.otf to [path to dompdf]/dompdf/lib/fonts/Whitney-Bold-Adv.otf...
Generating Adobe Font Metrics for [path to dompdf]/dompdf/lib/fonts/Whitney-Bold-Adv...
Copying [path to original font]/Whitney OTF/Whitney-BookItal-Adv.otf to [path to dompdf]/dompdf/lib/fonts/Whitney-BookItal-Adv.otf...
Generating Adobe Font Metrics for [path to dompdf]/dompdf/lib/fonts/Whitney-BookItal-Adv...
Copying [path to original font]/Whitney OTF/Whitney-BoldItal-Adv.otf to /Applications/XAMPP/xamppfiles/htdocs/nmnh/sites/all/libraries/dompdf/lib/fonts/Whitney-BoldItal-Adv.otf...
Generating Adobe Font Metrics for [path to dompdf]/dompdf/lib/fonts/Whitney-BoldItal-Adv...

This created .otf and .ufm files in the fonts directory. When creating a PDF, I got the results below.
 

<span style='color: #000'>10 frames</span> <span style='color: #900'>34,304 KB</span> <span style='color: #090'>593.20 ms</span> <span style='color: #009' title='Quirksmode'><span style='color: #c00'>ON</span></span><br /><b>DOMPDF Warnings</b><br><pre>'_dompdf_appearance' is not a valid CSS2 property.
'_dompdf_appearance' is not a valid CSS2 property.
'_dompdf_appearance' is not a valid CSS2 property.
'_dompdf_appearance' is not a valid CSS2 property.
'_dompdf_appearance' is not a valid CSS2 property.
'_dompdf_appearance' is not a valid CSS2 property.
'_dompdf_appearance' is not a valid CSS2 property.
'zoom' is not a valid CSS2 property.
'_moz_box_sizing' is not a valid CSS2 property.
'_webkit_box_sizing' is not a valid CSS2 property.
'box_sizing' is not a valid CSS2 property.
'_moz_border_radius' is not a valid CSS2 property.
'_webkit_border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'_moz_border_radius' is not a valid CSS2 property.
'_webkit_border_top_left_radius' is not a valid CSS2 property.
'_webkit_border_top_right_radius' is not a valid CSS2 property.
'_webkit_border_bottom_left_radius' is not a valid CSS2 property.
'_webkit_border_bottom_right_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'_moz_border_radius' is not a valid CSS2 property.
'_webkit_border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'text_shadow' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'_moz_border_radius' is not a valid CSS2 property.
'_webkit_border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'box_shadow' is not a valid CSS2 property.
'overflow_x' is not a valid CSS2 property.
'overflow_y' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'box_shadow' is not a valid CSS2 property.
'box_shadow' is not a valid CSS2 property.
'box_shadow' is not a valid CSS2 property.
'box_shadow' is not a valid CSS2 property.
'box_shadow' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
'box_shadow' is not a valid CSS2 property.
'box_shadow' is not a valid CSS2 property.
'border_radius' is not a valid CSS2 property.
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/Helvetica - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/Helvetica - Helvetica
metrics: Helvetica.afm, cache: Helvetica.afm.php
openFont: build php file from [path to dompdf]/dompdf/lib/fonts/Helvetica.afm
selectFont: checking for - [path to dompdf]/dompdf/lib/fonts/Helvetica.
selectFont: pfb or ttf file not found, ok if this is one of the 14 standard fonts
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - Whitney-Book-Adv
metrics: Whitney-Book-Adv.afm, cache: Whitney-Book-Adv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - Whitney-Book-Adv
metrics: Whitney-Book-Adv.afm, cache: Whitney-Book-Adv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - Whitney-Book-Adv
metrics: Whitney-Book-Adv.afm, cache: Whitney-Book-Adv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - Whitney-Book-Adv
metrics: Whitney-Book-Adv.afm, cache: Whitney-Book-Adv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - Whitney-Book-Adv
metrics: Whitney-Book-Adv.afm, cache: Whitney-Book-Adv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - Whitney-Book-Adv
metrics: Whitney-Book-Adv.afm, cache: Whitney-Book-Adv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv - Whitney-Book-Adv
metrics: Whitney-Book-Adv.afm, cache: Whitney-Book-Adv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/Whitney-Book-Adv.  Do you need to run load_font.php?
</pre>


So, it looks like it's not appending the file extension to the filename when trying to open my font. Any ideas? Thanks!
 

BrianS

unread,
Feb 27, 2013, 1:30:37 PM2/27/13
to dom...@googlegroups.com
Don't worry about the missing file extension. A lot that happens under-the-hood with fonts happens without the extension. dompdf/cpdf adds it back when looking for the actual file.

The issue is that you're using an OTF. Though php-font-lib supports OTF we haven't updated dompdf/cpdf with support for the format yet.

Jonathan

unread,
Feb 27, 2013, 4:47:32 PM2/27/13
to dom...@googlegroups.com
Hi Brian,

Good info about .otf. 

Given that, I converted the fonts to .ttf (through a web-based service). I ran load_font again, got success. There are .ttf and .afm files in the fonts directory. However, I'm still getting the same error:

<span style='color: #000'>10 frames</span> <span style='color: #900'>34,560 KB</span> <span style='color: #090'>640.86 ms</span> <span style='color: #009' title='Quirksmode'><span style='color: #c00'>ON</span></span><br /><b>DOMPDF Warnings</b><br><pre>'_dompdf_appearance' is not a valid CSS2 property.
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/whitneybookadv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/whitneybookadv - whitneybookadv
metrics: whitneybookadv.afm, cache: whitneybookadv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/whitneybookadv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/whitneybookadv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/whitneybookadv - whitneybookadv
metrics: whitneybookadv.afm, cache: whitneybookadv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/whitneybookadv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/whitneybookadv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/whitneybookadv - whitneybookadv
metrics: whitneybookadv.afm, cache: whitneybookadv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/whitneybookadv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/whitneybookadv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/whitneybookadv - whitneybookadv
metrics: whitneybookadv.afm, cache: whitneybookadv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/whitneybookadv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/whitneybookadv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/whitneybookadv - whitneybookadv
metrics: whitneybookadv.afm, cache: whitneybookadv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/whitneybookadv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/whitneybookadv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/whitneybookadv - whitneybookadv
metrics: whitneybookadv.afm, cache: whitneybookadv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/whitneybookadv.  Do you need to run load_font.php?
selectFont: selecting - [path to dompdf]/dompdf/lib/fonts/whitneybookadv - , 1
openFont: [path to dompdf]/dompdf/lib/fonts/whitneybookadv - whitneybookadv
metrics: whitneybookadv.afm, cache: whitneybookadv.afm.php
openFont: no font file found for [path to dompdf]/dompdf/lib/fonts/whitneybookadv.  Do you need to run load_font.php?
</pre>

Thinking that it might be a result of converting from otf to ttf, I grabbed a native ttf font and tried that. Still, no dice. Not sure what I still might be doing wrong.

BrianS

unread,
Feb 27, 2013, 7:36:46 PM2/27/13
to dom...@googlegroups.com
Is Unicode enabled? php-font-lib currently only produces Unicode font metrics (.UFM). If you're not set up for Unicode support then dompdf will be looking for the .AFM. Ideally you would have both metrics files. In the meantime you might want to follow the instructions in the Unicode How-to.
Reply all
Reply to author
Forward
0 new messages