[cairo-commit] cairomm/cairomm scaledfont.cc, 1.1, 1.2 scaledfont.h, 1.2, 1.3

Murray Cumming commit at pdx.freedesktop.org
Wed Jul 5 08:17:22 PDT 2006


Committed by: murrayc

Update of /cvs/cairo/cairomm/cairomm
In directory kemper:/tmp/cvs-serv26002/cairomm

Modified Files:
	scaledfont.cc scaledfont.h 
Log Message:
2006-07-05  Murray Cumming  <murrayc at murrayc.com>

        * cairomm/scaledfont.cc:
        * cairomm/scaledfont.h: create(): Make the font_matrix and ctm
        parameters const (they are now const in the C API too). Maybe the font
        parameter should be const, but maybe there is a reason that it is not
        const in the C API. Pass FontOptions by const reference instead of
        by value.
        glyph_extents(): Pass the vector by const reference instead of by
        value.
        I would prefere to make all the extents() functions use return values
        instead of output parameters, but I suppose this might be slightly
        less efficient in some circumstances.


Index: scaledfont.cc
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/scaledfont.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- scaledfont.cc	4 Jul 2006 23:06:07 -0000	1.1
+++ scaledfont.cc	5 Jul 2006 15:17:21 -0000	1.2
@@ -30,13 +30,10 @@
     m_cobject = cairo_scaled_font_reference(cobj);
 }
 
-RefPtr<ScaledFont> ScaledFont::create(FontFace font_face, Matrix& font_matrix,
-    Matrix& ctm, FontOptions options)
+RefPtr<ScaledFont> ScaledFont::create(FontFace& font_face, const Matrix& font_matrix,
+    const Matrix& ctm, const FontOptions& options)
 {
-  cairo_scaled_font_t* cobj = cairo_scaled_font_create(font_face.cobj(),
-      static_cast<cairo_matrix_t*>(&font_matrix),
-      static_cast<cairo_matrix_t*>(&ctm), options.cobj()
-      );
+  cairo_scaled_font_t* cobj = cairo_scaled_font_create(font_face.cobj(), &font_matrix, &ctm, options.cobj());
   check_status_and_throw_exception(cairo_scaled_font_status(cobj));
   return RefPtr<ScaledFont>(new ScaledFont(cobj, false));
 }
@@ -53,7 +50,7 @@
   check_object_status_and_throw_exception(*this);
 }
 
-void ScaledFont::glyph_extents(std::vector<Glyph> glyphs, TextExtents& extents)
+void ScaledFont::glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents)
 {
   // copy the data from the vector to a standard C array.  I don't believe
   // this will be a frequently used function so I think the performance hit is

Index: scaledfont.h
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/scaledfont.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- scaledfont.h	5 Jul 2006 14:59:12 -0000	1.2
+++ scaledfont.h	5 Jul 2006 15:17:21 -0000	1.3
@@ -19,8 +19,8 @@
 #ifndef __CAIROMM_SCALEDFONT_H
 #define __CAIROMM_SCALEDFONT_H
 
-#include <cairomm/context.h>    // Matrix
-#include <cairomm/fontoptions.h>    // Matrix
+#include <cairomm/context.h>
+#include <cairomm/fontoptions.h>
 
 namespace Cairo
 {
@@ -64,6 +64,7 @@
   /** Creates a ScaledFont object from a font face and matrices that describe
    * the size of the font and the environment in which it will be used.
    *
+   * @param font_face A font face.
    * @param font_matrix font space to user space transformation matrix for the
    * font. In the simplest case of a N point font, this matrix is just a scale
    * by N, but it can also be used to shear the font or stretch it unequally
@@ -73,8 +74,8 @@
    * @param options: options to use when getting metrics for the font and
    * rendering with it.
    */
-  static RefPtr<ScaledFont> create(FontFace font_face, Matrix& font_matrix,
-      Matrix& ctm, FontOptions options);
+  static RefPtr<ScaledFont> create(FontFace& font_face, const Matrix& font_matrix,
+      const Matrix& ctm, const FontOptions& options);
 
   /** Gets the metrics for a ScaledFont */
   void extents(FontExtents& extents) const;
@@ -114,7 +115,7 @@
    * @param glyphs A vector of glyphs to calculate the extents of
    * @param extents Returns the extents for the array of glyphs
    **/
-  void glyph_extents(std::vector<Glyph> glyphs, TextExtents& extents);
+  void glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents);
 
   /** The FontFace with which this ScaledFont was created.
    * @since 1.2



More information about the cairo-commit mailing list