Forum Bugs

Font substitution handling for missing fonts

dsmith
Hello,

I have some old SVG images which I can't share that use Helvetica fonts. In Prince XML 12.5, this font is replaced with Arial which is a good substitution. In Prince XML 14.1, this font is replaced with Times New Roman which is not even remotely close to Helvetica. Do I need to specify font substitutions manually with 14.1? If so, can you point me to how to setup the map?

Thanks,
Darren
mikeday
Does the specified font-family include any fallback or is it just "font-family: Helvetica"? I don't recall changes between 12.5 and 14.1 that would apply to this situation, but you could define a @font-face rule that maps Helvetica to Arial instead.
dsmith
In the SVG it is just: .st000 { font-family:Helvetica; }

I'll look into the @font-face rule. Thanks!
mikeday
Right, that will fallback to serif if Helvetica is not present, so you could add something like this:
@font-face {
    font-family: Helvetica;
    src: local("Arial")
}
dsmith
Another issue which seems somewhat related to Prince 14.1 vs Prince 13.6 (not going back to 12.5 this time). I've noticed that 14.1 is not embedding our proprietary font into the PDF like 13.6 did.

The font is called out in our CSS file like so:
  @font-face {
    font-family:'proprietary font name';
    src:url('../resource/font/eot_font.eot') format('eot'),
      url('../resource/font/ttf_font.ttf') format('truetype'),
      url('../resource/font/woff_font.woff') format('woff'),
      url('../resource/font/woff2_font.woff2') format('woff2'),
      url('woff_font.woff') format('woff');
  }

This font is used in our SVGs.

With 13.6 I get the following output:
prince: v3.css: warning: unsupported properties: text-underline-position
prince: ../resource/font/eot_font.eot: warning: ../resource/font/eot_font.eot: can't open input file: No such file or directory
prince: ../resource/font/ttf_font.ttf: warning: ../resource/font/ttf_font.ttf: can't open input file: No such file or directory
prince: ../resource/font/woff_font.woff: warning: ../resource/font/woff_font.woff: can't open input file: No such file or directory
prince: ../resource/font/woff2_font.woff2: warning: ../resource/font/woff2_font.woff2: can't open input file: No such file or directory

Note there is no error for the last URL in the @font-face which was added for Prince PDF generation. The others are for supporting various web browsers.

With 14.1 I just get the following:
prince: v3.css: warning: unsupported properties: text-underline-position

So it seems 14.1 is not even trying to read the fonts?
mikeday
We've adjusted how @font-face rules work in Prince 14 and the main document now has a different scope to external SVG images, they can each import different font families and do not share them. The simplest way to use the same fonts in both is to import the same CSS or apply a user style sheet.
dsmith
Is there any chance you could implement a switch to bring back the old behavior? We have over 250k images that would need to be modified.
mikeday
How about passing "--style myfonts.css" on the command-line, then they would work as-is?

Unfortunately the old behaviour is inconsistent with how browsers work, consider that it implies an SVG might look different depending on which document references it (!)
dsmith
It looks like that switch will work for us. Thank you very much!