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 Diff line number Diff line change
Expand Up @@ -1720,6 +1720,10 @@ Context2d::MoveTo(const Arguments &args) {
return Undefined();
}

/*
* Set font face.
*/

#ifdef HAVE_FREETYPE
Handle<Value>
Context2d::SetFontFace(const Arguments &args) {
Expand All @@ -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<FontFace>(obj);
double size = args[1]->NumberValue();

Expand Down
19 changes: 11 additions & 8 deletions src/FontFace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit ef897a2

Please sign in to comment.