Skip to content

Commit

Permalink
rework/update conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
chearon committed Apr 24, 2016
1 parent 5f26917 commit a7cf2f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function fontFile(name) {
// `registerFont`. When you set `ctx.font`, refer to the styles and the family
// name as it is embedded in the TTF. If you aren't sure, open the font in
// FontForge and visit Element -> Font Information and copy the Family Name
Canvas.registerFont(fontFile('Pfennig.ttf'));
Canvas.registerFont(fontFile('PfennigBold.ttf'));
Canvas.registerFont(fontFile('PfennigItalic.ttf'));
Canvas.registerFont(fontFile('PfennigBoldItalic.ttf'));
Canvas.registerFont(fontFile('Pfennig.ttf'), {family: 'pfennigFont'});
Canvas.registerFont(fontFile('PfennigBold.ttf'), {family: 'pfennigFont'});
Canvas.registerFont(fontFile('PfennigItalic.ttf'), {family: 'pfennigFont'});
Canvas.registerFont(fontFile('PfennigBoldItalic.ttf'), {family: 'pfennigFont'});

var canvas = new Canvas(320, 320);
var ctx = canvas.getContext('2d');
Expand All @@ -27,13 +27,13 @@ ctx.font = 'normal normal 50px Helvetica';

ctx.fillText('Quo Vaids?', 0, 70);

ctx.font = 'bold 50px Pfennig';
ctx.font = 'bold 50px pfennigFont';
ctx.fillText('Quo Vaids?', 0, 140);

ctx.font = 'italic 50px Pfennig';
ctx.font = 'italic 50px pfennigFont';
ctx.fillText('Quo Vaids?', 0, 210);

ctx.font = 'bold italic 50px Pfennig';
ctx.font = 'bold italic 50px pfennigFont';
ctx.fillText('Quo Vaids?', 0, 280);

var out = fs.createWriteStream(__dirname + '/font.png');
Expand Down
2 changes: 2 additions & 0 deletions src/register_font.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ get_pango_weight(FT_UShort weight) {
case 100: return PANGO_WEIGHT_THIN;
case 200: return PANGO_WEIGHT_ULTRALIGHT;
case 300: return PANGO_WEIGHT_LIGHT;
#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 36, 7)
case 350: return PANGO_WEIGHT_SEMILIGHT;
#endif
case 380: return PANGO_WEIGHT_BOOK;
case 400: return PANGO_WEIGHT_NORMAL;
case 500: return PANGO_WEIGHT_MEDIUM;
Expand Down

0 comments on commit a7cf2f0

Please sign in to comment.