Julian Viereck
12 years ago
committed by
TJ Holowaychuk
21 changed files with 117012 additions and 30 deletions
@ -0,0 +1,50 @@ |
|||
|
|||
/** |
|||
* Module dependencies. |
|||
*/ |
|||
|
|||
var Canvas = require('../lib/canvas') |
|||
, canvas = new Canvas(320, 320) |
|||
, Font = Canvas.Font |
|||
, ctx = canvas.getContext('2d') |
|||
, fs = require('fs') |
|||
, path = require("path"); |
|||
|
|||
if (!Font) { |
|||
throw new Error('Need to compile with font support'); |
|||
} |
|||
|
|||
function fontFile(name) { |
|||
return path.join(__dirname, '/pfennigFont/', name); |
|||
} |
|||
|
|||
var pfennigFont = new Font('pfennigFont', fontFile('Pfennig.ttf')); |
|||
pfennigFont.addFace(fontFile('PfennigBold.ttf'), 'bold'); |
|||
pfennigFont.addFace(fontFile('PfennigItalic.ttf'), 'normal', 'italic'); |
|||
pfennigFont.addFace(fontFile('PfennigBoldItalic.ttf'), 'bold', 'italic'); |
|||
|
|||
var canvas = new Canvas(320, 320) |
|||
var ctx = canvas.getContext('2d') |
|||
|
|||
// Tell the ctx to use the font.
|
|||
ctx.useFont(pfennigFont); |
|||
|
|||
ctx.font = 'normal normal 50px "Times", serif'; |
|||
|
|||
ctx.fillText('Quo Vaids?', 0, 70); |
|||
|
|||
ctx.font = 'bold 50px pfennigFont'; |
|||
ctx.fillText('Quo Vaids?', 0, 140); |
|||
|
|||
ctx.font = 'italic 50px pfennigFont'; |
|||
ctx.fillText('Quo Vaids?', 0, 210); |
|||
|
|||
ctx.font = 'bold italic 50px pfennigFont'; |
|||
ctx.fillText('Quo Vaids?', 0, 280); |
|||
|
|||
var out = fs.createWriteStream(__dirname + '/fontExample.png'); |
|||
var stream = canvas.createPNGStream(); |
|||
|
|||
stream.on('data', function(chunk){ |
|||
out.write(chunk); |
|||
}); |
@ -0,0 +1,108 @@ |
|||
FONTLOG |
|||
Pfennig font family |
|||
========================== |
|||
|
|||
This file provides detailed information on the Pfennig family of fonts. |
|||
This information should be distributed along with the Pfennig fonts and |
|||
any derivative works. |
|||
|
|||
|
|||
Basic Font Information |
|||
---------------------- |
|||
|
|||
Pfennig is a sans-serif font with support for Latin, Cyrillic, Greek and Hebrew |
|||
character sets. It contains sufficient characters for Latin-0 through Latin-10, |
|||
as well as all modern Cyrillic scripts, the full Vietnamese range, modern Greek, |
|||
modern Hebrew, and the Pan-African Alphabet. It supports the standard Roman |
|||
ligatures and uses OpenType tables for diacritic placement. |
|||
|
|||
Pfennig supports the following Unicode ranges: |
|||
|
|||
Range Description Coverage |
|||
.............................................. |
|||
U+0020-U+007F Basic Latin Full |
|||
U+00A0-U+00FF Latin-1 Supplement Full |
|||
U+0100-U+017F Latin Extended-A Full |
|||
U+0180-U+024F Latin Extended-B 146/208 |
|||
U+0250-U+02AF IPA Extensions 32/96 |
|||
U+02B0-U+02FF Spacing Modifiers 18/80 |
|||
U+0300-U+036F Combining Diacritics 34/112 |
|||
U+0370-U+03FF Greek 74/134 |
|||
U+0400-U+04FF Cyrillic 214/256 |
|||
U+0500-U+052F Cyrillic Supplement 14/44 |
|||
U+0590-U+05FF Hebrew 27/87 |
|||
U+1DC0-U+1DFF Comb. Diacritic Supp. 4/43 |
|||
U+1E00-U+1EFF Latin Extended Add'l 173/256 |
|||
U+2000-U+206F General Punctuation 19/107 |
|||
U+2070-U+209F Super/Subscripts 1/42 |
|||
U+20A0-U+20CF Currency Symbols 1/26 (Euro sign only) |
|||
U+2100-U+214F Letterlike Symbols 2/80 |
|||
U+2200-U+22FF Mathematical Operators 2/256 |
|||
U+25A0-U+25FF Geometric Shapes 1/96 (Dotted circle only) |
|||
U+2C60-U+2C7F Latin Extended-C 5/32 |
|||
U+A720-U+A7FF Latin Extended-D 5/129 |
|||
U+FB00-U+FB06 Latin Ligatures 5/7 (all except archaic ligatures) |
|||
|
|||
ChangeLog |
|||
--------- |
|||
|
|||
2012-04-10 Added Cyrillic glyphs for Orok, Khanty, Nenets (in Unicode |
|||
pipeline) |
|||
2012-04-07 Improved AE ligature and U+A78D; added a few glyphs with |
|||
diacritics. |
|||
2011-09-24 Added a few African Latin glyphs; improved Cyrillic breve; major |
|||
spacing improvements in italics; improved TTF hints. |
|||
2010-08-31 Further refinements of Vietnamese range in all faces. |
|||
2010-08-04 Added several obscure African letters. Corrected some stacked |
|||
diacritics. Corrected proposed codepoint for H with hook. |
|||
2010-06-23 Added modern Hebrew and Greek ranges |
|||
2010-06-17 Added all anchors needed for diacritic attachment for |
|||
Pan-African to upright fonts; italic fonts are by nature unsuitable |
|||
for Pan-African due to stylistic clashes (e.g. between a and alpha). |
|||
Improved lowercase thorn in all fonts. Added dropped umlaut on A, O |
|||
and U in upright fonts, accessible as ss01. |
|||
2010-06-04 Finished up requirements for Pan-African Alphabet; |
|||
improved Vietnamese italic & bold-italic |
|||
2010-04-23 Completed support for all Cyrillic codepoints for modern |
|||
orthographies. |
|||
2010-04-14 More glyphs: African, modern Pinyin, Amerindian |
|||
2010-04-12 Moved non-Unicode glyphs to PUA; added a few more African |
|||
glyphs. |
|||
2010-04-06 Diacritic improvement in Bold Vietnamese. Additional glyphs |
|||
for Skolt Sami, the Pan-Nigerian Alphabet, and various other |
|||
African languages. |
|||
2010-03-31 Further spacing enhancements in non-italic. Improvements in |
|||
Vietnamese range in Medium to prevent excessive diacritic |
|||
height. Spacing improvements in italic ligatures. |
|||
2009-09-18 Major overhaul of spacing in non-italic |
|||
2009-08-06 Added Vietnamese range. |
|||
2009-07-30 Kerned Latin ranges. |
|||
2009-07-29 Added Cyrillic range. |
|||
2009-07-24 Initial release |
|||
|
|||
|
|||
Information for Contributors |
|||
---------------------------- |
|||
|
|||
This font is licensed under the Open Font License (OFL). There is no Reserved |
|||
Name clause for the Pfennig font, enabling the free conversion between font |
|||
formats. |
|||
|
|||
You can read more about the OFL here: |
|||
http://scripts.sil.org/OFL |
|||
|
|||
If you'd like to make changes to the original font, you are free to contact |
|||
the author of the original font (for contact information, please see the |
|||
"Contributors" section below). Glyph changes should be in a FontForge .sfd |
|||
file (please make sure your version of FontForge is reasonably up-to-date). |
|||
Please send *only* the changed glyphs, not the entire font range. The author |
|||
reserves the right to reject or modify any contributions. If your contribution |
|||
is accepted, your name will appear in the Contributors section (unless you |
|||
specify otherwise). |
|||
|
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
Daniel Johnson (font maintainer) |
|||
il.basso.buffo at gmail dot com |
@ -0,0 +1,93 @@ |
|||
Copyright (c) 2009 - 2012 Daniel Johnson (<il.basso.buffo@gmail.com>). |
|||
|
|||
This Font Software is licensed under the SIL Open Font License, Version 1.1. |
|||
This license is copied below, and is also available with a FAQ at: |
|||
http://scripts.sil.org/OFL |
|||
|
|||
|
|||
----------------------------------------------------------- |
|||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 |
|||
----------------------------------------------------------- |
|||
|
|||
PREAMBLE |
|||
The goals of the Open Font License (OFL) are to stimulate worldwide |
|||
development of collaborative font projects, to support the font creation |
|||
efforts of academic and linguistic communities, and to provide a free and |
|||
open framework in which fonts may be shared and improved in partnership |
|||
with others. |
|||
|
|||
The OFL allows the licensed fonts to be used, studied, modified and |
|||
redistributed freely as long as they are not sold by themselves. The |
|||
fonts, including any derivative works, can be bundled, embedded, |
|||
redistributed and/or sold with any software provided that any reserved |
|||
names are not used by derivative works. The fonts and derivatives, |
|||
however, cannot be released under any other type of license. The |
|||
requirement for fonts to remain under this license does not apply |
|||
to any document created using the fonts or their derivatives. |
|||
|
|||
DEFINITIONS |
|||
"Font Software" refers to the set of files released by the Copyright |
|||
Holder(s) under this license and clearly marked as such. This may |
|||
include source files, build scripts and documentation. |
|||
|
|||
"Reserved Font Name" refers to any names specified as such after the |
|||
copyright statement(s). |
|||
|
|||
"Original Version" refers to the collection of Font Software components as |
|||
distributed by the Copyright Holder(s). |
|||
|
|||
"Modified Version" refers to any derivative made by adding to, deleting, |
|||
or substituting -- in part or in whole -- any of the components of the |
|||
Original Version, by changing formats or by porting the Font Software to a |
|||
new environment. |
|||
|
|||
"Author" refers to any designer, engineer, programmer, technical |
|||
writer or other person who contributed to the Font Software. |
|||
|
|||
PERMISSION & CONDITIONS |
|||
Permission is hereby granted, free of charge, to any person obtaining |
|||
a copy of the Font Software, to use, study, copy, merge, embed, modify, |
|||
redistribute, and sell modified and unmodified copies of the Font |
|||
Software, subject to the following conditions: |
|||
|
|||
1) Neither the Font Software nor any of its individual components, |
|||
in Original or Modified Versions, may be sold by itself. |
|||
|
|||
2) Original or Modified Versions of the Font Software may be bundled, |
|||
redistributed and/or sold with any software, provided that each copy |
|||
contains the above copyright notice and this license. These can be |
|||
included either as stand-alone text files, human-readable headers or |
|||
in the appropriate machine-readable metadata fields within text or |
|||
binary files as long as those fields can be easily viewed by the user. |
|||
|
|||
3) No Modified Version of the Font Software may use the Reserved Font |
|||
Name(s) unless explicit written permission is granted by the corresponding |
|||
Copyright Holder. This restriction only applies to the primary font name as |
|||
presented to the users. |
|||
|
|||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font |
|||
Software shall not be used to promote, endorse or advertise any |
|||
Modified Version, except to acknowledge the contribution(s) of the |
|||
Copyright Holder(s) and the Author(s) or with their explicit written |
|||
permission. |
|||
|
|||
5) The Font Software, modified or unmodified, in part or in whole, |
|||
must be distributed entirely under this license, and must not be |
|||
distributed under any other license. The requirement for fonts to |
|||
remain under this license does not apply to any document created |
|||
using the Font Software. |
|||
|
|||
TERMINATION |
|||
This license becomes null and void if any of the above conditions are |
|||
not met. |
|||
|
|||
DISCLAIMER |
|||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF |
|||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
|||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE |
|||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL |
|||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM |
|||
OTHER DEALINGS IN THE FONT SOFTWARE. |
File diff suppressed because it is too large
Binary file not shown.
File diff suppressed because it is too large
Binary file not shown.
File diff suppressed because it is too large
Binary file not shown.
File diff suppressed because it is too large
Binary file not shown.
@ -0,0 +1,99 @@ |
|||
//
|
|||
// FontFace.cc
|
|||
//
|
|||
// Copyright (c) 2012 Julian Viereck <julian.viereck@gmail.com>
|
|||
//
|
|||
|
|||
#include "FontFace.h" |
|||
|
|||
Persistent<FunctionTemplate> FontFace::constructor; |
|||
|
|||
/*
|
|||
* Destroy ft_face. |
|||
*/ |
|||
|
|||
FontFace::~FontFace() { |
|||
// Decrement extra reference count added in ::New(...).
|
|||
// Once there is no reference left to crFace, cairo will release the
|
|||
// free type font face as well.
|
|||
cairo_font_face_destroy (_crFace); |
|||
} |
|||
|
|||
/*
|
|||
* Initialize FontFace. |
|||
*/ |
|||
|
|||
void |
|||
FontFace::Initialize(Handle<Object> target) { |
|||
HandleScope scope; |
|||
|
|||
// Constructor
|
|||
constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(FontFace::New)); |
|||
constructor->InstanceTemplate()->SetInternalFieldCount(1); |
|||
constructor->SetClassName(String::NewSymbol("FontFace")); |
|||
|
|||
// Prototype
|
|||
target->Set(String::NewSymbol("FontFace"), constructor->GetFunction()); |
|||
} |
|||
|
|||
/*
|
|||
* Initialize a new FontFace object. |
|||
*/ |
|||
|
|||
FT_Library library; /* handle to library */ |
|||
|
|||
bool FontFace::_initLibrary = true; |
|||
static cairo_user_data_key_t key; |
|||
|
|||
Handle<Value> |
|||
FontFace::New(const Arguments &args) { |
|||
HandleScope scope; |
|||
|
|||
if (!args[0]->IsString() |
|||
|| !args[1]->IsNumber()) |
|||
{ |
|||
return ThrowException(Exception::Error(String::New("Wrong argument types passed to FontFace constructor"))); |
|||
} |
|||
|
|||
String::AsciiValue filePath(args[0]); |
|||
int faceIdx = int(args[1]->NumberValue()); |
|||
|
|||
FT_Face ftFace; |
|||
FT_Error ftError; |
|||
cairo_font_face_t *crFace; |
|||
|
|||
if (_initLibrary) { |
|||
_initLibrary = false; |
|||
ftError = FT_Init_FreeType(&library); |
|||
if (ftError) { |
|||
return ThrowException(Exception::Error(String::New("Could not load library"))); |
|||
} |
|||
} |
|||
|
|||
// Create new freetype font face.
|
|||
ftError = FT_New_Face(library, *filePath, faceIdx, &ftFace); |
|||
if (ftError) { |
|||
return ThrowException(Exception::Error(String::New("Could not load font file"))); |
|||
} |
|||
|
|||
// Create new cairo font face.
|
|||
crFace = cairo_ft_font_face_create_for_ft_face(ftFace, 0); |
|||
|
|||
// If the cairo font face is released, release the FreeType font face as well.
|
|||
int status = cairo_font_face_set_user_data (crFace, &key, |
|||
ftFace, (cairo_destroy_func_t) FT_Done_Face); |
|||
if (status) { |
|||
cairo_font_face_destroy (crFace); |
|||
FT_Done_Face (ftFace); |
|||
return ThrowException(Exception::Error(String::New("Failed to setup cairo font face user data"))); |
|||
} |
|||
|
|||
// Explicit reference count the cairo font face. Otherwise the font face might
|
|||
// get released by cairo although the JS font face object is still alive.
|
|||
cairo_font_face_reference(crFace); |
|||
|
|||
FontFace *face = new FontFace(ftFace, crFace); |
|||
face->Wrap(args.This()); |
|||
return args.This(); |
|||
} |
|||
|
@ -0,0 +1,33 @@ |
|||
//
|
|||
// FontFace.h
|
|||
//
|
|||
// Copyright (c) 2012 Julian Viereck <julian.viereck@gmail.com>
|
|||
//
|
|||
|
|||
#ifndef __NODE_TRUE_TYPE_FONT_FACE_H__ |
|||
#define __NODE_TRUE_TYPE_FONT_FACE_H__ |
|||
|
|||
#include "Canvas.h" |
|||
|
|||
#include <ft2build.h> |
|||
#include <cairo-ft.h> |
|||
#include FT_FREETYPE_H |
|||
|
|||
class FontFace: public node::ObjectWrap { |
|||
public: |
|||
static Persistent<FunctionTemplate> constructor; |
|||
static void Initialize(Handle<Object> target); |
|||
static Handle<Value> New(const Arguments &args); |
|||
FontFace(FT_Face ftFace, cairo_font_face_t *crFace) |
|||
:_ftFace(ftFace), _crFace(crFace) {} |
|||
|
|||
inline cairo_font_face_t *cairoFace(){ return _crFace; } |
|||
private: |
|||
~FontFace(); |
|||
FT_Face _ftFace; |
|||
cairo_font_face_t *_crFace; |
|||
static bool _initLibrary; |
|||
}; |
|||
|
|||
#endif |
|||
|
@ -0,0 +1,13 @@ |
|||
#!/usr/bin/env bash |
|||
has_cairo_freetyep() { |
|||
pkg-config cairo --cflags-only-I | grep -E "freetype2" && return 0 |
|||
|
|||
return 1; |
|||
} |
|||
|
|||
has_cairo_freetyep $1 > /dev/null |
|||
if test $? -eq 0; then |
|||
echo true |
|||
else |
|||
echo false |
|||
fi |
Loading…
Reference in new issue