Use a new rsvg_drawing_ctx_get_dpi() accessor throughout

Instead of accessing ctx->{dpi_x,dpi_y} directly.
parent 2376ac2a
......@@ -2381,8 +2381,21 @@ rsvg_drawing_ctx_pop_view_box (RsvgDrawingCtx * ctx)
void
rsvg_drawing_ctx_get_view_box_size (RsvgDrawingCtx *ctx, double *out_width, double *out_height)
{
*out_width = ctx->vb.rect.width;
*out_height = ctx->vb.rect.height;
if (out_width)
*out_width = ctx->vb.rect.width;
if (out_height)
*out_height = ctx->vb.rect.height;
}
void
rsvg_drawing_ctx_get_dpi (RsvgDrawingCtx *ctx, double *out_dpi_x, double *out_dpi_y)
{
if (out_dpi_x)
*out_dpi_x = ctx->dpi_x;
if (out_dpi_y)
*out_dpi_y = ctx->dpi_y;
}
void
......
......@@ -464,11 +464,15 @@ rsvg_cairo_create_pango_context (RsvgDrawingCtx * ctx)
PangoFontMap *fontmap;
PangoContext *context;
RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);
double dpi_y;
fontmap = pango_cairo_font_map_get_default ();
context = pango_font_map_create_context (fontmap);
pango_cairo_update_context (render->cr, context);
pango_cairo_context_set_resolution (context, ctx->dpi_y);
rsvg_drawing_ctx_get_dpi (ctx, NULL, &dpi_y);
pango_cairo_context_set_resolution (context, dpi_y);
return context;
}
......
......@@ -143,15 +143,19 @@ _rsvg_css_normalize_length (const RsvgLength * in, RsvgDrawingCtx * ctx)
else
return in->length * font / 2.;
} else if (in->unit == LENGTH_UNIT_INCH) {
double dpi_x, dpi_y;
rsvg_drawing_ctx_get_dpi (ctx, &dpi_x, &dpi_y);
switch (in->dir) {
case LENGTH_DIR_HORIZONTAL:
return in->length * ctx->dpi_x;
return in->length * dpi_x;
case LENGTH_DIR_VERTICAL:
return in->length * ctx->dpi_y;
return in->length * dpi_y;
case LENGTH_DIR_BOTH:
return in->length * rsvg_viewport_percentage (ctx->dpi_x, ctx->dpi_y);
return in->length * rsvg_viewport_percentage (dpi_x, dpi_y);
}
} else if (in->unit == LENGTH_UNIT_RELATIVE_LARGER) {
/* todo: "larger" */
......
......@@ -446,6 +446,9 @@ void rsvg_drawing_ctx_pop_view_box (RsvgDrawingCtx * ctx);
G_GNUC_INTERNAL
void rsvg_drawing_ctx_get_view_box_size (RsvgDrawingCtx *ctx, double *out_width, double *out_height);
G_GNUC_INTERNAL
void rsvg_drawing_ctx_get_dpi (RsvgDrawingCtx *ctx, double *out_dpi_x, double *out_dpi_y);
G_GNUC_INTERNAL
void rsvg_SAX_handler_struct_init (void);
G_GNUC_INTERNAL
......
......@@ -513,6 +513,7 @@ rsvg_text_create_layout (RsvgDrawingCtx * ctx,
PangoLayout *layout;
PangoAttrList *attr_list;
PangoAttribute *attribute;
double dpi_y;
if (state->lang)
pango_context_set_language (context, pango_language_from_string (state->lang));
......@@ -532,9 +533,10 @@ rsvg_text_create_layout (RsvgDrawingCtx * ctx,
pango_font_description_set_variant (font_desc, state->font_variant);
pango_font_description_set_weight (font_desc, state->font_weight);
pango_font_description_set_stretch (font_desc, state->font_stretch);
rsvg_drawing_ctx_get_dpi (ctx, NULL, &dpi_y);
pango_font_description_set_size (font_desc,
_rsvg_css_normalize_font_size (state, ctx) *
PANGO_SCALE / ctx->dpi_y * 72);
_rsvg_css_normalize_font_size (state, ctx) * PANGO_SCALE / dpi_y * 72);
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, font_desc);
......
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