summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-02-28 21:15:15 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-02-28 21:15:15 +0000
commit94742208d8f1e274d8a5db4515acfbd4b3d9e4fa (patch)
tree57e31004de3d14316ad1d54a416bf680b45c3cf2
parent77626cb70d108fcba67dbc6085b864fcf166598d (diff)
downloadpango-94742208d8f1e274d8a5db4515acfbd4b3d9e4fa.tar.gz
add approximate_digit_width field
2001-02-28 Havoc Pennington <hp@redhat.com> * pango/pango-font.h (struct _PangoFontMetrics): add approximate_digit_width field * pango/pangox.c (pango_x_font_get_metrics): make up an approximate digit width number
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.pre-1-08
-rw-r--r--ChangeLog.pre-1-108
-rw-r--r--ChangeLog.pre-1-28
-rw-r--r--ChangeLog.pre-1-48
-rw-r--r--ChangeLog.pre-1-68
-rw-r--r--ChangeLog.pre-1-88
-rw-r--r--docs/tmpl/fonts.sgml49
-rw-r--r--pango/pango-font.h1
-rw-r--r--pango/pangox.c28
10 files changed, 130 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9005552f..b653aae1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2001-02-28 Havoc Pennington <hp@redhat.com>
+ * pango/pango-font.h (struct _PangoFontMetrics): add
+ approximate_digit_width field
+
+ * pango/pangox.c (pango_x_font_get_metrics): make up an
+ approximate digit width number
+
+2001-02-28 Havoc Pennington <hp@redhat.com>
+
* pango/pango-font.h (struct _PangoFontMetrics): Add
approximate_char_width field
diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0
index 9005552f..b653aae1 100644
--- a/ChangeLog.pre-1-0
+++ b/ChangeLog.pre-1-0
@@ -1,5 +1,13 @@
2001-02-28 Havoc Pennington <hp@redhat.com>
+ * pango/pango-font.h (struct _PangoFontMetrics): add
+ approximate_digit_width field
+
+ * pango/pangox.c (pango_x_font_get_metrics): make up an
+ approximate digit width number
+
+2001-02-28 Havoc Pennington <hp@redhat.com>
+
* pango/pango-font.h (struct _PangoFontMetrics): Add
approximate_char_width field
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 9005552f..b653aae1 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,5 +1,13 @@
2001-02-28 Havoc Pennington <hp@redhat.com>
+ * pango/pango-font.h (struct _PangoFontMetrics): add
+ approximate_digit_width field
+
+ * pango/pangox.c (pango_x_font_get_metrics): make up an
+ approximate digit width number
+
+2001-02-28 Havoc Pennington <hp@redhat.com>
+
* pango/pango-font.h (struct _PangoFontMetrics): Add
approximate_char_width field
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index 9005552f..b653aae1 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,5 +1,13 @@
2001-02-28 Havoc Pennington <hp@redhat.com>
+ * pango/pango-font.h (struct _PangoFontMetrics): add
+ approximate_digit_width field
+
+ * pango/pangox.c (pango_x_font_get_metrics): make up an
+ approximate digit width number
+
+2001-02-28 Havoc Pennington <hp@redhat.com>
+
* pango/pango-font.h (struct _PangoFontMetrics): Add
approximate_char_width field
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 9005552f..b653aae1 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,5 +1,13 @@
2001-02-28 Havoc Pennington <hp@redhat.com>
+ * pango/pango-font.h (struct _PangoFontMetrics): add
+ approximate_digit_width field
+
+ * pango/pangox.c (pango_x_font_get_metrics): make up an
+ approximate digit width number
+
+2001-02-28 Havoc Pennington <hp@redhat.com>
+
* pango/pango-font.h (struct _PangoFontMetrics): Add
approximate_char_width field
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 9005552f..b653aae1 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,5 +1,13 @@
2001-02-28 Havoc Pennington <hp@redhat.com>
+ * pango/pango-font.h (struct _PangoFontMetrics): add
+ approximate_digit_width field
+
+ * pango/pangox.c (pango_x_font_get_metrics): make up an
+ approximate digit width number
+
+2001-02-28 Havoc Pennington <hp@redhat.com>
+
* pango/pango-font.h (struct _PangoFontMetrics): Add
approximate_char_width field
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 9005552f..b653aae1 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,5 +1,13 @@
2001-02-28 Havoc Pennington <hp@redhat.com>
+ * pango/pango-font.h (struct _PangoFontMetrics): add
+ approximate_digit_width field
+
+ * pango/pangox.c (pango_x_font_get_metrics): make up an
+ approximate digit width number
+
+2001-02-28 Havoc Pennington <hp@redhat.com>
+
* pango/pango-font.h (struct _PangoFontMetrics): Add
approximate_char_width field
diff --git a/docs/tmpl/fonts.sgml b/docs/tmpl/fonts.sgml
index 0b93033b..ab1af34c 100644
--- a/docs/tmpl/fonts.sgml
+++ b/docs/tmpl/fonts.sgml
@@ -42,6 +42,13 @@ the characteristics of a font to load.
@PANGO_STYLE_OBLIQUE:
@PANGO_STYLE_ITALIC:
+<!-- ##### MACRO PANGO_TYPE_STYLE ##### -->
+<para>
+
+</para>
+
+
+
<!-- ##### ENUM PangoWeight ##### -->
<para>
An enumeration specifying the weight (boldness) of a font. This is a numerical
@@ -55,6 +62,13 @@ value ranging from 100 to 900, but there are two predefined values:
@PANGO_WEIGHT_ULTRABOLD:
@PANGO_WEIGHT_HEAVY:
+<!-- ##### MACRO PANGO_TYPE_WEIGHT ##### -->
+<para>
+
+</para>
+
+
+
<!-- ##### ENUM PangoVariant ##### -->
<para>
An enumeration specifying capitalization variant of the font.
@@ -64,6 +78,13 @@ An enumeration specifying capitalization variant of the font.
@PANGO_VARIANT_SMALL_CAPS: A font with the lower case characters
replaced by smaller variants of the capital characters.
+<!-- ##### MACRO PANGO_TYPE_VARIANT ##### -->
+<para>
+
+</para>
+
+
+
<!-- ##### ENUM PangoStretch ##### -->
<para>
An enumeration specifying the width of the font relative to other designs
@@ -80,6 +101,13 @@ within a family.
@PANGO_STRETCH_EXTRA_EXPANDED:
@PANGO_STRETCH_ULTRA_EXPANDED:
+<!-- ##### MACRO PANGO_TYPE_STRETCH ##### -->
+<para>
+
+</para>
+
+
+
<!-- ##### FUNCTION pango_font_description_copy ##### -->
<para>
@@ -89,6 +117,16 @@ within a family.
@Returns:
+<!-- ##### FUNCTION pango_font_description_equal ##### -->
+<para>
+
+</para>
+
+@desc1:
+@desc2:
+@Returns:
+
+
<!-- ##### FUNCTION pango_font_descriptions_free ##### -->
<para>
@@ -124,6 +162,15 @@ within a family.
@Returns:
+<!-- ##### FUNCTION pango_font_description_to_filename ##### -->
+<para>
+
+</para>
+
+@desc:
+@Returns:
+
+
<!-- ##### STRUCT PangoFont ##### -->
<para>
The #PangoFont structure is used to represent
@@ -188,6 +235,8 @@ a font. It contains the following members:
@descent: the logical extent of the font beneath the baseline.
as @ascent + @descent. Individual characters may have
extents exceeding this value.
+@approximate_char_width:
+@approximate_digit_width:
<!-- ##### FUNCTION pango_font_find_shaper ##### -->
<para>
diff --git a/pango/pango-font.h b/pango/pango-font.h
index 109a7819..d0619f24 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -91,6 +91,7 @@ struct _PangoFontMetrics
int ascent;
int descent;
int approximate_char_width;
+ int approximate_digit_width;
};
PangoFontDescription *pango_font_description_copy (const PangoFontDescription *desc);
diff --git a/pango/pangox.c b/pango/pangox.c
index 172f64aa..06b4cea8 100644
--- a/pango/pangox.c
+++ b/pango/pangox.c
@@ -525,9 +525,9 @@ pango_x_font_get_glyph_extents (PangoFont *font,
static gboolean
get_int_prop (Atom atom,
XFontStruct *fs,
- gint *val)
+ int *val)
{
- gint i;
+ int i;
*val = 0;
@@ -556,8 +556,8 @@ get_font_metrics_from_subfonts (PangoFont *font,
PangoXFont *xfont = (PangoXFont *)font;
GSList *tmp_list = subfonts;
gboolean first = TRUE;
- gint total_avg_widths = 0;
- gint n_avg_widths = 0;
+ int total_avg_widths = 0;
+ int n_avg_widths = 0;
Atom avg_width_atom;
avg_width_atom = pango_x_fontmap_atom_from_name (xfont->fontmap,
@@ -780,12 +780,32 @@ pango_x_font_get_metrics (PangoFont *font,
if (!tmp_list)
{
+ PangoLayout *layout;
+ PangoRectangle extents;
+ PangoContext *context;
+
info = g_new (PangoXMetricsInfo, 1);
info->lang = lookup_lang;
xfont->metrics_by_lang = g_slist_prepend (xfont->metrics_by_lang, info);
get_font_metrics_from_string (font, lang, str, &info->metrics);
+
+ /* This is sort of a sledgehammer solution, but we cache this
+ * stuff so not a huge deal hopefully. Get the avg. width of the
+ * chars in "0123456789"
+ */
+ context = pango_x_get_context (pango_x_fontmap_get_display (xfont->fontmap));
+ pango_context_set_lang (context, lang);
+ layout = pango_layout_new (context);
+ pango_layout_set_text (layout, "0123456789", -1);
+
+ pango_layout_get_extents (layout, NULL, &extents);
+
+ metrics->approximate_digit_width = extents.width / 10;
+
+ g_object_unref (G_OBJECT (layout));
+ g_object_unref (G_OBJECT (context));
}
*metrics = info->metrics;