Skip to content

Commit

Permalink
ocd
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jan 16, 2013
1 parent dce07d5 commit ef897a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/CanvasRenderingContext2d.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1720,6 +1720,10 @@ Context2d::MoveTo(const Arguments &args) {
return Undefined(); return Undefined();
} }


/*
* Set font face.
*/

#ifdef HAVE_FREETYPE #ifdef HAVE_FREETYPE
Handle<Value> Handle<Value>
Context2d::SetFontFace(const Arguments &args) { Context2d::SetFontFace(const Arguments &args) {
Expand All @@ -1735,7 +1739,6 @@ Context2d::SetFontFace(const Arguments &args) {
if (!FontFace::constructor->HasInstance(obj)) if (!FontFace::constructor->HasInstance(obj))
return ThrowException(Exception::TypeError(String::New("FontFace expected"))); return ThrowException(Exception::TypeError(String::New("FontFace expected")));



FontFace *face = ObjectWrap::Unwrap<FontFace>(obj); FontFace *face = ObjectWrap::Unwrap<FontFace>(obj);
double size = args[1]->NumberValue(); double size = args[1]->NumberValue();


Expand Down
19 changes: 11 additions & 8 deletions src/FontFace.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FontFace::~FontFace() {
// Decrement extra reference count added in ::New(...). // Decrement extra reference count added in ::New(...).
// Once there is no reference left to crFace, cairo will release the // Once there is no reference left to crFace, cairo will release the
// free type font face as well. // free type font face as well.
cairo_font_face_destroy (_crFace); cairo_font_face_destroy(_crFace);
} }


/* /*
Expand Down Expand Up @@ -45,21 +45,24 @@ FT_Library library; /* handle to library */
bool FontFace::_initLibrary = true; bool FontFace::_initLibrary = true;
static cairo_user_data_key_t key; static cairo_user_data_key_t key;


/*
* Initialize a new FontFace.
*/

Handle<Value> Handle<Value>
FontFace::New(const Arguments &args) { FontFace::New(const Arguments &args) {
HandleScope scope; HandleScope scope;


if (!args[0]->IsString() if (!args[0]->IsString()
|| !args[1]->IsNumber()) || !args[1]->IsNumber()) {
{
return ThrowException(Exception::Error(String::New("Wrong argument types passed to FontFace constructor"))); return ThrowException(Exception::Error(String::New("Wrong argument types passed to FontFace constructor")));
} }


String::AsciiValue filePath(args[0]); String::AsciiValue filePath(args[0]);
int faceIdx = int(args[1]->NumberValue()); int faceIdx = int(args[1]->NumberValue());


FT_Face ftFace; FT_Face ftFace;
FT_Error ftError; FT_Error ftError;
cairo_font_face_t *crFace; cairo_font_face_t *crFace;


if (_initLibrary) { if (_initLibrary) {
Expand All @@ -83,9 +86,9 @@ FontFace::New(const Arguments &args) {
int status = cairo_font_face_set_user_data (crFace, &key, int status = cairo_font_face_set_user_data (crFace, &key,
ftFace, (cairo_destroy_func_t) FT_Done_Face); ftFace, (cairo_destroy_func_t) FT_Done_Face);
if (status) { if (status) {
cairo_font_face_destroy (crFace); cairo_font_face_destroy (crFace);
FT_Done_Face (ftFace); FT_Done_Face (ftFace);
return ThrowException(Exception::Error(String::New("Failed to setup cairo font face user data"))); 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 // Explicit reference count the cairo font face. Otherwise the font face might
Expand Down

0 comments on commit ef897a2

Please sign in to comment.