summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--cairomm/scaledfont.h2
-rw-r--r--tests/test-scaled-font.cc45
3 files changed, 52 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index fddad41..44975e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-12-15 Jonathon Jongsma <jonathon@quotidian.org>
+
+ * cairomm/scaledfont.h: revert the virtual destructor since it's unnecessary
+ and an ABI change. The ScaledFont subclasses don't have any virtual functions
+ or any subclass-specific data that needs to be cleaned up, so a virtual
+ destructor is not really necessary here.
+ * tests/test-scaled-font.cc: a little paranoia test just to ensure that the
+ base destructor is called correctly reducing the ref count when we delete a
+ FtFontFace
+
2008-12-14 Jonathon Jongsma <jonathon@quotidian.org>
* cairomm/fontface.cc: fixed a bug in UserFont where I was incorrectly using a
diff --git a/cairomm/scaledfont.h b/cairomm/scaledfont.h
index c3e9b8d..9abe48f 100644
--- a/cairomm/scaledfont.h
+++ b/cairomm/scaledfont.h
@@ -65,7 +65,7 @@ public:
*/
explicit ScaledFont(cobject* cobj, bool has_reference = false);
- virtual ~ScaledFont();
+ ~ScaledFont();
/** 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.
diff --git a/tests/test-scaled-font.cc b/tests/test-scaled-font.cc
index 73a4c59..e1798b6 100644
--- a/tests/test-scaled-font.cc
+++ b/tests/test-scaled-font.cc
@@ -69,6 +69,40 @@ void test_get_font_face()
BOOST_REQUIRE_EQUAL(cairo_font_face_get_reference_count(face->cobj()), refcount);
}
+#ifdef CAIRO_HAS_FT_FONT
+void test_ft_scaled_font()
+{
+ FcPattern* invalid = FcPatternCreate();
+ Cairo::RefPtr<Cairo::FtFontFace> invalid_face;
+ BOOST_CHECK_THROW(invalid_face = Cairo::FtFontFace::create(invalid), std::bad_alloc);
+
+ // basically taken from the cairo test case -- we don't care what font we're
+ // using so just create an empty pattern and do the minimal substitution to
+ // get a valid pattern
+ FcPattern* pattern = FcPatternCreate();
+ FcConfigSubstitute (NULL, pattern, FcMatchPattern);
+ FcDefaultSubstitute (pattern);
+ FcResult result;
+ FcPattern* resolved = FcFontMatch (NULL, pattern, &result);
+ Cairo::RefPtr<Cairo::FtFontFace> face = Cairo::FtFontFace::create(resolved);
+ BOOST_CHECK(face);
+
+ cairo_scaled_font_t* c_scaled_font = 0;
+ int refcount = 0;
+ {
+ Cairo::RefPtr<Cairo::FtScaledFont> scaled_font =
+ FtScaledFont::create(face,
+ Cairo::identity_matrix(),
+ Cairo::identity_matrix(),
+ FontOptions());
+ c_scaled_font = scaled_font->cobj();
+ refcount = cairo_scaled_font_get_reference_count(c_scaled_font);
+ }
+ // make sure that the base destructor is called
+ BOOST_CHECK_EQUAL(cairo_scaled_font_get_reference_count(c_scaled_font), refcount -1);
+}
+#endif // CAIRO_HAS_FT_FONT
+
test_suite*
init_unit_test_suite(int argc, char* argv[])
@@ -78,10 +112,13 @@ init_unit_test_suite(int argc, char* argv[])
test_suite* test= BOOST_TEST_SUITE( "Cairo::ScaledFont Tests" );
- test->add (BOOST_TEST_CASE (&test_construction));
- test->add (BOOST_TEST_CASE (&test_text_to_glyphs));
- test->add (BOOST_TEST_CASE (&test_scale_matrix));
- test->add (BOOST_TEST_CASE (&test_get_font_face));
+ test->add(BOOST_TEST_CASE(&test_construction));
+ test->add(BOOST_TEST_CASE(&test_text_to_glyphs));
+ test->add(BOOST_TEST_CASE(&test_scale_matrix));
+ test->add(BOOST_TEST_CASE(&test_get_font_face));
+#ifdef CAIRO_HAS_FT_FONT
+ test->add(BOOST_TEST_CASE(&test_ft_scaled_font));
+#endif // CAIRO_HAS_FT_FONT
return test;
}