diff options
author | Povilas Kanapickas <povilas@radix.lt> | 2014-02-13 02:10:06 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2014-02-21 09:32:24 +0100 |
commit | a3740cdc1d881df809cd59efa755c076bd4a6c7e (patch) | |
tree | 662d87e86b04bfeb6facf34f21153bc50b1af06c | |
parent | 790b401ffb0a4fdf7bfb7fcc1c1eec96d229cc32 (diff) |
Wrap FtFontFace::{get,set,unset}_synthesize
-rw-r--r-- | cairomm/enums.h | 38 | ||||
-rw-r--r-- | cairomm/fontface.cc | 15 | ||||
-rw-r--r-- | cairomm/fontface.h | 22 |
3 files changed, 75 insertions, 0 deletions
diff --git a/cairomm/enums.h b/cairomm/enums.h index 26102c0..548a7f3 100644 --- a/cairomm/enums.h +++ b/cairomm/enums.h @@ -20,6 +20,7 @@ #define __CAIROMM_ENUMS_H #include <cairo.h> +#include <cairo-ft.h> namespace Cairo { @@ -809,6 +810,43 @@ typedef enum REGION_OVERLAP_PART = CAIRO_REGION_OVERLAP_PART } RegionOverlap; +/** + * A set of synthesis options to control how FreeType renders the glyphs for a + * particular font face. + * + * FreeType provides the ability to synthesize different glyphs from a base + * font, which is useful if you lack those glyphs from a true bold or oblique + * font. + * + * Individual synthesis features of a @c FtFontFace can be set using + * @c FtFontFace::set_synthesize(), or disabled using + * @c FtFontFace::unset_synthesize(). The currently enabled set of synthesis + * options can be queried with @c FtFontFace::get_synthesize(). + * + * Note: that when synthesizing glyphs, the font metrics returned will only be + * estimates. + * + * @since 1.12 + */ +enum FtSynthesize { + + /// Embolden the glyphs (redraw with a pixel offset) + FT_SYNTHESIZE_BOLT = CAIRO_FT_SYNTHESIZE_BOLD, + + /// Slant the glyph outline by 12 degrees to the right. + FT_SYNTHESIZE_OBLIQUE = CAIRO_FT_SYNTHESIZE_OBLIQUE +}; + +inline FtSynthesize operator|(FtSynthesize a, FtSynthesize b) +{ + return static_cast<FtSynthesize>(static_cast<int>(a) | static_cast<int>(b)); +} + +inline FtSynthesize operator&(FtSynthesize a, FtSynthesize b) +{ + return static_cast<FtSynthesize>(static_cast<int>(a) & static_cast<int>(b)); +} + } // namespace Cairo #endif //__CAIROMM_ENUMS_H diff --git a/cairomm/fontface.cc b/cairomm/fontface.cc index 2071d2f..cb1468f 100644 --- a/cairomm/fontface.cc +++ b/cairomm/fontface.cc @@ -403,6 +403,21 @@ FtFontFace::FtFontFace(FcPattern* pattern) : check_status_and_throw_exception(cairo_font_face_status(m_cobject)); } +void FtFontFace::set_synthesize(FtSynthesize synth_flags) +{ + cairo_ft_font_face_set_synthesize(m_cobject, synth_flags); +} + +void FtFontFace::unset_synthesize(FtSynthesize synth_flags) +{ + cairo_ft_font_face_unset_synthesize(m_cobject, synth_flags); +} + +FtSynthesize FtFontFace::get_synthesize() const +{ + return (FtSynthesize)cairo_ft_font_face_get_synthesize(m_cobject); +} + #endif // CAIRO_HAS_FT_FONT } //namespace Cairo diff --git a/cairomm/fontface.h b/cairomm/fontface.h index 464332a..25268ca 100644 --- a/cairomm/fontface.h +++ b/cairomm/fontface.h @@ -468,6 +468,28 @@ public: */ static RefPtr<FtFontFace> create(FcPattern* pattern); + /** Sets synthesis options to control how FreeType renders the glyphs for a + * particular font face. The given options are ORed with the currently active + * options. + * + * @param synth_flags A set of synthesis options to enable + * @since 1.12 + */ + void set_synthesize(FtSynthesize synth_flags); + + /** Unsets the specified FreeType glypth synthesis options + * + * @param synth_flags A set of synthesis options to disable + * @since 1.12 + */ + void unset_synthesize(FtSynthesize synth_flags); + + /** Returns currently activy FreeType glyph synthesis options + * + * @since 1.12 + */ + FtSynthesize get_synthesize() const; + protected: FtFontFace(FT_Face face, int load_flags); FtFontFace(FcPattern* pattern); |