2009-01-02 Behdad Esfahbod <behdad@gnome.org>
+ * pango-view/viewer-main.c (main):
+ * pango-view/viewer-pangocairo.c (pangocairo_view_render):
+ * pango-view/viewer-pangoft2.c (pangoft2_view_render):
+ * pango-view/viewer-pangox.c (pangox_view_render):
+ * pango-view/viewer-pangoxft.c (pangoxft_view_render):
+ * pango-view/viewer.h:
+ Make sure we measure layout with the same surface type as the
+ final target. Also reduces fonts loaded by the pangocairo backend.
+
+2009-01-02 Behdad Esfahbod <behdad@gnome.org>
+
* pango/pangocairo-context.c (_pango_cairo_update_context):
Completely ignore CTM translation offsets.
instance = view->create (view);
context = view->get_context (instance);
- do_output (context, NULL, NULL, NULL, NULL, &width, &height);
+ width = height = 1;
+ surface = view->create_surface (instance, width, height);
+ view->render (instance, surface, context, &width, &height, NULL);
+ view->destroy_surface (instance, surface);
surface = view->create_surface (instance, width, height);
for (run = 0; run < MAX(1,opt_runs); run++)
- view->render (instance, surface, context, width, height, NULL);
+ view->render (instance, surface, context, &width, &height, NULL);
if (opt_output)
{
if (!state)
break;
- view->render (instance, surface, context, width, height, state);
+ view->render (instance, surface, context, &width, &height, state);
}
if (view->destroy_window)
pangocairo_view_render (gpointer instance G_GNUC_UNUSED,
gpointer surface,
PangoContext *context,
- int width G_GNUC_UNUSED,
- int height G_GNUC_UNUSED,
+ int *width,
+ int *height,
gpointer state)
{
cairo_t *cr;
CairoSurface *c_surface = (CairoSurface *) surface;
- if (!surface)
- {
- cairo_surface_t *cs;
- /* This is annoying ... we have to create a temporary surface just to
- * get the extents of the text.
- */
- /* image surface here is not good as it may have font options different
- * from the target surface */
- cs = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1);
- cr = cairo_create (cs);
- cairo_surface_destroy (cs);
- }
- else
- cr = cairo_create (c_surface->cairo);
+ g_assert (surface);
+
+ cr = cairo_create (c_surface->cairo);
transform_callback (context, NULL, cr, state);
cairo_paint (cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
- do_output (context, render_callback, transform_callback, cr, state, NULL, NULL);
+ do_output (context, render_callback, transform_callback, cr, state, width, height);
cairo_destroy (cr);
}
pangoft2_view_render (gpointer instance G_GNUC_UNUSED,
gpointer surface,
PangoContext *context,
- int width G_GNUC_UNUSED,
- int height G_GNUC_UNUSED,
+ int *width,
+ int *height,
gpointer state)
{
int pix_idx;
FT_Bitmap *bitmap = (FT_Bitmap *) surface;
- do_output (context, render_callback, NULL, surface, state, NULL, NULL);
+ do_output (context, render_callback, NULL, surface, state, width, height);
for (pix_idx=0; pix_idx<bitmap->pitch * bitmap->rows; pix_idx++)
bitmap->buffer[pix_idx] = 255 - bitmap->buffer[pix_idx];
pangox_view_render (gpointer instance,
gpointer surface,
PangoContext *context,
- int width,
- int height,
+ int *width,
+ int *height,
gpointer state)
{
XViewer *x = (XViewer *) instance;
gc = XCreateGC (x->display, pixmap, 0, NULL);
XSetForeground(x->display, gc, WhitePixel(x->display, x->screen));
- XFillRectangle (x->display, pixmap, gc, 0, 0, width, height);
+ XFillRectangle (x->display, pixmap, gc, 0, 0, *width, *height);
x_context.x = x;
x_context.drawable = pixmap;
x_context.gc = gc;
XSetForeground(x->display, gc, BlackPixel(x->display, x->screen));
- do_output (context, render_callback, NULL, &x_context, state, NULL, NULL);
+ do_output (context, render_callback, NULL, &x_context, state, width, height);
XFlush(x->display);
pangoxft_view_render (gpointer instance,
gpointer surface,
PangoContext *context,
- int width,
- int height,
+ int *width,
+ int *height,
gpointer state)
{
XViewer *x = (XViewer *) instance;
color.color.green = 0xffff;
color.color.alpha = 0xffff;
- XftDrawRect (draw, &color, 0, 0, width, height);
+ XftDrawRect (draw, &color, 0, 0, *width, *height);
color.color.red = 0x0;
color.color.green = 0x0;
xft_context.draw = draw;
xft_context.color = color;
- do_output (context, render_callback, NULL, &xft_context, state, NULL, NULL);
+ do_output (context, render_callback, NULL, &xft_context, state, width, height);
XftDrawDestroy (draw);
}
void (*render) (gpointer instance,
gpointer surface,
PangoContext *context,
- int width,
- int height,
+ int *width,
+ int *height,
gpointer state);
/* The following can be NULL */