scaledfont.h
Go to the documentation of this file.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 static RefPtr<ScaledFont> create(const RefPtr<FontFace>& font_face, const cairo_matrix_t& font_matrix,
00087 const cairo_matrix_t& ctm, const FontOptions& options = FontOptions());
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00101 void get_extents(FontExtents& extents) const;
00102
00106 void extents(FontExtents& extents) const;
00107
00128 void get_text_extents(const std::string& utf8, TextExtents& extents) const;
00132 void text_extents(const std::string& utf8, TextExtents& extents) const;
00133
00149 void get_glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents);
00150
00154 void glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents);
00155
00159 RefPtr<FontFace> get_font_face() const;
00160
00164 void get_font_options(FontOptions& options) const;
00165
00169 void get_font_matrix(Matrix& font_matrix) const;
00170
00171 void get_font_matrix(cairo_matrix_t& font_matrix) const;
00172
00176 void get_ctm(Matrix& ctm) const;
00177
00178 void get_ctm(cairo_matrix_t& ctm) const;
00179
00183 FontType get_type() const;
00184
00185
00186
00207 void text_to_glyphs(double x,
00208 double y,
00209 const std::string& utf8,
00210 std::vector<Glyph>& glyphs,
00211 std::vector<TextCluster>& clusters,
00212 TextClusterFlags& cluster_flags);
00213
00222 void get_scale_matrix(Matrix& scale_matrix) const;
00223
00224 protected:
00225
00226 ScaledFont(const RefPtr<FontFace>& font_face, const cairo_matrix_t& font_matrix,
00227 const cairo_matrix_t& ctm, const FontOptions& options = FontOptions());
00229 cobject* m_cobject;
00230 };
00231
00232 #ifdef CAIRO_HAS_FT_FONT
00233
00234
00238 class FtScaledFont : public ScaledFont
00239 {
00240 public:
00245 static RefPtr<FtScaledFont> create(const RefPtr<FtFontFace>& font_face, const Matrix& font_matrix,
00246 const Matrix& ctm, const FontOptions& options = FontOptions());
00247
00270 FT_Face lock_face();
00271
00276 void unlock_face();
00277
00278 protected:
00279 FtScaledFont(const RefPtr<FtFontFace>& font_face, const Matrix& font_matrix,
00280 const Matrix& ctm, const FontOptions& options = FontOptions());
00281 };
00282 #endif // CAIRO_HAS_FT_FONT
00283
00284 }
00285
00286 #endif // __CAIROMM_SCALEDFONT_H
00287