Commit 2b23da97 authored by XueShuming's avatar XueShuming
Browse files

add code for destroy text_context

parent 81519ade
......@@ -179,11 +179,13 @@ typedef struct _HiSVGTextRectangle {
} HiSVGTextRectangle;
HiSVGTextContext* hisvg_text_context_create (double dpi, const char* language, HiSVGTextDirection* direction, HiSVGTextGravity* gravity);
void hisvg_text_context_destroy (HiSVGTextContext* context);
HiSVGTextGravity hisvg_text_context_get_gravity (HiSVGTextContext* context);
HiSVGTextContextLayout* hisvg_text_context_layout_create (HiSVGTextContext* context,
int letter_spacing, HiSVGTextAlignment alignment, const HiSVGFontDescription* desc,
int font_decoration, const char* text);
void hisvg_text_context_layout_destroy(HiSVGTextContextLayout* layout);
void hisvg_text_context_layout_get_size (HiSVGTextContextLayout* layout, int* width, int* height);
HiSVGTextContext* hisvg_text_layout_get_context (HiSVGTextContextLayout* layout);
......@@ -195,7 +197,7 @@ HiSVGFontDescription* hisvg_font_description_create (const char* type,
HiSVGTextWeight weight, HiSVGTextStretch stretch, gint size,
guint size_is_absolute
);
void hisvg_font_description_free (HiSVGFontDescription* desc);
void hisvg_font_description_destroy (HiSVGFontDescription* desc);
double hisvg_text_gravity_to_rotation (HiSVGTextGravity gravity);
......
......@@ -68,6 +68,12 @@ HiSVGTextContext* hisvg_text_context_create (double dpi, const char* language, H
return ctx;
}
void hisvg_text_context_destroy (HiSVGTextContext* context)
{
g_object_unref (context->pango_ctx);
free(context);
}
HiSVGTextGravity hisvg_text_context_get_gravity (HiSVGTextContext* context)
{
return pango_context_get_gravity (context->pango_ctx);
......@@ -129,6 +135,12 @@ HiSVGTextContextLayout* hisvg_text_context_layout_create (HiSVGTextContext* cont
return result;
}
void hisvg_text_context_layout_destroy(HiSVGTextContextLayout* layout)
{
g_object_unref (layout->pango_layout);
free(layout);
}
void hisvg_text_context_layout_get_size (HiSVGTextContextLayout* layout, int* width, int* height)
{
pango_layout_get_size (layout->pango_layout, width, height);
......@@ -157,7 +169,7 @@ HiSVGFontDescription* hisvg_font_description_create (const char* type,
return desc;
}
void hisvg_font_description_free (HiSVGFontDescription* desc)
void hisvg_font_description_destroy (HiSVGFontDescription* desc)
{
free(desc->type);
free(desc->family);
......@@ -192,7 +204,18 @@ void hisvg_text_context_layout_get_extents (HiSVGTextContextLayout* layout, HiSV
double hisvg_text_gravity_to_rotation (HiSVGTextGravity gravity)
{
return pango_gravity_to_rotation (gravity);
double rotation;
switch (gravity)
{
default:
case HISVG_TEXT_GRAVITY_AUTO: /* shut gcc up */
case HISVG_TEXT_GRAVITY_SOUTH: rotation = 0; break;
case HISVG_TEXT_GRAVITY_NORTH: rotation = G_PI; break;
case HISVG_TEXT_GRAVITY_EAST: rotation = -G_PI_2; break;
case HISVG_TEXT_GRAVITY_WEST: rotation = +G_PI_2; break;
}
return rotation;
}
void hisvg_cairo_update_text_context (cairo_t* cr, HiSVGTextContext* context)
......
......@@ -533,7 +533,7 @@ struct _HiSVGTextLayout {
static void
hisvg_text_layout_free (HiSVGTextLayout * layout)
{
g_object_unref (layout->layout);
hisvg_text_context_layout_destroy (layout->layout);
g_free (layout);
}
......@@ -558,7 +558,7 @@ hisvg_text_create_layout (HiSVGDrawingCtx * ctx,
layout = hisvg_text_context_layout_create (context,
letter_spacing, alignment, font_desc, state->font_decor, text);
hisvg_font_description_free (font_desc);
hisvg_font_description_destroy (font_desc);
return layout;
}
......@@ -618,8 +618,8 @@ hisvg_text_render_text (HiSVGDrawingCtx * ctx, const char *text, gdouble * x, gd
else
*x += w / (double)HISVG_TEXT_SCALE;
g_object_unref (layout);
g_object_unref (context);
hisvg_text_context_layout_destroy (layout);
hisvg_text_context_destroy (context);
}
static gdouble
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment