value lime_cairo_get_font_face (value handle) { cairo_font_face_t* face = cairo_get_font_face ((cairo_t*)val_data (handle)); cairo_font_face_reference (face); return CFFIPointer (face, gc_cairo_font_face); }
//FIXME should not be exposed to the user of the language binding, //FIXME but rather used to implement memory management within the language binding // cairo_public cairo_font_face_t * // cairo_font_face_reference (cairo_font_face_t *font_face); static int l_cairo_font_face_reference(lua_State* L) { cairo_font_face_t *font_face = get_cairo_font_face_t (L, 1); cairo_font_face_t *v = cairo_font_face_reference (font_face); lua_pushlightuserdata(L, v); return 1; }
cairo_status_t _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font, cairo_font_face_t *font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options, const cairo_scaled_font_backend_t *backend) { scaled_font->ref_count = 1; _cairo_scaled_font_init_key (scaled_font, font_face, font_matrix, ctm, options); cairo_font_face_reference (font_face); cairo_matrix_multiply (&scaled_font->scale, &scaled_font->font_matrix, &scaled_font->ctm); scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal, _cairo_scaled_glyph_destroy, 256); scaled_font->surface_backend = NULL; scaled_font->surface_private = NULL; scaled_font->backend = backend; return CAIRO_STATUS_SUCCESS; }
static PyObject * pycairo_get_font_face (PycairoContext *o) { cairo_font_face_t *font_face = cairo_get_font_face (o->ctx); cairo_font_face_reference (font_face); return PycairoFontFace_FromFontFace (font_face); }
FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other) { // Check for self-assignment. if (this == &other) return *this; m_font = other.m_font; m_size = other.m_size; m_syntheticBold = other.m_syntheticBold; m_syntheticOblique = other.m_syntheticOblique; m_useGDI = other.m_useGDI; if (other.m_fontFace) cairo_font_face_reference(other.m_fontFace); if (m_fontFace) cairo_font_face_destroy(m_fontFace); m_fontFace = other.m_fontFace; if (other.m_scaledFont) cairo_scaled_font_reference(other.m_scaledFont); if (m_scaledFont) cairo_scaled_font_destroy(m_scaledFont); m_scaledFont = other.m_scaledFont; return *this; }
VALUE rb_cairo_font_face_to_ruby_object (cairo_font_face_t *face) { if (face) { VALUE klass; switch (cairo_font_face_get_type (face)) { #ifdef CAIRO_HAS_FT_FONT case CAIRO_FONT_TYPE_FT: klass = rb_cCairo_FreeTypeFontFace; break; #endif #if CAIRO_CHECK_VERSION(1, 7, 6) case CAIRO_FONT_TYPE_TOY: klass = rb_cCairo_ToyFontFace; break; case CAIRO_FONT_TYPE_USER: klass = rb_cCairo_UserFontFace; break; #endif default: klass = rb_cCairo_FontFace; break; } cairo_font_face_reference (face); return Data_Wrap_Struct (klass, NULL, cr_font_face_free, face); } else { return Qnil; } }
SkCairoFTTypeface(cairo_font_face_t* fontFace, const SkFontStyle& style, SkFontID id, bool isFixedWidth) : SkTypeface(style, id, isFixedWidth) , fFontFace(fontFace) { cairo_font_face_set_user_data(fFontFace, &kSkTypefaceKey, this, NULL); cairo_font_face_reference(fFontFace); }
IoCairoFontFace *IoCairoFontFace_rawClone(IoCairoFontFace *proto) { IoObject *self = IoObject_rawClonePrimitive(proto); if (FACE(proto)) IoObject_setDataPointer_(self, cairo_font_face_reference(FACE(proto))); return self; }
static PyObject * scaled_font_get_font_face (PycairoScaledFont *o) { return PycairoFontFace_FromFontFace ( cairo_font_face_reference ( cairo_scaled_font_get_font_face (o->scaled_font))); }
static int cr_get_font_face (lua_State *L) { cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT); cairo_font_face_t **face = create_fontface_userdata(L); *face = cairo_get_font_face(*obj); cairo_font_face_reference(*face); return 1; }
void drawContextFltkCairo::drawString(const char *str) { GLfloat pos[4], color[4]; glGetFloatv(GL_CURRENT_RASTER_POSITION, pos); glGetFloatv(GL_CURRENT_COLOR, color); cairo_set_font_size(_cr, _currentFontSize); cairo_text_extents_t extent; cairo_text_extents(_cr, str, &extent); queueString::element elem = {str, pos[0], pos[1], pos[2], color[0], color[1], color[2], color[3], _currentFontSize, cairo_get_font_face(_cr), (int)ceil(extent.width) + 2, (int)ceil(extent.height) + 2, extent.x_bearing - 1, extent.y_bearing - 1}; cairo_font_face_reference(elem.fontFace); _queue->append(elem); }
SkCairoFTTypeface(const SkFontStyle& style, SkFontID id, bool isFixedWidth, cairo_font_face_t* fontFace, FcPattern* pattern) : SkTypeface(style, id, isFixedWidth) , fFontFace(fontFace) , fPattern(pattern) { cairo_font_face_set_user_data(fFontFace, &kSkTypefaceKey, this, nullptr); cairo_font_face_reference(fFontFace); #ifdef CAIRO_HAS_FC_FONT if (fPattern) { FcPatternReference(fPattern); } #endif }
/** * _cairo_toy_font_face_create: * @family: a font family name, encoded in UTF-8 * @slant: the slant for the font * @weight: the weight for the font * * Creates a font face from a triplet of family, slant, and weight. * These font faces are used in implementation of the the #cairo_t "toy" * font API. * * Return value: a newly created #cairo_font_face_t, destroy with * cairo_font_face_destroy() **/ cairo_font_face_t * _cairo_toy_font_face_create (const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight) { cairo_status_t status; cairo_toy_font_face_t key, *font_face; cairo_hash_table_t *hash_table; hash_table = _cairo_toy_font_face_hash_table_lock (); if (hash_table == NULL) goto UNWIND; _cairo_toy_font_face_init_key (&key, family, slant, weight); /* Return existing font_face if it exists in the hash table. */ if (_cairo_hash_table_lookup (hash_table, &key.base.hash_entry, (cairo_hash_entry_t **) &font_face)) { _cairo_toy_font_face_hash_table_unlock (); return cairo_font_face_reference (&font_face->base); } /* Otherwise create it and insert into hash table. */ font_face = malloc (sizeof (cairo_toy_font_face_t)); if (font_face == NULL) goto UNWIND_HASH_TABLE_LOCK; status = _cairo_toy_font_face_init (font_face, family, slant, weight); if (status) goto UNWIND_FONT_FACE_MALLOC; status = _cairo_hash_table_insert (hash_table, &font_face->base.hash_entry); if (status) goto UNWIND_FONT_FACE_INIT; _cairo_toy_font_face_hash_table_unlock (); return &font_face->base; UNWIND_FONT_FACE_INIT: UNWIND_FONT_FACE_MALLOC: free (font_face); UNWIND_HASH_TABLE_LOCK: _cairo_toy_font_face_hash_table_unlock (); UNWIND: return (cairo_font_face_t*) &_cairo_font_face_nil; }
FontPlatformData::FontPlatformData(const FontPlatformData& source) : m_font(source.m_font) , m_size(source.m_size) , m_fontFace(0) , m_scaledFont(0) , m_syntheticBold(source.m_syntheticBold) , m_syntheticOblique(source.m_syntheticOblique) , m_useGDI(source.m_useGDI) { if (source.m_fontFace) m_fontFace = cairo_font_face_reference(source.m_fontFace); if (source.m_scaledFont) m_scaledFont = cairo_scaled_font_reference(source.m_scaledFont); }
void _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font, cairo_font_face_t *font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options, const cairo_scaled_font_backend_t *backend) { scaled_font->ref_count = 1; _cairo_scaled_font_init_key (scaled_font, font_face, font_matrix, ctm, options); cairo_font_face_reference (font_face); cairo_matrix_multiply (&scaled_font->scale, &scaled_font->font_matrix, &scaled_font->ctm); scaled_font->backend = backend; }
static cairo_font_face_t * _cairo_toy_font_face_get_implementation (void *abstract_font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options) { cairo_toy_font_face_t *font_face = abstract_font_face; if (font_face->impl_face) { cairo_font_face_t *impl = font_face->impl_face; if (impl->backend->get_implementation != NULL) { return impl->backend->get_implementation (impl, font_matrix, ctm, options); } return cairo_font_face_reference (impl); } return abstract_font_face; }
void lime_cairo_font_face_reference (double handle) { cairo_font_face_reference ((cairo_font_face_t*)(intptr_t)handle); }
/** * cairo_toy_font_face_create: * @family: a font family name, encoded in UTF-8 * @slant: the slant for the font * @weight: the weight for the font * * Creates a font face from a triplet of family, slant, and weight. * These font faces are used in implementation of the the #cairo_t "toy" * font API. * * If @family is the zero-length string "", the platform-specific default * family is assumed. The default family then can be queried using * cairo_toy_font_face_get_family(). * * The cairo_select_font_face() function uses this to create font faces. * See that function for limitations and other details of toy font faces. * * Return value: a newly created #cairo_font_face_t. Free with * cairo_font_face_destroy() when you are done using it. * * Since: 1.8 **/ cairo_font_face_t * cairo_toy_font_face_create (const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight) { cairo_status_t status; cairo_toy_font_face_t key, *font_face; cairo_hash_table_t *hash_table; if (family == NULL) return (cairo_font_face_t*) &_cairo_font_face_null_pointer; /* Make sure we've got valid UTF-8 for the family */ status = _cairo_utf8_to_ucs4 (family, -1, NULL, NULL); if (unlikely (status)) { if (status == CAIRO_STATUS_INVALID_STRING) return (cairo_font_face_t*) &_cairo_font_face_invalid_string; return (cairo_font_face_t*) &_cairo_font_face_nil; } switch (slant) { case CAIRO_FONT_SLANT_NORMAL: case CAIRO_FONT_SLANT_ITALIC: case CAIRO_FONT_SLANT_OBLIQUE: break; default: return (cairo_font_face_t*) &_cairo_font_face_invalid_slant; } switch (weight) { case CAIRO_FONT_WEIGHT_NORMAL: case CAIRO_FONT_WEIGHT_BOLD: break; default: return (cairo_font_face_t*) &_cairo_font_face_invalid_weight; } if (*family == '\0') family = CAIRO_FONT_FAMILY_DEFAULT; hash_table = _cairo_toy_font_face_hash_table_lock (); if (unlikely (hash_table == NULL)) goto UNWIND; _cairo_toy_font_face_init_key (&key, family, slant, weight); /* Return existing font_face if it exists in the hash table. */ font_face = _cairo_hash_table_lookup (hash_table, &key.base.hash_entry); if (font_face != NULL) { if (font_face->base.status == CAIRO_STATUS_SUCCESS) { cairo_font_face_reference (&font_face->base); _cairo_toy_font_face_hash_table_unlock (); return &font_face->base; } /* remove the bad font from the hash table */ _cairo_hash_table_remove (hash_table, &font_face->base.hash_entry); } /* Otherwise create it and insert into hash table. */ font_face = _cairo_malloc (sizeof (cairo_toy_font_face_t)); if (unlikely (font_face == NULL)) { status = _cairo_error (CAIRO_STATUS_NO_MEMORY); goto UNWIND_HASH_TABLE_LOCK; } status = _cairo_toy_font_face_init (font_face, family, slant, weight); if (unlikely (status)) goto UNWIND_FONT_FACE_MALLOC; assert (font_face->base.hash_entry.hash == key.base.hash_entry.hash); status = _cairo_hash_table_insert (hash_table, &font_face->base.hash_entry); if (unlikely (status)) goto UNWIND_FONT_FACE_INIT; _cairo_toy_font_face_hash_table_unlock (); return &font_face->base; UNWIND_FONT_FACE_INIT: _cairo_toy_font_face_fini (font_face); UNWIND_FONT_FACE_MALLOC: free (font_face); UNWIND_HASH_TABLE_LOCK: _cairo_toy_font_face_hash_table_unlock (); UNWIND: return (cairo_font_face_t*) &_cairo_font_face_nil; }
virtual void use() { cairo_set_font_face(m_cairo, cairo_font_face_reference(m_font_face)); }
static PyObject * pycairo_get_font_face (PycairoContext *o) { return PycairoFontFace_FromFontFace ( cairo_font_face_reference (cairo_get_font_face (o->ctx))); }