summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2003-08-08 14:55:40 +0000
committerOwen Taylor <otaylor@src.gnome.org>2003-08-08 14:55:40 +0000
commitb73b08516c8c86234c8a35b05f7b2204e7ab10de (patch)
tree175fe06f0c5e5fdc7a603f68579516434de50773
parent82355601bff8ff93768ca4ec33b79a059a87f3da (diff)
downloadpango-b73b08516c8c86234c8a35b05f7b2204e7ab10de.tar.gz
Deprecate pango_ft2_get_context(), pango_ft2_font_map_for_display(),
Fri Aug 8 10:33:31 2003 Owen Taylor <otaylor@redhat.com> * pango/pangoft2.h: Deprecate pango_ft2_get_context(), pango_ft2_font_map_for_display(), pango_ft2_shutdown_display(); the explicit * pango/pangoft2-fontmap.c (pango_ft2_shutdown_display): Add docs about deprecations. * examples/Makefile.am (INCLUDES): Add -DPANGO_DISABLE_DEPRECATED * examples/pangoft2topgm.c: Fix deprecated usages; add --dpi and --markup options. Improve error handling.
-rw-r--r--ChangeLog14
-rw-r--r--ChangeLog.pre-1-1014
-rw-r--r--ChangeLog.pre-1-414
-rw-r--r--ChangeLog.pre-1-614
-rw-r--r--ChangeLog.pre-1-814
-rw-r--r--examples/Makefile.am1
-rw-r--r--examples/pangoft2topgm.c98
-rw-r--r--examples/renderdemo.c98
-rw-r--r--pango/pangoft2-fontmap.c7
-rw-r--r--pango/pangoft2.h9
10 files changed, 223 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index 3b381959..6b9c60f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Fri Aug 8 10:33:31 2003 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangoft2.h: Deprecate pango_ft2_get_context(),
+ pango_ft2_font_map_for_display(), pango_ft2_shutdown_display();
+ the explicit
+
+ * pango/pangoft2-fontmap.c (pango_ft2_shutdown_display):
+ Add docs about deprecations.
+
+ * examples/Makefile.am (INCLUDES): Add -DPANGO_DISABLE_DEPRECATED
+
+ * examples/pangoft2topgm.c: Fix deprecated usages; add
+ --dpi and --markup options. Improve error handling.
+
Fri Aug 8 10:03:03 2003 Owen Taylor <otaylor@redhat.com>
* examples/pangoft2topgm.c: Get rid of a bunch of
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 3b381959..6b9c60f7 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,17 @@
+Fri Aug 8 10:33:31 2003 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangoft2.h: Deprecate pango_ft2_get_context(),
+ pango_ft2_font_map_for_display(), pango_ft2_shutdown_display();
+ the explicit
+
+ * pango/pangoft2-fontmap.c (pango_ft2_shutdown_display):
+ Add docs about deprecations.
+
+ * examples/Makefile.am (INCLUDES): Add -DPANGO_DISABLE_DEPRECATED
+
+ * examples/pangoft2topgm.c: Fix deprecated usages; add
+ --dpi and --markup options. Improve error handling.
+
Fri Aug 8 10:03:03 2003 Owen Taylor <otaylor@redhat.com>
* examples/pangoft2topgm.c: Get rid of a bunch of
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 3b381959..6b9c60f7 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,17 @@
+Fri Aug 8 10:33:31 2003 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangoft2.h: Deprecate pango_ft2_get_context(),
+ pango_ft2_font_map_for_display(), pango_ft2_shutdown_display();
+ the explicit
+
+ * pango/pangoft2-fontmap.c (pango_ft2_shutdown_display):
+ Add docs about deprecations.
+
+ * examples/Makefile.am (INCLUDES): Add -DPANGO_DISABLE_DEPRECATED
+
+ * examples/pangoft2topgm.c: Fix deprecated usages; add
+ --dpi and --markup options. Improve error handling.
+
Fri Aug 8 10:03:03 2003 Owen Taylor <otaylor@redhat.com>
* examples/pangoft2topgm.c: Get rid of a bunch of
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 3b381959..6b9c60f7 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,17 @@
+Fri Aug 8 10:33:31 2003 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangoft2.h: Deprecate pango_ft2_get_context(),
+ pango_ft2_font_map_for_display(), pango_ft2_shutdown_display();
+ the explicit
+
+ * pango/pangoft2-fontmap.c (pango_ft2_shutdown_display):
+ Add docs about deprecations.
+
+ * examples/Makefile.am (INCLUDES): Add -DPANGO_DISABLE_DEPRECATED
+
+ * examples/pangoft2topgm.c: Fix deprecated usages; add
+ --dpi and --markup options. Improve error handling.
+
Fri Aug 8 10:03:03 2003 Owen Taylor <otaylor@redhat.com>
* examples/pangoft2topgm.c: Get rid of a bunch of
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 3b381959..6b9c60f7 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,17 @@
+Fri Aug 8 10:33:31 2003 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangoft2.h: Deprecate pango_ft2_get_context(),
+ pango_ft2_font_map_for_display(), pango_ft2_shutdown_display();
+ the explicit
+
+ * pango/pangoft2-fontmap.c (pango_ft2_shutdown_display):
+ Add docs about deprecations.
+
+ * examples/Makefile.am (INCLUDES): Add -DPANGO_DISABLE_DEPRECATED
+
+ * examples/pangoft2topgm.c: Fix deprecated usages; add
+ --dpi and --markup options. Improve error handling.
+
Fri Aug 8 10:03:03 2003 Owen Taylor <otaylor@redhat.com>
* examples/pangoft2topgm.c: Get rid of a bunch of
diff --git a/examples/Makefile.am b/examples/Makefile.am
index f411ed6e..bc718021 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -4,6 +4,7 @@ aliasdir = $(sysconfdir)/pango
INCLUDES = \
-DG_DISABLE_DEPRECATED \
+ -DPANGO_DISABLE_DEPRECATED \
$(PANGO_DEBUG_FLAGS) \
-I$(top_srcdir) \
$(QT_INCLUDES) \
diff --git a/examples/pangoft2topgm.c b/examples/pangoft2topgm.c
index 5063e786..9a61ce7a 100644
--- a/examples/pangoft2topgm.c
+++ b/examples/pangoft2topgm.c
@@ -33,15 +33,17 @@
#include <stdio.h>
#include <string.h>
-char *prog_name = NULL;
+static PangoContext *context;
-PangoContext *context;
+static char *opt_family = "sans";
+static PangoDirection opt_dir = PANGO_DIRECTION_LTR;
+static int opt_dpi = 96;
+static int opt_margin = 10;
+static int opt_markup = FALSE;
+static int opt_scale = 24;
+static gboolean opt_waterfall = FALSE;
-static char *init_family = "sans";
-static int init_scale = 24;
-static int init_margin = 10;
-static PangoDirection init_dir = PANGO_DIRECTION_LTR;
-static gboolean init_waterfall = FALSE;
+static void fail (const char *format, ...) G_GNUC_PRINTF (1, 2);
static void
fail (const char *format, ...)
@@ -66,10 +68,13 @@ make_layout(PangoContext *context,
PangoLayout *layout;
layout = pango_layout_new (context);
- pango_layout_set_text (layout, text, -1);
+ if (opt_markup)
+ pango_layout_set_markup (layout, text, -1);
+ else
+ pango_layout_set_text (layout, text, -1);
font_description = pango_font_description_new ();
- pango_font_description_set_family (font_description, init_family);
+ pango_font_description_set_family (font_description, opt_family);
pango_font_description_set_size (font_description, scale * PANGO_SCALE);
base_dir = pango_context_get_base_dir (context);
@@ -91,14 +96,14 @@ do_output (PangoContext *context,
{
PangoLayout *layout;
PangoRectangle logical_rect;
- int x = init_margin;
- int y = init_margin;
+ int x = opt_margin;
+ int y = opt_margin;
int scale, start_scale, end_scale, increment;
*width = 0;
*height = 0;
- if (init_waterfall)
+ if (opt_waterfall)
{
start_scale = 8;
end_scale = 48;
@@ -106,7 +111,7 @@ do_output (PangoContext *context,
}
else
{
- start_scale = end_scale = init_scale;
+ start_scale = end_scale = opt_scale;
increment = 1;
}
@@ -126,19 +131,33 @@ do_output (PangoContext *context,
g_object_unref (layout);
}
- *width += 2 * init_margin;
- *height += 2 * init_margin;
+ *width += 2 * opt_margin;
+ *height += 2 * opt_margin;
+}
+
+int int_arg (const char *arg_name, const char *arg)
+{
+ char *end;
+ long result = strtol (arg, &end, 0);
+ if (*arg == '\0' || *end != '\0')
+ {
+ fail ("Cannot parse integer value '%s' for %s.",
+ arg, arg_name);
+ }
+
+ return result;
}
int main(int argc, char *argv[])
{
+ char *outfile_name;
FILE *outfile;
- int dpi_x = 100, dpi_y = 100;
char *text;
size_t len;
char *p;
int argp;
char *prog_name = g_path_get_basename (argv[0]);
+ PangoFontMap *fontmap;
GError *error = NULL;
g_type_init();
@@ -159,38 +178,50 @@ int main(int argc, char *argv[])
" %s [--family f] [--scale s] file\n"
"\n"
"Options:\n"
+ " --dpi d Set the dpi.Default is '%d'.\n"
" --family f Set the family. Default is '%s'.\n"
" --margin m Set the margin on the output in pixels. Default is %d.\n"
+ " --markup Interpret contents as Pango markup.\n"
" --scale s Set the scale. Default is %d.\n"
" --rtl Set base dir to RTL. Default is LTR.\n"
" --waterfall Create a waterfall display."
" --width Width of drawing window. Default is 500.\n",
- prog_name, prog_name, init_family, init_margin, init_scale);
+ prog_name, prog_name, opt_dpi, opt_family, opt_margin, opt_scale);
exit(0);
}
+ if (strcmp(opt, "--dpi") == 0)
+ {
+ opt_dpi = int_arg("--dpi", argv[argp++]);
+ continue;
+ }
if (strcmp(opt, "--family") == 0)
{
- init_family = argv[argp++];
+ opt_family = argv[argp++];
continue;
}
if (strcmp(opt, "--margin") == 0)
{
- init_margin = atoi(argv[argp++]);
+ opt_margin = int_arg("--margin", argv[argp++]);
+ continue;
+ }
+ if (strcmp(opt, "--markup") == 0)
+ {
+ opt_markup = TRUE;
continue;
}
if (strcmp(opt, "--waterfall") == 0)
{
- init_waterfall = TRUE;
+ opt_waterfall = TRUE;
continue;
}
if (strcmp(opt, "--scale") == 0)
{
- init_scale = atoi(argv[argp++]);
+ opt_scale = int_arg("--scale", argv[argp++]);
continue;
}
if (strcmp(opt, "--rtl") == 0)
{
- init_dir = PANGO_DIRECTION_RTL;
+ opt_dir = PANGO_DIRECTION_RTL;
continue;
}
fail ("Unknown option %s!\n", opt);
@@ -220,18 +251,31 @@ int main(int argc, char *argv[])
*p = '\0';
}
+ /* Make sure we have valid markup
+ */
+ if (opt_markup &&
+ !pango_parse_markup (text, -1, 0, NULL, NULL, NULL, &error))
+ fail ("Cannot parse input as markup: %s", error->message);
+
if (argp < argc)
- outfile = fopen (argv[argp++], "wb");
+ {
+ outfile_name = argv[argp++];
+ outfile = fopen (outfile_name, "wb");
+
+ if (!outfile)
+ fail ("Cannot open output file %s: %s\n",
+ outfile_name, g_strerror (errno));
+ }
else
outfile = stdout;
- if (!outfile)
- fail ("Cannot open output file %s: s\n", outfile, g_strerror (errno));
- context = pango_ft2_get_context (dpi_x, dpi_y);
+ fontmap = pango_ft2_font_map_new ();
+ pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap), opt_dpi, opt_dpi);
+ context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap));
pango_context_set_language (context, pango_language_from_string ("en_US"));
- pango_context_set_base_dir (context, init_dir);
+ pango_context_set_base_dir (context, opt_dir);
/* Write contents as pgm file */
{
diff --git a/examples/renderdemo.c b/examples/renderdemo.c
index 5063e786..9a61ce7a 100644
--- a/examples/renderdemo.c
+++ b/examples/renderdemo.c
@@ -33,15 +33,17 @@
#include <stdio.h>
#include <string.h>
-char *prog_name = NULL;
+static PangoContext *context;
-PangoContext *context;
+static char *opt_family = "sans";
+static PangoDirection opt_dir = PANGO_DIRECTION_LTR;
+static int opt_dpi = 96;
+static int opt_margin = 10;
+static int opt_markup = FALSE;
+static int opt_scale = 24;
+static gboolean opt_waterfall = FALSE;
-static char *init_family = "sans";
-static int init_scale = 24;
-static int init_margin = 10;
-static PangoDirection init_dir = PANGO_DIRECTION_LTR;
-static gboolean init_waterfall = FALSE;
+static void fail (const char *format, ...) G_GNUC_PRINTF (1, 2);
static void
fail (const char *format, ...)
@@ -66,10 +68,13 @@ make_layout(PangoContext *context,
PangoLayout *layout;
layout = pango_layout_new (context);
- pango_layout_set_text (layout, text, -1);
+ if (opt_markup)
+ pango_layout_set_markup (layout, text, -1);
+ else
+ pango_layout_set_text (layout, text, -1);
font_description = pango_font_description_new ();
- pango_font_description_set_family (font_description, init_family);
+ pango_font_description_set_family (font_description, opt_family);
pango_font_description_set_size (font_description, scale * PANGO_SCALE);
base_dir = pango_context_get_base_dir (context);
@@ -91,14 +96,14 @@ do_output (PangoContext *context,
{
PangoLayout *layout;
PangoRectangle logical_rect;
- int x = init_margin;
- int y = init_margin;
+ int x = opt_margin;
+ int y = opt_margin;
int scale, start_scale, end_scale, increment;
*width = 0;
*height = 0;
- if (init_waterfall)
+ if (opt_waterfall)
{
start_scale = 8;
end_scale = 48;
@@ -106,7 +111,7 @@ do_output (PangoContext *context,
}
else
{
- start_scale = end_scale = init_scale;
+ start_scale = end_scale = opt_scale;
increment = 1;
}
@@ -126,19 +131,33 @@ do_output (PangoContext *context,
g_object_unref (layout);
}
- *width += 2 * init_margin;
- *height += 2 * init_margin;
+ *width += 2 * opt_margin;
+ *height += 2 * opt_margin;
+}
+
+int int_arg (const char *arg_name, const char *arg)
+{
+ char *end;
+ long result = strtol (arg, &end, 0);
+ if (*arg == '\0' || *end != '\0')
+ {
+ fail ("Cannot parse integer value '%s' for %s.",
+ arg, arg_name);
+ }
+
+ return result;
}
int main(int argc, char *argv[])
{
+ char *outfile_name;
FILE *outfile;
- int dpi_x = 100, dpi_y = 100;
char *text;
size_t len;
char *p;
int argp;
char *prog_name = g_path_get_basename (argv[0]);
+ PangoFontMap *fontmap;
GError *error = NULL;
g_type_init();
@@ -159,38 +178,50 @@ int main(int argc, char *argv[])
" %s [--family f] [--scale s] file\n"
"\n"
"Options:\n"
+ " --dpi d Set the dpi.Default is '%d'.\n"
" --family f Set the family. Default is '%s'.\n"
" --margin m Set the margin on the output in pixels. Default is %d.\n"
+ " --markup Interpret contents as Pango markup.\n"
" --scale s Set the scale. Default is %d.\n"
" --rtl Set base dir to RTL. Default is LTR.\n"
" --waterfall Create a waterfall display."
" --width Width of drawing window. Default is 500.\n",
- prog_name, prog_name, init_family, init_margin, init_scale);
+ prog_name, prog_name, opt_dpi, opt_family, opt_margin, opt_scale);
exit(0);
}
+ if (strcmp(opt, "--dpi") == 0)
+ {
+ opt_dpi = int_arg("--dpi", argv[argp++]);
+ continue;
+ }
if (strcmp(opt, "--family") == 0)
{
- init_family = argv[argp++];
+ opt_family = argv[argp++];
continue;
}
if (strcmp(opt, "--margin") == 0)
{
- init_margin = atoi(argv[argp++]);
+ opt_margin = int_arg("--margin", argv[argp++]);
+ continue;
+ }
+ if (strcmp(opt, "--markup") == 0)
+ {
+ opt_markup = TRUE;
continue;
}
if (strcmp(opt, "--waterfall") == 0)
{
- init_waterfall = TRUE;
+ opt_waterfall = TRUE;
continue;
}
if (strcmp(opt, "--scale") == 0)
{
- init_scale = atoi(argv[argp++]);
+ opt_scale = int_arg("--scale", argv[argp++]);
continue;
}
if (strcmp(opt, "--rtl") == 0)
{
- init_dir = PANGO_DIRECTION_RTL;
+ opt_dir = PANGO_DIRECTION_RTL;
continue;
}
fail ("Unknown option %s!\n", opt);
@@ -220,18 +251,31 @@ int main(int argc, char *argv[])
*p = '\0';
}
+ /* Make sure we have valid markup
+ */
+ if (opt_markup &&
+ !pango_parse_markup (text, -1, 0, NULL, NULL, NULL, &error))
+ fail ("Cannot parse input as markup: %s", error->message);
+
if (argp < argc)
- outfile = fopen (argv[argp++], "wb");
+ {
+ outfile_name = argv[argp++];
+ outfile = fopen (outfile_name, "wb");
+
+ if (!outfile)
+ fail ("Cannot open output file %s: %s\n",
+ outfile_name, g_strerror (errno));
+ }
else
outfile = stdout;
- if (!outfile)
- fail ("Cannot open output file %s: s\n", outfile, g_strerror (errno));
- context = pango_ft2_get_context (dpi_x, dpi_y);
+ fontmap = pango_ft2_font_map_new ();
+ pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap), opt_dpi, opt_dpi);
+ context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap));
pango_context_set_language (context, pango_language_from_string ("en_US"));
- pango_context_set_base_dir (context, init_dir);
+ pango_context_set_base_dir (context, opt_dir);
/* Write contents as pgm file */
{
diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c
index 1abc5a0d..bd49ec58 100644
--- a/pango/pangoft2-fontmap.c
+++ b/pango/pangoft2-fontmap.c
@@ -265,7 +265,7 @@ pango_ft2_font_map_create_context (PangoFT2FontMap *fontmap)
* (see pango_ft2_fontmap_get_for_display()) and sets the resolution
* for the default fontmap to @dpi_x by @dpi_y.
*
- * Use of this function is discouraged, see pango_ft2_fontmap_create_context()
+ * Use of this function is deprecated; see pango_ft2_fontmap_create_context()
* instead.
*
* Return value: the new #PangoContext
@@ -286,7 +286,9 @@ pango_ft2_get_context (double dpi_x, double dpi_y)
*
* Returns a #PangoFT2FontMap. This font map is cached and should
* not be freed. If the font map is no longer needed, it can
- * be released with pango_ft2_shutdown_display().
+ * be released with pango_ft2_shutdown_display(). Use of the
+ * global PangoFT2 fontmap is deprecated; use pango_ft2_font_map_new()
+ * instead.
*
* Returns: a #PangoFT2FontMap.
**/
@@ -305,6 +307,7 @@ pango_ft2_font_map_for_display (void)
* pango_ft2_shutdown_display:
*
* Free the global fontmap. (See pango_ft2_font_map_for_display())
+ * Use of the global PangoFT2 fontmap is deprecated.
**/
void
pango_ft2_shutdown_display (void)
diff --git a/pango/pangoft2.h b/pango/pangoft2.h
index da5cf3fb..e8ba820f 100644
--- a/pango/pangoft2.h
+++ b/pango/pangoft2.h
@@ -44,10 +44,6 @@ typedef void (*PangoFT2SubstituteFunc) (FcPattern *pattern,
gpointer data);
/* Calls for applications */
-PangoContext *pango_ft2_get_context (double dpi_x,
- double dpi_y);
-PangoFontMap *pango_ft2_font_map_for_display (void);
-void pango_ft2_shutdown_display (void);
void pango_ft2_render (FT_Bitmap *bitmap,
@@ -81,6 +77,11 @@ PangoContext *pango_ft2_font_map_create_context (PangoFT2FontMap
/* API for rendering modules
*/
#ifndef PANGO_DISABLE_DEPRECATED
+PangoContext *pango_ft2_get_context (double dpi_x,
+ double dpi_y);
+PangoFontMap *pango_ft2_font_map_for_display (void);
+void pango_ft2_shutdown_display (void);
+
PangoGlyph pango_ft2_get_unknown_glyph (PangoFont *font);
int pango_ft2_font_get_kerning (PangoFont *font,
PangoGlyph left,