summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--ChangeLog.pre-1-1014
-rw-r--r--docs/pango-sections.txt2
-rw-r--r--pango/pangocairo-fcfont.c2
-rw-r--r--pango/pangocairo-fcfontmap.c9
-rw-r--r--pango/pangocairo-fontmap.c65
-rw-r--r--pango/pangocairo.h4
-rw-r--r--pango/pangofc-fontmap.c18
-rw-r--r--pango/pangofc-fontmap.h4
9 files changed, 122 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 00f5bb94..8f68a293 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2005-05-17 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangofc-fontmap.[ch]: Add a new context_substitute() virtual
+ function that replaces default_substitute() and adds a
+ PangoContext argument.
+
+ * pango/pangocairo.h pango/pangocairo-fontmap.c docs/pango-sections.txt:
+ Add pango_cairo_context_set/get_hinting() to control
+ hinting on individual contexts.
+
+ * pango/pangocairo-fcfont.c pango/pangocairo-fcfontmap.c:
+ Implement hinting control for the for the fontconfig/cairo
+ backend.
+
Tue May 17 07:21:53 2005 Manish Singh <yosh@gimp.org>
* examples/cairoview.c: update for new cairo_xlib_surface API.
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 00f5bb94..8f68a293 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,17 @@
+2005-05-17 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangofc-fontmap.[ch]: Add a new context_substitute() virtual
+ function that replaces default_substitute() and adds a
+ PangoContext argument.
+
+ * pango/pangocairo.h pango/pangocairo-fontmap.c docs/pango-sections.txt:
+ Add pango_cairo_context_set/get_hinting() to control
+ hinting on individual contexts.
+
+ * pango/pangocairo-fcfont.c pango/pangocairo-fcfontmap.c:
+ Implement hinting control for the for the fontconfig/cairo
+ backend.
+
Tue May 17 07:21:53 2005 Manish Singh <yosh@gimp.org>
* examples/cairoview.c: update for new cairo_xlib_surface API.
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index 20584dc5..6838df62 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -778,6 +778,8 @@ pango_cairo_font_map_get_default
pango_cairo_font_map_set_resolution
pango_cairo_font_map_get_resolution
pango_cairo_font_map_create_context
+pango_cairo_context_set_hinting
+pango_cairo_context_get_hinting
pango_cairo_update_context
pango_cairo_create_layout
pango_cairo_update_layout
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index cde571bf..326cd3e5 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -341,7 +341,7 @@ _pango_cairo_fc_get_render_key (PangoCairoFcFontMap *cffontmap,
*xsize = (int) (xscale * size + 0.5);
*ysize = (int) (xscale * size + 0.5);
- *flags = 0;
+ *flags = pango_cairo_context_get_hinting (context);
if (matrix)
{
diff --git a/pango/pangocairo-fcfontmap.c b/pango/pangocairo-fcfontmap.c
index a1a107e9..e032c9d5 100644
--- a/pango/pangocairo-fcfontmap.c
+++ b/pango/pangocairo-fcfontmap.c
@@ -86,7 +86,8 @@ pango_cairo_fc_font_map_finalize (GObject *object)
}
static void
-pango_cairo_fc_font_map_default_substitute (PangoFcFontMap *fcfontmap,
+pango_cairo_fc_font_map_context_substitute (PangoFcFontMap *fcfontmap,
+ PangoContext *context,
FcPattern *pattern)
{
PangoCairoFcFontMap *cffontmap = PANGO_CAIRO_FC_FONT_MAP (fcfontmap);
@@ -96,6 +97,10 @@ pango_cairo_fc_font_map_default_substitute (PangoFcFontMap *fcfontmap,
if (FcPatternGet (pattern, FC_DPI, 0, &v) == FcResultNoMatch)
FcPatternAddDouble (pattern, FC_DPI, cffontmap->dpi);
+
+ if (!pango_cairo_context_get_hinting (context))
+ FcPatternAddBool (pattern, FC_HINTING, FcFalse);
+
FcDefaultSubstitute (pattern);
}
@@ -128,7 +133,7 @@ pango_cairo_fc_font_map_class_init (PangoCairoFcFontMapClass *class)
PangoFcFontMapClass *fcfontmap_class = PANGO_FC_FONT_MAP_CLASS (class);
gobject_class->finalize = pango_cairo_fc_font_map_finalize;
- fcfontmap_class->default_substitute = pango_cairo_fc_font_map_default_substitute;
+ fcfontmap_class->context_substitute = pango_cairo_fc_font_map_context_substitute;
fcfontmap_class->get_render_key = pango_cairo_fc_font_map_get_render_key;
fcfontmap_class->create_font = pango_cairo_fc_font_map_create_font;
}
diff --git a/pango/pangocairo-fontmap.c b/pango/pangocairo-fontmap.c
index f8cd2ab8..5b72375c 100644
--- a/pango/pangocairo-fontmap.c
+++ b/pango/pangocairo-fontmap.c
@@ -226,6 +226,71 @@ pango_cairo_update_context (cairo_t *cr,
pango_context_set_matrix (context, &pango_matrix);
}
+typedef struct _PangoCairoContextInfo PangoCairoContextInfo;
+
+struct _PangoCairoContextInfo
+{
+ gboolean hinting;
+};
+
+static PangoCairoContextInfo *
+get_context_info (PangoContext *context,
+ gboolean create)
+{
+ PangoCairoContextInfo *info = g_object_get_data (G_OBJECT (context),
+ "pango-cairo-context-info");
+ if (!info && create)
+ {
+ info = g_new (PangoCairoContextInfo, 1);
+ info->hinting = TRUE;
+
+ g_object_set_data_full (G_OBJECT (context), "pango-cairo-context-info",
+ info, (GDestroyNotify)g_free);
+ }
+
+ return info;
+}
+
+/**
+ * pango_cairo_context_set_hinting:
+ * @context: a #PangoContext, from pango_cairo_font_map_create_context()
+ * @hinting: %TRUE if hinting should be enabled.
+ *
+ * Sets whether outlines and font metrics should be hinted for this
+ * context. Hinting is the process of adjusting outlines so that they
+ * render better when drawn onto a pixel grid. When hinting is
+ * enabled, font metrics such as character widths and font ascent and
+ * descent are quantized to integer pixel values.
+ *
+ * If layouts have been previously created for this context, it is
+ * necessary to call pango_layout_context_changed() in order to update
+ * the layouts.
+ **/
+void
+pango_cairo_context_set_hinting (PangoContext *context,
+ gboolean hinting)
+{
+ PangoCairoContextInfo *info = get_context_info (context, TRUE);
+ info->hinting = hinting != FALSE;
+}
+
+/**
+ * pango_cairo_context_get_hinting:
+ * @context: a #PangoContext, from pango_cairo_font_map_create_context()
+ *
+ * Gets whether hinting is enabled for this context. See
+ * pango_cairo_context_set_hinting()
+ *
+ * Return value: %TRUE if hinting is enabled.
+ **/
+gboolean
+pango_cairo_context_get_hinting (PangoContext *context)
+{
+ PangoCairoContextInfo *info = get_context_info (context, FALSE);
+
+ return !info || info->hinting;
+}
+
/**
* pango_cairo_create_layout:
* @cr: a Cairo context
diff --git a/pango/pangocairo.h b/pango/pangocairo.h
index 147e619c..ba0949fc 100644
--- a/pango/pangocairo.h
+++ b/pango/pangocairo.h
@@ -62,6 +62,10 @@ PangoContext *pango_cairo_font_map_create_context (PangoCairoFontMap *fontmap);
void pango_cairo_update_context (cairo_t *cr,
PangoContext *context);
+void pango_cairo_context_set_hinting (PangoContext *context,
+ gboolean hinting);
+gboolean pango_cairo_context_get_hinting (PangoContext *context);
+
/* Convenience
*/
PangoLayout *pango_cairo_create_layout (cairo_t *cr);
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index c4068db3..7804c2e0 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -818,14 +818,18 @@ uniquify_pattern (PangoFcFontMap *fcfontmap,
static void
pango_fc_default_substitute (PangoFcFontMap *fontmap,
- FcPattern *pattern)
+ PangoContext *context,
+ FcPattern *pattern)
{
- if (PANGO_FC_FONT_MAP_GET_CLASS (fontmap)->default_substitute)
+ if (PANGO_FC_FONT_MAP_GET_CLASS (fontmap)->context_substitute)
+ PANGO_FC_FONT_MAP_GET_CLASS (fontmap)->context_substitute (fontmap, context, pattern);
+ else if (PANGO_FC_FONT_MAP_GET_CLASS (fontmap)->default_substitute)
PANGO_FC_FONT_MAP_GET_CLASS (fontmap)->default_substitute (fontmap, pattern);
}
static gdouble
-pango_fc_font_map_get_dpi (PangoFcFontMap *fcfontmap)
+pango_fc_font_map_get_dpi (PangoFcFontMap *fcfontmap,
+ PangoContext *context)
{
if (fcfontmap->priv->dpi < 0)
{
@@ -836,7 +840,7 @@ pango_fc_font_map_get_dpi (PangoFcFontMap *fcfontmap)
NULL);
if (tmp)
{
- pango_fc_default_substitute (fcfontmap, tmp);
+ pango_fc_default_substitute (fcfontmap, NULL, tmp);
result = FcPatternGetDouble (tmp, FC_DPI, 0, &fcfontmap->priv->dpi);
FcPatternDestroy (tmp);
}
@@ -881,7 +885,7 @@ pango_fc_font_map_get_render_key (PangoFcFontMap *fcfontmap,
if (pango_font_description_get_size_is_absolute (desc))
size = pango_font_description_get_size (desc);
else
- size = pango_fc_font_map_get_dpi (fcfontmap) * pango_font_description_get_size (desc) / 72.;
+ size = pango_fc_font_map_get_dpi (fcfontmap, context) * pango_font_description_get_size (desc) / 72.;
if (context)
matrix = pango_context_get_matrix (context);
@@ -947,7 +951,7 @@ pango_fc_font_map_get_patterns (PangoFontMap *fontmap,
{
pattern = pango_fc_make_pattern (desc, language, key.y_size / 1024.);
- pango_fc_default_substitute (fcfontmap, pattern);
+ pango_fc_default_substitute (fcfontmap, context, pattern);
font_patterns = FcFontSort (NULL, pattern, FcTrue, NULL, &res);
@@ -1609,7 +1613,7 @@ pango_fc_face_list_sizes (PangoFontFace *face,
if (FcPatternGetDouble (fontset->fonts[i], FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
{
if (dpi < 0)
- dpi = pango_fc_font_map_get_dpi (fcface->family->fontmap);
+ dpi = pango_fc_font_map_get_dpi (fcface->family->fontmap, NULL);
size_i = (int) (PANGO_SCALE * size * 72.0 / dpi);
g_array_append_val (size_array, size_i);
diff --git a/pango/pangofc-fontmap.h b/pango/pangofc-fontmap.h
index 4e98bc78..a6f4d511 100644
--- a/pango/pangofc-fontmap.h
+++ b/pango/pangofc-fontmap.h
@@ -89,6 +89,7 @@ struct _PangoFcFontMapClass
PangoFontMapClass parent_class;
/*< public >*/
+ /* Deprecated in favor of context_substitute */
void (*default_substitute) (PangoFcFontMap *fontmap,
FcPattern *pattern);
/* Deprecated in favor of create_font */
@@ -101,6 +102,9 @@ struct _PangoFcFontMapClass
int *xsize,
int *ysize,
guint *flags);
+ void (*context_substitute) (PangoFcFontMap *fontmap,
+ PangoContext *context,
+ FcPattern *pattern);
PangoFcFont *(*create_font) (PangoFcFontMap *fontmap,
PangoContext *context,
const PangoFontDescription *desc,