From 11a34bb3881dfcb3736e7aa8f8d8b0c64ba8d59a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 2 Feb 2006 01:54:25 +0000 Subject: Add a default_substitute function to set correct dpi on the pattern. 2006-02-01 Behdad Esfahbod * examples/xftview.c: Add a default_substitute function to set correct dpi on the pattern. --- ChangeLog | 5 +++++ examples/cairoview.c | 3 ++- examples/pangoft2topgm.c | 11 ++++++----- examples/viewer-x.c | 2 +- examples/viewer-x.h | 1 + examples/xftview.c | 10 ++++++++++ 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c0ed05d..e1906722 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-02-01 Behdad Esfahbod + + * examples/xftview.c: Add a default_substitute function to set + correct dpi on the pattern. + 2006-02-01 Behdad Esfahbod * examples/viewer-x.c, examples/viewer-x.h: Driver for X-based diff --git a/examples/cairoview.c b/examples/cairoview.c index 061c1abb..e677bcd7 100644 --- a/examples/cairoview.c +++ b/examples/cairoview.c @@ -100,6 +100,7 @@ transform_callback (PangoContext *context, void do_init (Display *display, int screen, + int dpi, /* output */ PangoContext **context, int *width, @@ -109,7 +110,7 @@ do_init (Display *display, cairo_t *cr; cairo_surface_t *surface; fontmap = pango_cairo_font_map_get_default (); - pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), opt_dpi); + pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), dpi); *context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap)); /* This is annoying ... we have to create a temporary surface just to diff --git a/examples/pangoft2topgm.c b/examples/pangoft2topgm.c index 85da627c..ddd162a6 100644 --- a/examples/pangoft2topgm.c +++ b/examples/pangoft2topgm.c @@ -31,10 +31,11 @@ #include static void -ft2_render (PangoLayout *layout, - int x, - int y, - gpointer data) +do_render (PangoLayout *layout, + int x, + int y, + gpointer data, + gboolean show_borders) { pango_ft2_render_layout (data, layout, x, y); } @@ -113,7 +114,7 @@ main(int argc, char *argv[]) memset (buf, 0x00, bitmap.pitch * bitmap.rows); for (run = 0; run < opt_runs; run++) - do_output (context, ft2_render, NULL, &bitmap, &width, &height, FALSE); + do_output (context, do_render, NULL, &bitmap, &width, &height, FALSE); if (gen_output) { diff --git a/examples/viewer-x.c b/examples/viewer-x.c index 6546612b..8d2a4d11 100644 --- a/examples/viewer-x.c +++ b/examples/viewer-x.c @@ -100,7 +100,7 @@ main (int argc, char **argv) fail ("Cannot open display %s\n", XDisplayName (NULL)); screen = DefaultScreen (display); - do_init (display, screen, &context, &width, &height); + do_init (display, screen, opt_dpi, &context, &width, &height); bg = WhitePixel (display, screen); window = XCreateSimpleWindow (display, DefaultRootWindow (display), diff --git a/examples/viewer-x.h b/examples/viewer-x.h index 6ff528bb..83c40358 100644 --- a/examples/viewer-x.h +++ b/examples/viewer-x.h @@ -28,6 +28,7 @@ void do_init (Display *display, int screen, + int dpi, /* output */ PangoContext **context, int *width, diff --git a/examples/xftview.c b/examples/xftview.c index f9ba6f6a..ab65a17a 100644 --- a/examples/xftview.c +++ b/examples/xftview.c @@ -26,6 +26,14 @@ #include +static void +default_substitute (FcPattern *pattern, + gpointer data) +{ + int dpi = GPOINTER_TO_INT (data); + FcPatternAddInteger (pattern, FC_DPI, dpi); +} + static void render_callback (PangoLayout *layout, int x, @@ -67,6 +75,7 @@ render_callback (PangoLayout *layout, void do_init (Display *display, int screen, + int dpi, /* output */ PangoContext **context, int *width, @@ -74,6 +83,7 @@ do_init (Display *display, { XftInit (NULL); *context = pango_xft_get_context (display, screen); + pango_xft_set_default_substitute (display, screen, default_substitute, GINT_TO_POINTER (dpi), NULL); do_output (*context, NULL, NULL, NULL, width, height, FALSE); } -- cgit v1.2.1