scaledfont.h

Go to the documentation of this file.
00001 /* Copyright (C) 2006 The cairomm Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU Library General Public
00005  * License as published by the Free Software Foundation; either
00006  * version 2 of the License, or (at your option) any later version.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public
00014  * License along with this library; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00016  * 02110-1301, USA.
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   // For use only by the cairomm implementation.
00055   inline ErrorStatus get_status() const
00056   { return cairo_scaled_font_status(const_cast<cairo_scaled_font_t*>(cobj())); }
00057 
00058   // for RefPtr
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 
00081   static RefPtr<ScaledFont> create(const RefPtr<FontFace>& font_face, const Matrix& font_matrix,
00082       const Matrix& ctm, const FontOptions& options = FontOptions());
00083   // NOTE: the constructor doesn't take a RefPtr<const FontFace> because the
00084   // FontFace object can be changed in this constructor (in the case of user
00085   // fonts, the FontFace becomes immutable, i.e. you can't call any set_*_func()
00086   // functions any longer)
00087 
00088   //We use an output paramter instead of the return value,
00089   //for consistency with other get_*extents() methods in other classes,
00090   //though they should probably all use the return value instead.
00091   //but it is too late to change that now. murrayc:
00092 
00096   void get_extents(FontExtents& extents) const;
00097 
00101   void extents(FontExtents& extents) const;
00102 
00123   void get_text_extents(const std::string& utf8, TextExtents& extents) const;
00127   void text_extents(const std::string& utf8, TextExtents& extents) const;
00128 
00144   void get_glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents);
00145 
00149   void glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents);
00150 
00154   RefPtr<FontFace> get_font_face() const;
00155 
00159   void get_font_options(FontOptions& options) const;
00160 
00164   void get_font_matrix(Matrix& font_matrix) const;
00165 
00169   void get_ctm(Matrix& ctm) const;
00170 
00174   FontType get_type() const;
00175 
00176   // FIXME: it'd be really nice not to assume a specific container (e.g.
00177   // std::vector) here
00198   void text_to_glyphs(double x,
00199                       double y,
00200                       const std::string& utf8,
00201                       std::vector<Glyph>& glyphs,
00202                       std::vector<TextCluster>& clusters,
00203                       TextClusterFlags& cluster_flags);
00204 
00213   void get_scale_matrix(Matrix& scale_matrix) const;
00214 
00215 protected:
00216   ScaledFont(const RefPtr<FontFace>& font_face, const Matrix& font_matrix,
00217              const Matrix& ctm, const FontOptions& options = FontOptions());
00219   cobject* m_cobject;
00220 };
00221 
00222 #ifdef CAIRO_HAS_FT_FONT
00223 
00224 //TODO: Documentation.
00228 class FtScaledFont : public ScaledFont
00229 {
00230 public:
00235   static RefPtr<FtScaledFont> create(const RefPtr<FtFontFace>& font_face, const Matrix& font_matrix,
00236       const Matrix& ctm, const FontOptions& options = FontOptions());
00237 
00260   FT_Face lock_face();
00261 
00266   void unlock_face();
00267 
00268 protected:
00269   FtScaledFont(const RefPtr<FtFontFace>& font_face, const Matrix& font_matrix,
00270       const Matrix& ctm, const FontOptions& options = FontOptions());
00271 };
00272 #endif // CAIRO_HAS_FT_FONT
00273 
00274 }
00275 
00276 #endif // __CAIROMM_SCALEDFONT_H
00277 // vim: ts=2 sw=2 et

Generated on Sat Oct 25 23:19:50 2008 for cairomm by  doxygen 1.5.5