PhenX / canvas-text

Automatically exported from code.google.com/p/canvas-text
MIT License
1 stars 2 forks source link

typefaces file for font name with spaces #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I set dontUseMoz=true | reimplement=true | autoload=false
2. I want load font which contains spaces characters in name (I.E DejaVu
Sans, DejaVu Serif...)

What is the expected output? What do you see instead?
If I rename font file like dejavu_serif-normal-normal.js, I can load
typeface file but have this js error :
Erreur : this.faces[family] is undefined
Fichier Source :
http://domaine.ltd/canvas.text.js?dontUseMoz=true&reimplement=true&autoload=fals
e
Ligne : 158

This is beacause there in the dejavu_serif-normal-normal.js file, the
"familyName" property is set to "DejaVu Serif".

To correct this we have to modify any typeface file "familyName" property,
I.E we can use DejaVuSerif and load dejavuserif-normal-normal.js file.

Original issue reported on code.google.com by henri.th...@gmail.com on 20 Aug 2009 at 8:56

GoogleCodeExporter commented 9 years ago
Hello, you need to specify the font family name with quotes, like this :

ctx.font = "20px 'DejaVu Serif'";

or 

ctx.font = '20px "DejaVu Serif"';

When you have spaces in the font face name. The spec allows spaces in font 
names 
without quotes, but the lib doesn't handle this yet.

The spec : 

  For example, after the following statement:

     context.font = 'italic 400 12px/2 Unknown Font, sans-serif';

  ...the expression context.font would evaluate to the string "italic 12px "Unknown 
Font", sans-serif"

Original comment by fabien.menager on 20 Aug 2009 at 9:55