summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-02-02 01:54:25 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-02-02 01:54:25 +0000
commit11a34bb3881dfcb3736e7aa8f8d8b0c64ba8d59a (patch)
treea25a4b26b92163777bbb9f479809b79041e10250 /examples
parent9ca400bee42e2ad658681c8d0161ec18492964ef (diff)
downloadpango-11a34bb3881dfcb3736e7aa8f8d8b0c64ba8d59a.tar.gz
Add a default_substitute function to set correct dpi on the pattern.
2006-02-01 Behdad Esfahbod <behdad@gnome.org> * examples/xftview.c: Add a default_substitute function to set correct dpi on the pattern.
Diffstat (limited to 'examples')
-rw-r--r--examples/cairoview.c3
-rw-r--r--examples/pangoft2topgm.c11
-rw-r--r--examples/viewer-x.c2
-rw-r--r--examples/viewer-x.h1
-rw-r--r--examples/xftview.c10
5 files changed, 20 insertions, 7 deletions
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 <pango/pangoft2.h>
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
@@ -27,6 +27,14 @@
#include <pango/pangoxft.h>
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,
int y,
@@ -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);
}