Skip to content
Browse files

Working version

  • Loading branch information...
1 parent 2d0eb0c commit bd01e8d0dc03075d677aef71c10fce5e67828f8f @jviereck committed Jun 24, 2012
Showing with 14 additions and 12 deletions.
  1. +13 −11 src/CanvasRenderingContext2d.cc
  2. +1 −1 src/CanvasRenderingContext2d.h
View
24 src/CanvasRenderingContext2d.cc
@@ -1625,20 +1625,20 @@ Context2d::PrepareTrueTypeFace(const Arguments &args) {
return ThrowException(Exception::TypeError(String::New("TrueTypeFontFace expected")));
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
+ cairo_t *ctx = context->context();
cairo_font_face_t *cr_face;
TrueTypeFontFace *face = ObjectWrap::Unwrap<TrueTypeFontFace>(obj);
cr_face = cairo_ft_font_face_create_for_ft_face(face->face, 0);
- cairo_set_font_face(ctx, cr_face);
-
- vector<cairo_font_face_t*> font_faces = context->font_faces();
- font_faces.insert(font_faces.end(), cr_face);
+ vector<cairo_font_face_t*> *font_faces = context->font_faces();
+ font_faces->insert(font_faces->end(), cr_face);
- printf("=== PrepareTrueTypeFace %p %p %d\n", context, &font_faces, int(font_faces.size()));
+ cairo_set_font_face(ctx, cr_face);
+ printf("=== PrepareTrueTypeFace %p %p %d\n", context, font_faces, int(font_faces->size()));
- return scope.Close(Number::New(font_faces.size() - 1));
+ return scope.Close(Number::New(font_faces->size() - 1));
}
Handle<Value>
@@ -1655,18 +1655,20 @@ Context2d::SetFontFace(const Arguments &args) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->context();
- vector<cairo_font_face_t*> font_faces = context->font_faces();
+ vector<cairo_font_face_t*> *font_faces = context->font_faces();
- printf("_setFontFace %p %p %d %d\n", context, &font_faces, int(font_faces.size()), idx);
+ printf("_setFontFace %p %p %d %d\n", context, font_faces, int(font_faces->size()), idx);
- if (idx > int(font_faces.size()) || idx < 0)
+ if (idx >= int(font_faces->size()) || idx < 0)
return ThrowException(Exception::TypeError(String::New("Try to get element out of bound")));
cairo_set_font_size(ctx, size);
- printf("_setFontFace::2 %p\n", font_faces[idx]);
+ printf("_setFontFace::4\n");
+
+ printf("_setFontFace::2 %p\n", font_faces->at(idx));
- cairo_set_font_face(ctx, font_faces[idx]);
+ cairo_set_font_face(ctx, font_faces->at(idx));
printf("_setFontFace::3\n");
View
2 src/CanvasRenderingContext2d.h
@@ -128,7 +128,7 @@ class Context2d: public node::ObjectWrap {
inline void setContext(cairo_t *ctx) { _context = ctx; }
inline cairo_t *context(){ return _context; }
inline Canvas *canvas(){ return _canvas; }
- inline vector<cairo_font_face_t*> font_faces(){ return _font_faces; }
+ inline vector<cairo_font_face_t*> *font_faces(){ return &_font_faces; }
inline bool hasShadow();
void inline setSourceRGBA(rgba_t color);
void setTextPath(const char *str, double x, double y);

0 comments on commit bd01e8d

Please sign in to comment.
Something went wrong with that request. Please try again.