|
|
@ -16,7 +16,7 @@ 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); |
|
|
|
cairo_font_face_destroy(_crFace); |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
@ -45,21 +45,24 @@ FT_Library library; /* handle to library */ |
|
|
|
bool FontFace::_initLibrary = true; |
|
|
|
static cairo_user_data_key_t key; |
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize a new FontFace. |
|
|
|
*/ |
|
|
|
|
|
|
|
Handle<Value> |
|
|
|
FontFace::New(const Arguments &args) { |
|
|
|
HandleScope scope; |
|
|
|
|
|
|
|
if (!args[0]->IsString() |
|
|
|
|| !args[1]->IsNumber()) |
|
|
|
{ |
|
|
|
|| !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; |
|
|
|
FT_Face ftFace; |
|
|
|
FT_Error ftError; |
|
|
|
cairo_font_face_t *crFace; |
|
|
|
|
|
|
|
if (_initLibrary) { |
|
|
@ -83,9 +86,9 @@ FontFace::New(const Arguments &args) { |
|
|
|
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"))); |
|
|
|
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
|
|
|
|