summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-08-16 17:47:00 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-08-16 17:47:00 +0000
commit06a6c6ab09299923a86cf486ee3d75304cb6f0e1 (patch)
treeb41db8f2d4e12ecb5be9c0bfd2d7c1e3ce13a467 /examples
parentf978372136fc20679761bc86eff186edbca8ee42 (diff)
downloadpango-06a6c6ab09299923a86cf486ee3d75304cb6f0e1.tar.gz
Sync with change to OTL_GlyphItemRec.
Mon Aug 16 13:42:38 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-ot.h (struct _PangoOTGlyph): Sync with change to OTL_GlyphItemRec. (https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=129982, Jatin Nansi)
Diffstat (limited to 'examples')
-rw-r--r--examples/pangoft2topgm.c2
-rw-r--r--examples/renderdemo.c41
-rw-r--r--examples/renderdemo.h25
3 files changed, 61 insertions, 7 deletions
diff --git a/examples/pangoft2topgm.c b/examples/pangoft2topgm.c
index 52370383..f3a1a15c 100644
--- a/examples/pangoft2topgm.c
+++ b/examples/pangoft2topgm.c
@@ -81,7 +81,9 @@ main(int argc, char *argv[])
}
fontmap = pango_ft2_font_map_new ();
+
pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap), opt_dpi, opt_dpi);
+ pango_ft2_font_map_set_default_substitute (PANGO_FT2_FONT_MAP (fontmap), fc_substitute_func, NULL, NULL);
context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap));
/* Write contents as pgm file */
diff --git a/examples/renderdemo.c b/examples/renderdemo.c
index b6940380..0cc30fff 100644
--- a/examples/renderdemo.c
+++ b/examples/renderdemo.c
@@ -55,6 +55,7 @@ gboolean opt_waterfall = FALSE;
int opt_width = -1;
int opt_indent = 0;
PangoEllipsizeMode opt_ellipsize = PANGO_ELLIPSIZE_NONE;
+HintMode opt_hinting = HINT_DEFAULT;
/* Text (or markup) to render */
char *text;
@@ -299,6 +300,23 @@ show_help (ArgContext *context,
exit (0);
}
+/* This function gets called to convert a matched pattern into what
+ * we'll use to actually load the font. We turn off hinting since we
+ * want metrics that are independent of scale.
+ */
+void
+fc_substitute_func (FcPattern *pattern, gpointer data)
+{
+ if (opt_hinting != HINT_DEFAULT)
+ {
+ FcPatternDel (pattern, FC_HINTING);
+ FcPatternAddBool (pattern, FC_HINTING, opt_hinting != HINT_NONE);
+
+ FcPatternDel (pattern, FC_AUTOHINT);
+ FcPatternAddBool (pattern, FC_AUTOHINT, opt_hinting != HINT_AUTO);
+ }
+}
+
void
parse_ellipsis (ArgContext *arg_context,
const char *name,
@@ -319,6 +337,27 @@ parse_ellipsis (ArgContext *arg_context,
}
void
+parse_hinting (ArgContext *arg_context,
+ const char *name,
+ const char *arg,
+ gpointer data)
+{
+ static GEnumClass *class = NULL;
+
+ if (!class)
+ class = g_type_class_ref (PANGO_TYPE_ELLIPSIZE_MODE);
+
+ if (strcmp (arg, "none") == 0)
+ opt_hinting = HINT_NONE;
+ else if (strcmp (arg, "auto") == 0)
+ opt_hinting = HINT_AUTO;
+ else if (strcmp (arg, "full") == 0)
+ opt_hinting = HINT_FULL;
+ else
+ fail ("--hinting option must be one of none/auto/full");
+}
+
+void
parse_options (int argc, char *argv[])
{
static const ArgDesc args[] = {
@@ -336,6 +375,8 @@ parse_options (int argc, char *argv[])
ARG_BOOL, &opt_header },
{ "help", "Show this output",
ARG_CALLBACK, NULL, show_help, },
+ { "hinting", "Hinting style [=none/auto/full]",
+ ARG_CALLBACK, NULL, parse_hinting, },
{ "margin", "Set the margin on the output in pixels",
ARG_INT, &opt_margin },
{ "markup", "Interpret contents as Pango markup",
diff --git a/examples/renderdemo.h b/examples/renderdemo.h
index 94a27f49..cffea109 100644
--- a/examples/renderdemo.h
+++ b/examples/renderdemo.h
@@ -20,6 +20,14 @@
*/
#include <pango/pango-layout.h>
+#include <pango/pangofc-fontmap.h>
+
+typedef enum {
+ HINT_DEFAULT,
+ HINT_NONE,
+ HINT_AUTO,
+ HINT_FULL
+} HintMode;
typedef void (*RenderCallback) (PangoLayout *layout,
int x,
@@ -28,13 +36,15 @@ typedef void (*RenderCallback) (PangoLayout *layout,
void fail (const char *format, ...) G_GNUC_PRINTF (1, 2);
-void parse_options (int argc,
- char *argv[]);
-void do_output (PangoContext *context,
- RenderCallback render_cb,
- gpointer render_data,
- int *width,
- int *height);
+void parse_options (int argc,
+ char *argv[]);
+void do_output (PangoContext *context,
+ RenderCallback render_cb,
+ gpointer render_data,
+ int *width,
+ int *height);
+void fc_substitute_func (FcPattern *pattern,
+ gpointer data);
gchar *get_options_string (void);
extern char *prog_name;
@@ -54,3 +64,4 @@ extern gboolean opt_waterfall;
extern int opt_width;
extern int opt_indent;
extern PangoEllipsizeMode opt_ellipsize;
+extern HintMode opt_hinting;