00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CAIROMM_SCALEDFONT_H
00020 #define __CAIROMM_SCALEDFONT_H
00021
00022 #include <cairomm/refptr.h>
00023 #include <cairomm/fontoptions.h>
00024 #include <cairomm/fontface.h>
00025 #include <cairomm/matrix.h>
00026 #include <cairomm/types.h>
00027 #include <vector>
00028
00029 #ifdef CAIRO_HAS_FT_FONT
00030 #include <cairo-ft.h>
00031 #endif // CAIRO_HAS_FT_FONT
00032
00033 namespace Cairo
00034 {
00035
00040 class ScaledFont
00041 {
00042
00043 public:
00045 typedef cairo_scaled_font_t cobject;
00046
00048 inline cobject* cobj() { return m_cobject; }
00049
00051 inline const cobject* cobj() const { return m_cobject; }
00052
00053 #ifndef DOXYGEN_IGNORE_THIS
00054
00055 inline ErrorStatus get_status() const
00056 { return cairo_scaled_font_status(const_cast<cairo_scaled_font_t*>(cobj())); }
00057
00058
00059 void reference() const { cairo_scaled_font_reference(m_cobject); }
00060 void unreference() const { cairo_scaled_font_destroy(m_cobject); }
00061 #endif //DOXYGEN_IGNORE_THIS
00062
00066 explicit ScaledFont(cobject* cobj, bool has_reference = false);
00067
00068 ~ScaledFont();
00069
00083 static RefPtr<ScaledFont> create(const RefPtr<FontFace>& font_face, const Matrix& font_matrix,
00084 const Matrix& ctm, const FontOptions& options = FontOptions());
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00098 void get_extents(FontExtents& extents) const;
00099
00103 void extents(FontExtents& extents) const;
00104
00125 void get_text_extents(const std::string& utf8, TextExtents& extents) const;
00129 void text_extents(const std::string& utf8, TextExtents& extents) const;
00130
00146 void get_glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents);
00147
00151 void glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents);
00152
00156 RefPtr<FontFace> get_font_face() const;
00157
00161 void get_font_options(FontOptions& options) const;
00162
00166 void get_font_matrix(Matrix& font_matrix) const;
00167
00171 void get_ctm(Matrix& ctm) const;
00172
00176 FontType get_type() const;
00177
00178
00179
00200 void text_to_glyphs(double x,
00201 double y,
00202 const std::string& utf8,
00203 std::vector<Glyph>& glyphs,
00204 std::vector<TextCluster>& clusters,
00205 TextClusterFlags& cluster_flags);
00206
00215 void get_scale_matrix(Matrix& scale_matrix) const;
00216
00217 protected:
00218 ScaledFont(const RefPtr<FontFace>& font_face, const Matrix& font_matrix,
00219 const Matrix& ctm, const FontOptions& options = FontOptions());
00221 cobject* m_cobject;
00222 };
00223
00224 #ifdef CAIRO_HAS_FT_FONT
00225
00226
00230 class FtScaledFont : public ScaledFont
00231 {
00232 public:
00237 static RefPtr<FtScaledFont> create(const RefPtr<FtFontFace>& font_face, const Matrix& font_matrix,
00238 const Matrix& ctm, const FontOptions& options = FontOptions());
00239
00262 FT_Face lock_face();
00263
00268 void unlock_face();
00269
00270 protected:
00271 FtScaledFont(const RefPtr<FtFontFace>& font_face, const Matrix& font_matrix,
00272 const Matrix& ctm, const FontOptions& options = FontOptions());
00273 };
00274 #endif // CAIRO_HAS_FT_FONT
00275
00276 }
00277
00278 #endif // __CAIROMM_SCALEDFONT_H
00279