diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index ad0e844..d427dac 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -1720,6 +1720,10 @@ Context2d::MoveTo(const Arguments &args) { return Undefined(); } +/* + * Set font face. + */ + #ifdef HAVE_FREETYPE Handle Context2d::SetFontFace(const Arguments &args) { @@ -1735,7 +1739,6 @@ Context2d::SetFontFace(const Arguments &args) { if (!FontFace::constructor->HasInstance(obj)) return ThrowException(Exception::TypeError(String::New("FontFace expected"))); - FontFace *face = ObjectWrap::Unwrap(obj); double size = args[1]->NumberValue(); diff --git a/src/FontFace.cc b/src/FontFace.cc index 293bece..c359069 100644 --- a/src/FontFace.cc +++ b/src/FontFace.cc @@ -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 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