summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-05-22 20:10:08 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-05-22 20:10:08 +0000
commitec8d35bf511a8dcdd612850917e1e9ae9b36e1d0 (patch)
treef53a6154f829fc6ff81f278d7176c84ce4c290af
parentf9697a634b7267fa0743e47561c28b3ca3ae226b (diff)
downloadpango-ec8d35bf511a8dcdd612850917e1e9ae9b36e1d0.tar.gz
New function pango_font_describe_with_absolute_size().
2006-05-22 Behdad Esfahbod <behdad@gnome.org> * pango/pango-font.h, pango/fonts.c: New function pango_font_describe_with_absolute_size(). * pango/pangocairo-font.c (_pango_cairo_font_get_hex_box_info): * pango/pangocairo-win32font.c (create_metrics_for_context): * pango/pangofc-font.c (pango_fc_font_class_init), (pango_fc_font_describe_absolute), (pango_fc_font_create_metrics_for_context): * pango/pangowin32.c (pango_win32_font_class_init), (pango_win32_font_get_metrics), (pango_win32_font_describe), (pango_win32_font_describe_absolute): Implement and use PangoFontClass->describe_absolute.
-rw-r--r--ChangeLog15
-rw-r--r--docs/pango-sections.txt1
-rw-r--r--docs/tmpl/fonts.sgml9
-rw-r--r--pango/fonts.c28
-rw-r--r--pango/pango-font.h3
-rw-r--r--pango/pango.def1
-rw-r--r--pango/pangocairo-font.c17
-rw-r--r--pango/pangocairo-win32font.c2
-rw-r--r--pango/pangofc-font.c19
-rw-r--r--pango/pangowin32.c18
10 files changed, 96 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 94fcec35..fe666f9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2006-05-22 Behdad Esfahbod <behdad@gnome.org>
+ * pango/pango-font.h, pango/fonts.c: New function
+ pango_font_describe_with_absolute_size().
+
+ * pango/pangocairo-font.c (_pango_cairo_font_get_hex_box_info):
+ * pango/pangocairo-win32font.c (create_metrics_for_context):
+ * pango/pangofc-font.c (pango_fc_font_class_init),
+ (pango_fc_font_describe_absolute),
+ (pango_fc_font_create_metrics_for_context):
+ * pango/pangowin32.c (pango_win32_font_class_init),
+ (pango_win32_font_get_metrics), (pango_win32_font_describe),
+ (pango_win32_font_describe_absolute): Implement and use
+ PangoFontClass->describe_absolute.
+
+2006-05-22 Behdad Esfahbod <behdad@gnome.org>
+
Bug 339730 – Pango needlessly falls back away from a Type 1 font into
a TTF font
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index e7f86471..bca9ba01 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -197,6 +197,7 @@ PANGO_FONT
PANGO_IS_FONT
pango_font_find_shaper
pango_font_describe
+pango_font_describe_with_absolute_size
pango_font_get_coverage
pango_font_get_glyph_extents
pango_font_get_metrics
diff --git a/docs/tmpl/fonts.sgml b/docs/tmpl/fonts.sgml
index 416a1870..a1009747 100644
--- a/docs/tmpl/fonts.sgml
+++ b/docs/tmpl/fonts.sgml
@@ -588,6 +588,15 @@ Returns %TRUE if @object is a #PangoFont.
@Returns:
+<!-- ##### FUNCTION pango_font_describe_with_absolute_size ##### -->
+<para>
+
+</para>
+
+@font:
+@Returns:
+
+
<!-- ##### FUNCTION pango_font_get_coverage ##### -->
<para>
diff --git a/pango/fonts.c b/pango/fonts.c
index 38f459ef..bbc70106 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1106,7 +1106,9 @@ pango_font_init (PangoFont *font)
* pango_font_describe:
* @font: a #PangoFont
*
- * Returns a description of the font.
+ * Returns a description of the font, with font size set in points.
+ * Use pango_font_describe_with_absolute_size() if you want the font
+ * size in device units.
*
* Return value: a newly-allocated #PangoFontDescription object.
**/
@@ -1119,6 +1121,30 @@ pango_font_describe (PangoFont *font)
}
/**
+ * pango_font_describe_with_absolute_size:
+ * @font: a #PangoFont
+ *
+ * Returns a description of the font, with absolute font size set
+ * (in device units). Use pango_font_describe() if you want the font
+ * size in points.
+ *
+ * Return value: a newly-allocated #PangoFontDescription object.
+ **/
+PangoFontDescription *
+pango_font_describe_with_absolute_size (PangoFont *font)
+{
+ g_return_val_if_fail (font != NULL, NULL);
+
+ if (G_UNLIKELY (!PANGO_FONT_GET_CLASS (font)->describe_absolute))
+ {
+ g_warning ("describe_absolute not implemented for this font class, report this as a bug");
+ return pango_font_describe (font);
+ }
+
+ return PANGO_FONT_GET_CLASS (font)->describe_absolute (font);
+}
+
+/**
* pango_font_get_coverage:
* @font: a #PangoFont
* @language: the language tag
diff --git a/pango/pango-font.h b/pango/pango-font.h
index 58d796ab..5b30c4ca 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -304,6 +304,7 @@ struct _PangoFontFaceClass
GType pango_font_get_type (void) G_GNUC_CONST;
PangoFontDescription *pango_font_describe (PangoFont *font);
+PangoFontDescription *pango_font_describe_with_absolute_size (PangoFont *font);
PangoCoverage * pango_font_get_coverage (PangoFont *font,
PangoLanguage *language);
PangoEngineShape * pango_font_find_shaper (PangoFont *font,
@@ -349,12 +350,12 @@ struct _PangoFontClass
PangoFontMetrics * (*get_metrics) (PangoFont *font,
PangoLanguage *language);
PangoFontMap * (*get_font_map) (PangoFont *font);
+ PangoFontDescription *(*describe_absolute) (PangoFont *font);
/*< private >*/
/* Padding for future expansion */
void (*_pango_reserved1) (void);
void (*_pango_reserved2) (void);
- void (*_pango_reserved3) (void);
};
/* used for very rare and miserable situtations that we cannot even
diff --git a/pango/pango.def b/pango/pango.def
index cb88c903..4733905e 100644
--- a/pango/pango.def
+++ b/pango/pango.def
@@ -86,6 +86,7 @@ EXPORTS
pango_find_map
pango_find_paragraph_boundary
pango_font_describe
+ pango_font_describe_with_absolute_size
pango_font_description_better_match
pango_font_description_copy
pango_font_description_copy_static
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 878e3ba4..0e42a82f 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -184,13 +184,8 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
fontmap = pango_font_get_font_map ((PangoFont *)cfont);
- desc = pango_font_describe ((PangoFont *)cfont);
+ desc = pango_font_describe_with_absolute_size ((PangoFont *)cfont);
size = pango_font_description_get_size (desc) / (1.*PANGO_SCALE);
- if (pango_font_description_get_size_is_absolute (desc))
- {
- int dpi = pango_cairo_font_map_get_resolution (PANGO_CAIRO_FONT_MAP (fontmap));
- size = size * 72. / dpi;
- }
mini_desc = pango_font_description_new ();
pango_font_description_set_family_static (mini_desc, "monospace");
@@ -201,12 +196,12 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
if (is_hinted)
{
mini_size = HINT_Y (mini_size);
- }
- if (mini_size < 5.0)
- {
- rows = 1;
- mini_size = MIN (MAX (size - 1, 0), 5.0);
+ if (mini_size < 5.0)
+ {
+ rows = 1;
+ mini_size = MIN (MAX (size - 1, 0), 5.0);
+ }
}
pango_font_description_set_size (mini_desc, mini_size * PANGO_SCALE);
diff --git a/pango/pangocairo-win32font.c b/pango/pangocairo-win32font.c
index 4de0d2b4..a7ef250a 100644
--- a/pango/pangocairo-win32font.c
+++ b/pango/pangocairo-win32font.c
@@ -308,7 +308,7 @@ create_metrics_for_context (PangoFont *font,
&metrics->strikethrough_position);
layout = pango_layout_new (context);
- font_desc = pango_font_describe (font);
+ font_desc = pango_font_describe_with_absolute_size (font);
pango_layout_set_font_description (layout, font_desc);
pango_layout_set_text (layout, sample_str, -1);
pango_layout_get_extents (layout, NULL, &extents);
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index e31155a0..da9b9754 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -83,6 +83,7 @@ static PangoFontMetrics * pango_fc_font_get_metrics (PangoFont *font,
PangoLanguage *language);
static PangoFontMap * pango_fc_font_get_font_map (PangoFont *font);
static PangoFontDescription *pango_fc_font_describe (PangoFont *font);
+static PangoFontDescription *pango_fc_font_describe_absolute (PangoFont *font);
#define PANGO_FC_FONT_LOCK_FACE(font) (PANGO_FC_FONT_GET_CLASS (font)->lock_face (font))
@@ -103,6 +104,7 @@ pango_fc_font_class_init (PangoFcFontClass *class)
object_class->finalize = pango_fc_font_finalize;
object_class->set_property = pango_fc_font_set_property;
font_class->describe = pango_fc_font_describe;
+ font_class->describe_absolute = pango_fc_font_describe_absolute;
font_class->find_shaper = pango_fc_font_find_shaper;
font_class->get_coverage = pango_fc_font_get_coverage;
font_class->get_metrics = pango_fc_font_get_metrics;
@@ -227,6 +229,19 @@ pango_fc_font_describe (PangoFont *font)
return pango_font_description_copy (fcfont->description);
}
+static PangoFontDescription *
+pango_fc_font_describe_absolute (PangoFont *font)
+{
+ PangoFcFont *fcfont = (PangoFcFont *)font;
+ PangoFontDescription *desc = pango_font_description_copy (fcfont->description);
+ double size;
+
+ if (FcPatternGetDouble (fcfont->font_pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
+ pango_font_description_set_absolute_size (desc, size * PANGO_SCALE);
+
+ return desc;
+}
+
static PangoMap *
pango_fc_get_shaper_map (PangoLanguage *language)
{
@@ -401,13 +416,15 @@ pango_fc_font_create_metrics_for_context (PangoFcFont *fcfont,
PangoRectangle extents;
PangoLanguage *language = pango_context_get_language (context);
const char *sample_str = pango_language_get_sample_string (language);
+ PangoFontDescription *desc = pango_font_describe_with_absolute_size (fcfont);
metrics = pango_font_metrics_new ();
get_face_metrics (fcfont, metrics);
layout = pango_layout_new (context);
- pango_layout_set_font_description (layout, fcfont->description);
+ pango_layout_set_font_description (layout, desc);
+ pango_font_description_free (desc);
pango_layout_set_text (layout, sample_str, -1);
pango_layout_get_extents (layout, NULL, &extents);
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index fff3ac61..37d20be2 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -49,6 +49,7 @@ static void pango_win32_font_real_done_font (PangoFont *font);
static double pango_win32_font_real_get_metrics_factor (PangoFont *font);
static PangoFontDescription *pango_win32_font_describe (PangoFont *font);
+static PangoFontDescription *pango_win32_font_describe_absolute (PangoFont *font);
static PangoCoverage *pango_win32_font_get_coverage (PangoFont *font,
PangoLanguage *lang);
static void pango_win32_font_calc_coverage (PangoFont *font,
@@ -200,6 +201,7 @@ pango_win32_font_class_init (PangoWin32FontClass *class)
object_class->dispose = pango_win32_font_dispose;
font_class->describe = pango_win32_font_describe;
+ font_class->describe_absolute = pango_win32_font_describe;
font_class->get_coverage = pango_win32_font_get_coverage;
font_class->find_shaper = pango_win32_font_find_shaper;
font_class->get_glyph_extents = pango_win32_font_get_glyph_extents;
@@ -582,7 +584,7 @@ pango_win32_font_get_metrics (PangoFont *font,
/* Get the average width of the chars in "0123456789" */
context = pango_win32_get_context ();
pango_context_set_language (context, language);
- font_desc = pango_font_describe (font);
+ font_desc = pango_font_describe_with_absolute_size (font);
pango_context_set_font_description (context, font_desc);
layout = pango_layout_new (context);
pango_layout_set_text (layout, "0123456789", -1);
@@ -782,7 +784,19 @@ pango_win32_font_describe (PangoFont *font)
PangoWin32Font *win32font = PANGO_WIN32_FONT (font);
desc = pango_font_description_copy (win32font->win32face->description);
- pango_font_description_set_size (desc, win32font->size);
+ pango_font_description_set_size (desc, win32font->size /* TODO */);
+
+ return desc;
+}
+
+static PangoFontDescription *
+pango_win32_font_describe_absolute (PangoFont *font)
+{
+ PangoFontDescription *desc;
+ PangoWin32Font *win32font = PANGO_WIN32_FONT (font);
+
+ desc = pango_font_description_copy (win32font->win32face->description);
+ pango_font_description_set_absolute_size (desc, win32font->size);
return desc;
}