Beispiel #1
0
/**
 * cairo_quartz_font_face_create_for_cgfont
 * @font: a #CGFontRef obtained through a method external to cairo.
 *
 * Creates a new font for the Quartz font backend based on a
 * #CGFontRef.  This font can then be used with
 * cairo_set_font_face() or cairo_scaled_font_create().
 *
 * Return value: a newly created #cairo_font_face_t. Free with
 *  cairo_font_face_destroy() when you are done using it.
 *
 * Since: 1.6
 */
cairo_font_face_t *
cairo_quartz_font_face_create_for_cgfont (CGFontRef font)
{
    cairo_quartz_font_face_t *font_face;

    quartz_font_ensure_symbols();

    font_face = malloc (sizeof (cairo_quartz_font_face_t));
    if (!font_face) {
	cairo_status_t ignore_status;
	ignore_status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
	return (cairo_font_face_t *)&_cairo_font_face_nil;
    }

    font_face->cgFont = CGFontRetain (font);

    if (CTFontCreateWithGraphicsFontPtr) {
        font_face->ctFont = CTFontCreateWithGraphicsFontPtr (font, 1.0, NULL, NULL);
    } else {
        font_face->ctFont = NULL;
    }

    _cairo_font_face_init (&font_face->base, &_cairo_quartz_font_face_backend);

    return &font_face->base;
}
SFFontRef SFFontMakeCloneForCGFont(SFFontRef sfFont, CGFontRef cgFont, SFFloat size) {
    SFFont *clone = malloc(sizeof(SFFont));
    clone->_cgFont = CGFontRetain(cgFont);
    clone->_tables = SFFontTablesRetain(sfFont->_tables);
    clone->_retainCount = 1;

    setFontSize(clone, size);
    
    return clone;
}
SFFontRef SFFontCreateWithCGFont(CGFontRef cgFont, SFFloat size) {
    SFFont *sfFont = malloc(sizeof(SFFont));
    sfFont->_cgFont = CGFontRetain(cgFont);
    sfFont->_tables = SFFontTablesCreate();
    sfFont->_retainCount = 1;

    setFontSize(sfFont, size);
    
    return sfFont;
}
Beispiel #4
0
SFFontRef SFFontCreate(CGFontRef cgFont, CGFloat size) {
    SFFont *sfFont = malloc(sizeof(SFFont));
    
    sfFont->_cgFont = CGFontRetain(cgFont);
    sfFont->_availableFontTables = 0;
    sfFont->_retainCount = 1;
    
    setFontSize(sfFont, size);
    
    return sfFont;
}
Beispiel #5
0
ScaledFontMac::ScaledFontMac(CGFontRef aFont, Float aSize)
  : ScaledFontBase(aSize)
{
  if (!sSymbolLookupDone) {
    CTFontDrawGlyphsPtr =
      (CTFontDrawGlyphsFuncT*)dlsym(RTLD_DEFAULT, "CTFontDrawGlyphs");
    sSymbolLookupDone = true;
  }

  // XXX: should we be taking a reference
  mFont = CGFontRetain(aFont);
  if (CTFontDrawGlyphsPtr != nullptr) {
    // only create mCTFont if we're going to be using the CTFontDrawGlyphs API
    mCTFont = CTFontCreateWithGraphicsFont(aFont, aSize, nullptr, nullptr);
  } else {
    mCTFont = nullptr;
  }
}
/**
 * cairo_quartz_font_face_create_for_cgfont
 * @font: a #CGFontRef obtained through a method external to cairo.
 *
 * Creates a new font for the Quartz font backend based on a
 * #CGFontRef.  This font can then be used with
 * cairo_set_font_face() or cairo_scaled_font_create().
 *
 * Return value: a newly created #cairo_font_face_t. Free with
 *  cairo_font_face_destroy() when you are done using it.
 *
 * Since: 1.6
 */
cairo_font_face_t *
cairo_quartz_font_face_create_for_cgfont (CGFontRef font)
{
    cairo_quartz_font_face_t *font_face;

    quartz_font_ensure_symbols();

    font_face = malloc (sizeof (cairo_quartz_font_face_t));
    if (!font_face) {
	_cairo_error (CAIRO_STATUS_NO_MEMORY);
	return (cairo_font_face_t *)&_cairo_font_face_nil;
    }

    font_face->cgFont = CGFontRetain (font);

    _cairo_font_face_init (&font_face->base, &_cairo_quartz_font_face_backend);

    return &font_face->base;
}
ScaledFontMac::ScaledFontMac(CGFontRef aFont, Float aSize)
  : ScaledFontBase(aSize)
{
  // XXX: should we be taking a reference
  mFont = CGFontRetain(aFont);
}