diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2007-06-11 03:00:39 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2007-06-11 03:00:39 +0000 |
commit | c82dcf4c9cda78350bc844f6187bac5df87f5444 (patch) | |
tree | 84e809493cffad93cb3fcc0f65558499e2c6f405 | |
parent | 1bc615b0a5863c5680770171f014a1f99c975a9e (diff) | |
download | pango-c82dcf4c9cda78350bc844f6187bac5df87f5444.tar.gz |
Bug 347236 – provide pango_cairo_font_get_scaled_font Bug 347235 – Add
2007-06-10 Behdad Esfahbod <behdad@gnome.org>
Bug 347236 – provide pango_cairo_font_get_scaled_font
Bug 347235 – Add pango_cairo_font_map_get_font_type
Bug 353291 – Provide pango_cairo_font_map_new_for_font_type
* pango/pangocairo-font.c: New public API:
pango_cairo_font_get_scaled_font()
* pango/pangocairo-fontmap.c: New public API:
pango_cairo_font_map_new_for_font_type()
pango_cairo_font_map_get_font_type()
* pango/pangocairo-fcfontmap.c:
Implement get_font_type() method.
* pango/pangocairo.h:
* pango/pangocairo-private.h:
* docs/pango-sections.txt:
* docs/tmpl/pangocairo.sgml:
* pango/pangocairo.def:
Update.
svn path=/trunk/; revision=2336
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | docs/pango-sections.txt | 5 | ||||
-rw-r--r-- | docs/tmpl/pangocairo.sgml | 29 | ||||
-rw-r--r-- | pango/pangocairo-fcfontmap.c | 7 | ||||
-rw-r--r-- | pango/pangocairo-font.c | 22 | ||||
-rw-r--r-- | pango/pangocairo-fontmap.c | 65 | ||||
-rw-r--r-- | pango/pangocairo-private.h | 2 | ||||
-rw-r--r-- | pango/pangocairo-render.c | 4 | ||||
-rw-r--r-- | pango/pangocairo.def | 3 | ||||
-rw-r--r-- | pango/pangocairo.h | 13 |
10 files changed, 162 insertions, 13 deletions
@@ -1,3 +1,28 @@ +2007-06-10 Behdad Esfahbod <behdad@gnome.org> + + Bug 347236 – provide pango_cairo_font_get_scaled_font + Bug 347235 – Add pango_cairo_font_map_get_font_type + Bug 353291 – Provide pango_cairo_font_map_new_for_font_type + + * pango/pangocairo-font.c: New public API: + + pango_cairo_font_get_scaled_font() + + * pango/pangocairo-fontmap.c: New public API: + + pango_cairo_font_map_new_for_font_type() + pango_cairo_font_map_get_font_type() + + * pango/pangocairo-fcfontmap.c: + Implement get_font_type() method. + + * pango/pangocairo.h: + * pango/pangocairo-private.h: + * docs/pango-sections.txt: + * docs/tmpl/pangocairo.sgml: + * pango/pangocairo.def: + Update. + 2007-06-09 Behdad Esfahbod <behdad@gnome.org> Bug 337593 – move glyph extents code (and cache) from diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt index d50b1a6e..4623cbf0 100644 --- a/docs/pango-sections.txt +++ b/docs/pango-sections.txt @@ -822,11 +822,14 @@ pango_xft_renderer_get_type <TITLE>Cairo Rendering</TITLE> <FILE>pangocairo</FILE> PangoCairoFontMap -pango_cairo_font_map_new pango_cairo_font_map_get_default +pango_cairo_font_map_new +pango_cairo_font_map_new_for_font_type +pango_cairo_font_map_get_font_type pango_cairo_font_map_set_resolution pango_cairo_font_map_get_resolution pango_cairo_font_map_create_context +pango_cairo_font_get_scaled_font pango_cairo_context_set_resolution pango_cairo_context_get_resolution pango_cairo_context_set_font_options diff --git a/docs/tmpl/pangocairo.sgml b/docs/tmpl/pangocairo.sgml index 0299893d..8f6b5fd1 100644 --- a/docs/tmpl/pangocairo.sgml +++ b/docs/tmpl/pangocairo.sgml @@ -151,6 +151,14 @@ int main (int argc, char **argv) </para> +<!-- ##### FUNCTION pango_cairo_font_map_get_default ##### --> +<para> + +</para> + +@Returns: + + <!-- ##### FUNCTION pango_cairo_font_map_new ##### --> <para> @@ -159,11 +167,21 @@ int main (int argc, char **argv) @Returns: -<!-- ##### FUNCTION pango_cairo_font_map_get_default ##### --> +<!-- ##### FUNCTION pango_cairo_font_map_new_for_font_type ##### --> <para> </para> +@fonttype: +@Returns: + + +<!-- ##### FUNCTION pango_cairo_font_map_get_font_type ##### --> +<para> + +</para> + +@fontmap: @Returns: @@ -194,6 +212,15 @@ int main (int argc, char **argv) @Returns: +<!-- ##### FUNCTION pango_cairo_font_get_scaled_font ##### --> +<para> + +</para> + +@font: +@Returns: + + <!-- ##### FUNCTION pango_cairo_context_set_resolution ##### --> <para> diff --git a/pango/pangocairo-fcfontmap.c b/pango/pangocairo-fcfontmap.c index bcecb059..967ca8f4 100644 --- a/pango/pangocairo-fcfontmap.c +++ b/pango/pangocairo-fcfontmap.c @@ -52,11 +52,18 @@ pango_cairo_fc_font_map_get_resolution_cairo (PangoCairoFontMap *cfontmap) return cffontmap->dpi; } +static cairo_font_type_t +pango_cairo_fc_font_map_get_font_type (PangoCairoFontMap *cfontmap) +{ + return CAIRO_FONT_TYPE_FT; +} + static void cairo_font_map_iface_init (PangoCairoFontMapIface *iface) { iface->set_resolution = pango_cairo_fc_font_map_set_resolution; iface->get_resolution = pango_cairo_fc_font_map_get_resolution_cairo; + iface->get_font_type = pango_cairo_fc_font_map_get_font_type; } G_DEFINE_TYPE_WITH_CODE (PangoCairoFcFontMap, pango_cairo_fc_font_map, PANGO_TYPE_FC_FONT_MAP, diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c index 5f439998..9b449c0e 100644 --- a/pango/pangocairo-font.c +++ b/pango/pangocairo-font.c @@ -140,8 +140,20 @@ done: return cf_priv->scaled_font; } -static cairo_scaled_font_t * -_pango_cairo_font_get_scaled_font (PangoFont *cfont) +/** + * pango_cairo_font_get_scaled_font: + * @font: a #PangoFont from a #PangoCairoFontMap + * + * Gets the #cairo_scaled_font_t used by @font. + * The scaled font can be referenced and ketp using + * cairo_scaled_font_reference(). + * + * Return value: the #cairo_scaled_font_t used by @font + * + * Since: 1.18 + **/ +cairo_scaled_font_t * +pango_cairo_font_get_scaled_font (PangoFont *cfont) { PangoCairoFontPrivate *cf_priv; @@ -150,7 +162,7 @@ _pango_cairo_font_get_scaled_font (PangoFont *cfont) if (!_pango_cairo_warning_history.font_get_scaled_font) { _pango_cairo_warning_history.font_get_scaled_font = TRUE; - g_warning ("_pango_cairo_font_get_scaled_font called with bad font, expect ugly output"); + g_warning ("pango_cairo_font_get_scaled_font called with bad font, expect ugly output"); } return NULL; } @@ -174,7 +186,7 @@ gboolean _pango_cairo_font_install (PangoFont *font, cairo_t *cr) { - cairo_scaled_font_t *scaled_font = _pango_cairo_font_get_scaled_font (font); + cairo_scaled_font_t *scaled_font = pango_cairo_font_get_scaled_font (font); if (G_UNLIKELY (scaled_font == NULL || cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS)) return FALSE; @@ -392,7 +404,7 @@ _pango_cairo_font_private_get_hex_box_info (PangoCairoFontPrivate *cf_priv) cairo_font_options_destroy (font_options); - scaled_mini_font = _pango_cairo_font_get_scaled_font (mini_font); + scaled_mini_font = pango_cairo_font_get_scaled_font (mini_font); for (i = 0 ; i < 16 ; i++) { diff --git a/pango/pangocairo-fontmap.c b/pango/pangocairo-fontmap.c index e16579e2..31e36621 100644 --- a/pango/pangocairo-fontmap.c +++ b/pango/pangocairo-fontmap.c @@ -95,10 +95,55 @@ pango_cairo_font_map_new (void) return g_object_new (PANGO_TYPE_CAIRO_WIN32_FONT_MAP, NULL); #elif defined(HAVE_CAIRO_FREETYPE) return g_object_new (PANGO_TYPE_CAIRO_FC_FONT_MAP, NULL); +#else + g_assert_not_reached (); + return NULL; #endif } /** + * pango_cairo_font_map_new_for_font_type: + * + * Creates a new #PangoCairoFontMap object of the type suitable + * to be used with cairo font backend of type @fonttype. + * + * In most cases one should simply use @pango_cairo_font_map_new(), + * or in fact in most of those cases, just use + * @pango_cairo_font_map_get_default(). + * + * Return value: the newly allocated #PangoFontMap of suitable type + * which should be freed with g_object_unref(), + * or %NULL if the requested cairo font backend is + * not supported. + * + * Since: 1.18 + **/ +PangoFontMap * +pango_cairo_font_map_new_for_font_type (cairo_font_type_t fonttype) +{ + /* Make sure that the type system is initialized */ + g_type_init (); + + switch (fonttype) + { +#if defined(HAVE_CAIRO_ATSUI) + case CAIRO_FONT_TYPE_ATSUI: + return g_object_new (PANGO_TYPE_CAIRO_ATSUI_FONT_MAP, NULL); +#endif +#if defined(HAVE_CAIRO_WIN32) + case CAIRO_FONT_TYPE_WIN32: + return g_object_new (PANGO_TYPE_CAIRO_WIN32_FONT_MAP, NULL); +#endif +#if defined(HAVE_CAIRO_FREETYPE) + case CAIRO_FONT_TYPE_FT: + return g_object_new (PANGO_TYPE_CAIRO_FC_FONT_MAP, NULL); +#endif + default: + return NULL; + } +} + +/** * pango_cairo_font_map_get_default: * * Gets a default font map to use with Cairo. @@ -113,7 +158,7 @@ pango_cairo_font_map_get_default (void) { static PangoFontMap *default_font_map = NULL; - if (!default_font_map) + if (G_UNLIKELY (!default_font_map)) default_font_map = pango_cairo_font_map_new (); return default_font_map; @@ -181,3 +226,21 @@ pango_cairo_font_map_create_context (PangoCairoFontMap *fontmap) return context; } + +/** + * pango_cairo_font_map_get_font_type: + * @fontmap: a #PangoCairoFontMap + * + * Gets the type of Cairo font backend that @fontmap uses. + * + * Return value: the #cairo_font_type_t cairo font backend type + * + * Since: 1.18 + **/ +cairo_font_type_t +pango_cairo_font_map_get_font_type (PangoCairoFontMap *fontmap) +{ + g_return_val_if_fail (PANGO_IS_CAIRO_FONT_MAP (fontmap), CAIRO_FONT_TYPE_TOY); + + return (* PANGO_CAIRO_FONT_MAP_GET_IFACE (fontmap)->get_font_type) (fontmap); +} diff --git a/pango/pangocairo-private.h b/pango/pangocairo-private.h index e5a7c382..1fb100a2 100644 --- a/pango/pangocairo-private.h +++ b/pango/pangocairo-private.h @@ -39,6 +39,8 @@ struct _PangoCairoFontMapIface void (*set_resolution) (PangoCairoFontMap *fontmap, double dpi); double (*get_resolution) (PangoCairoFontMap *fontmap); + + cairo_font_type_t (*get_font_type) (PangoCairoFontMap *fontmap); }; diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c index d14d980d..b0ef136d 100644 --- a/pango/pangocairo-render.c +++ b/pango/pangocairo-render.c @@ -602,7 +602,7 @@ _pango_cairo_do_error_underline (cairo_t *cr, /** * pango_cairo_show_glyph_string: * @cr: a Cairo context - * @font: a #PangoFont + * @font: a #PangoFont from a #PangoCairoFontMap * @glyphs: a #PangoGlyphString * * Draws the glyphs in @glyphs in the specified cairo context. @@ -696,7 +696,7 @@ pango_cairo_show_error_underline (cairo_t *cr, /** * pango_cairo_glyph_string_path * @cr: a Cairo context - * @font: a #PangoFont + * @font: a #PangoFont from a #PangoCairoFontMap * @glyphs: a #PangoGlyphString * * Adds the glyphs in @glyphs to the current path in the specified diff --git a/pango/pangocairo.def b/pango/pangocairo.def index 308bc7a9..b16c0f2a 100644 --- a/pango/pangocairo.def +++ b/pango/pangocairo.def @@ -10,11 +10,14 @@ EXPORTS ; pango_cairo_fc_font_get_type ; pango_cairo_fc_font_map_get_type pango_cairo_font_get_type + pango_cairo_font_get_scaled_font pango_cairo_font_map_create_context pango_cairo_font_map_get_default + pango_cairo_font_map_get_font_type pango_cairo_font_map_get_resolution pango_cairo_font_map_get_type pango_cairo_font_map_new + pango_cairo_font_map_new_for_font_type pango_cairo_font_map_set_resolution pango_cairo_glyph_string_path pango_cairo_layout_line_path diff --git a/pango/pangocairo.h b/pango/pangocairo.h index d8085112..2e75b28d 100644 --- a/pango/pangocairo.h +++ b/pango/pangocairo.h @@ -52,16 +52,23 @@ typedef void (* PangoCairoShapeRendererFunc) (cairo_t *cr, /* * PangoCairoFontMap */ -GType pango_cairo_font_map_get_type (void); +GType pango_cairo_font_map_get_type (void); -PangoFontMap *pango_cairo_font_map_new (void); -PangoFontMap *pango_cairo_font_map_get_default (void); +PangoFontMap *pango_cairo_font_map_new (void); +PangoFontMap *pango_cairo_font_map_new_for_font_type (cairo_font_type_t fonttype); +PangoFontMap *pango_cairo_font_map_get_default (void); +cairo_font_type_t pango_cairo_font_map_get_font_type (PangoCairoFontMap *fontmap); void pango_cairo_font_map_set_resolution (PangoCairoFontMap *fontmap, double dpi); double pango_cairo_font_map_get_resolution (PangoCairoFontMap *fontmap); PangoContext *pango_cairo_font_map_create_context (PangoCairoFontMap *fontmap); +/* + * PangoFont methods available to PangoCairo fonts + */ +cairo_scaled_font_t *pango_cairo_font_get_scaled_font (PangoFont *font); + /* Update a Pango context for the current state of a cairo context */ void pango_cairo_update_context (cairo_t *cr, |