summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--cairomm/scaledfont.cc11
-rw-r--r--cairomm/scaledfont.h11
3 files changed, 24 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index a34f1d6..0cc8367 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2006-07-05 Murray Cumming <murrayc@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.
+
+2006-07-05 Murray Cumming <murrayc@murrayc.com>
+
* cairomm/cairomm.h:
* cairomm/context.h:
* cairomm/path.h:
diff --git a/cairomm/scaledfont.cc b/cairomm/scaledfont.cc
index 56736de..90c26e8 100644
--- a/cairomm/scaledfont.cc
+++ b/cairomm/scaledfont.cc
@@ -30,13 +30,10 @@ ScaledFont::ScaledFont(cobject* cobj, bool has_reference)
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 @@ void ScaledFont::text_extents(const std::string& utf8, TextExtents& extents) con
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
diff --git a/cairomm/scaledfont.h b/cairomm/scaledfont.h
index ee9e570..9ad077c 100644
--- a/cairomm/scaledfont.h
+++ b/cairomm/scaledfont.h
@@ -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 @@ public:
/** 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 @@ public:
* @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 @@ public:
* @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