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 /pango/pangocairo-fontmap.c | |
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
Diffstat (limited to 'pango/pangocairo-fontmap.c')
-rw-r--r-- | pango/pangocairo-fontmap.c | 65 |
1 files changed, 64 insertions, 1 deletions
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); +} |