Beispiel #1
0
static cairo_status_t
_user_font_face_create (cairo_font_face_t **out)
{
    cairo_font_face_t *user_font_face;
    cairo_font_face_t *fallback_font_face;
    cairo_status_t status;

    user_font_face = cairo_user_font_face_create ();
    cairo_user_font_face_set_init_func             (user_font_face, test_scaled_font_init);
    cairo_user_font_face_set_render_glyph_func     (user_font_face, test_scaled_font_render_glyph);
    cairo_user_font_face_set_text_to_glyphs_func   (user_font_face, test_scaled_font_text_to_glyphs);

    /* This also happens to be default font face on cairo_t, so does
     * not make much sense here.  For demonstration only.
     */
    fallback_font_face = cairo_toy_font_face_create ("",
						     CAIRO_FONT_SLANT_NORMAL,
						     CAIRO_FONT_WEIGHT_NORMAL);

    status = cairo_font_face_set_user_data (user_font_face,
					    &fallback_font_key,
					    fallback_font_face,
					    (cairo_destroy_func_t) cairo_font_face_destroy);
    if (status) {
	cairo_font_face_destroy (fallback_font_face);
	cairo_font_face_destroy (user_font_face);
	return status;
    }

    *out = user_font_face;
    return CAIRO_STATUS_SUCCESS;
}
Beispiel #2
0
static cairo_status_t
_user_font_face_create (cairo_font_face_t **out)
{
    static const test_scaled_font_glyph_t glyphs [] = {
	{ 'c',  6, { 0x00, 0x38, 0x44, 0x80, 0x80, 0x80, 0x44, 0x38 } },
	{ 'a',  6, { 0x00, 0x70, 0x88, 0x3c, 0x44, 0x84, 0x8c, 0x74 } },
	{ 'i',  1, { 0x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 } },
	{ 'r',  6, { 0x00, 0xb8, 0xc4, 0x80, 0x80, 0x80, 0x80, 0x80 } },
	{ 'o',  7, { 0x00, 0x38, 0x44, 0x82, 0x82, 0x82, 0x44, 0x38 } },
	{  -1,  8, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
    };

    cairo_font_face_t *user_font_face;
    cairo_status_t status;

    user_font_face = cairo_user_font_face_create ();
    cairo_user_font_face_set_init_func             (user_font_face, test_scaled_font_init);
    cairo_user_font_face_set_render_glyph_func     (user_font_face, test_scaled_font_render_glyph);
    cairo_user_font_face_set_unicode_to_glyph_func (user_font_face, test_scaled_font_unicode_to_glyph);

    status = cairo_font_face_set_user_data (user_font_face,
					    &test_font_face_glyphs_key,
					    (void*) glyphs, NULL);
    if (status) {
	cairo_font_face_destroy (user_font_face);
	return status;
    }

    *out = user_font_face;
    return CAIRO_STATUS_SUCCESS;
}
Beispiel #3
0
static cairo_font_face_t *
get_user_font_face (void)
{
    if (!user_font_face) {
	cairo_font_face_t *fallback_font_face;

	user_font_face = cairo_user_font_face_create ();
	cairo_user_font_face_set_init_func             (user_font_face, test_scaled_font_init);
	cairo_user_font_face_set_render_glyph_func     (user_font_face, test_scaled_font_render_glyph);
	cairo_user_font_face_set_text_to_glyphs_func   (user_font_face, test_scaled_font_text_to_glyphs);

	/* This also happens to be default font face on cairo_t, so does
	 * not make much sense here.  For demonstration only.
	 */
	fallback_font_face = cairo_toy_font_face_create ("",
							 CAIRO_FONT_SLANT_NORMAL,
							 CAIRO_FONT_WEIGHT_NORMAL);

	cairo_font_face_set_user_data (user_font_face,
				       &fallback_font_key,
				       fallback_font_face,
				       (cairo_destroy_func_t) cairo_font_face_destroy);
    }

    return user_font_face;
}
Beispiel #4
0
static VALUE
cr_user_font_face_initialize (VALUE self)
{
  cairo_font_face_t *face;

  face = cairo_user_font_face_create ();
  cr_font_face_check_status (face);

  cairo_font_face_set_user_data (face, &ruby_object_key, (void *)self, NULL);

  cairo_user_font_face_set_init_func
    (face, cr_user_font_face_init_func);
  cairo_user_font_face_set_render_glyph_func
    (face, cr_user_font_face_render_glyph_func);
  cairo_user_font_face_set_text_to_glyphs_func
    (face, cr_user_font_face_text_to_glyphs_func);
  cairo_user_font_face_set_unicode_to_glyph_func
    (face, cr_user_font_face_unicode_to_glyph_func);

  rb_ivar_set (self, cr_id_init, Qnil);
  rb_ivar_set (self, cr_id_render_glyph, Qnil);
  rb_ivar_set (self, cr_id_text_to_glyphs, Qnil);
  rb_ivar_set (self, cr_id_unicode_to_glyph, Qnil);

  DATA_PTR (self) = face;

  return Qnil;
}
Beispiel #5
0
UserFont::UserFont(SvgFont* instance){
    this->face = cairo_user_font_face_create ();
    cairo_user_font_face_set_init_func          (this->face, font_init_cb);
    cairo_user_font_face_set_render_glyph_func  (this->face, font_render_glyph_cb);
    cairo_user_font_face_set_text_to_glyphs_func(this->face, font_text_to_glyphs_cb);

    cairo_font_face_set_user_data (this->face, &key, (void*)instance, (cairo_destroy_func_t) NULL);
}
static int new_UserFontFace (lua_State *L)
{
    lua_remove(L, 1); // remove cairo.UserFontFace

    cairo_font_face_t *ff = cairo_user_font_face_create ();

    return new_FontFace(L, LUACAIRO ".UserFontFace.mt", ff, CAIRO_FONT_TYPE_USER, 1);
}
Beispiel #7
0
static cairo_font_face_t *
_cairo_font_face_twin_create_internal (void)
{
    cairo_font_face_t *twin_font_face;

    twin_font_face = cairo_user_font_face_create ();
    cairo_user_font_face_set_init_func             (twin_font_face, twin_scaled_font_init);
    cairo_user_font_face_set_render_glyph_func     (twin_font_face, twin_scaled_font_render_glyph);
    cairo_user_font_face_set_unicode_to_glyph_func (twin_font_face, twin_scaled_font_unicode_to_glyph);

    return twin_font_face;
}
Beispiel #8
0
cairo_font_face_t *
_cairo_font_face_twin_create (cairo_font_slant_t slant,
			      cairo_font_weight_t weight)
{
    cairo_font_face_t *twin_font_face;

    twin_font_face = cairo_user_font_face_create ();
    cairo_user_font_face_set_init_func             (twin_font_face, twin_scaled_font_init);
    cairo_user_font_face_set_render_glyph_func     (twin_font_face, twin_scaled_font_render_glyph);
    cairo_user_font_face_set_unicode_to_glyph_func (twin_font_face, twin_scaled_font_unicode_to_glyph);

    return twin_font_face;
}
cairo_status_t
_cairo_font_face_twin_create_for_toy (cairo_toy_font_face_t   *toy_face,
				      cairo_font_face_t      **font_face)
{
    cairo_status_t status;
    cairo_font_face_t *twin_font_face;

    twin_font_face = cairo_user_font_face_create ();
    cairo_user_font_face_set_init_func             (twin_font_face, twin_scaled_font_init);
    cairo_user_font_face_set_render_glyph_func     (twin_font_face, twin_scaled_font_render_glyph);
    cairo_user_font_face_set_unicode_to_glyph_func (twin_font_face, twin_scaled_font_unicode_to_glyph);
    status = twin_font_face_set_properties_from_toy (twin_font_face, toy_face);
    if (status) {
	cairo_font_face_destroy (twin_font_face);
	return status;
    }

    *font_face = twin_font_face;

    return CAIRO_STATUS_SUCCESS;
}