summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2017-04-19 12:26:09 +0200
committerMurray Cumming <murrayc@murrayc.com>2017-04-19 12:36:45 +0200
commit940252743dca2259158649a16d546696989d31d6 (patch)
treed90f2dd093f7a71805d2c3e7d89d23712b87921f
parent20917f97570b8f10f228b3dd361460de45705369 (diff)
Change Cairo::FontWeight enum to Cairo::ToyFontFace::Weight.
And change this from an old-style enum to a C++11 enum class.
-rw-r--r--cairomm/context.cc2
-rw-r--r--cairomm/context.h2
-rw-r--r--cairomm/enums.h16
-rw-r--r--cairomm/fontface.cc8
-rw-r--r--cairomm/fontface.h22
-rw-r--r--examples/text/text-rotate.cc2
-rw-r--r--examples/text/toy-text.cc2
-rw-r--r--examples/text/user-font.cc2
8 files changed, 28 insertions, 28 deletions
diff --git a/cairomm/context.cc b/cairomm/context.cc
index fd4eb53..382c2f1 100644
--- a/cairomm/context.cc
+++ b/cairomm/context.cc
@@ -458,7 +458,7 @@ void Context::copy_clip_rectangle_list(std::vector<Rectangle>& rectangles) const
cairo_rectangle_list_destroy(c_list);
}
-void Context::select_font_face(const std::string& family, ToyFontFace::Slant slant, FontWeight weight)
+void Context::select_font_face(const std::string& family, ToyFontFace::Slant slant, ToyFontFace::Weight weight)
{
cairo_select_font_face(cobj(), family.c_str(),
static_cast<cairo_font_slant_t>(slant),
diff --git a/cairomm/context.h b/cairomm/context.h
index f90b990..1a87e3a 100644
--- a/cairomm/context.h
+++ b/cairomm/context.h
@@ -1151,7 +1151,7 @@ public:
* @param weight the weight for the font
*
**/
- void select_font_face(const std::string& family, ToyFontFace::Slant slant, FontWeight weight);
+ void select_font_face(const std::string& family, ToyFontFace::Slant slant, ToyFontFace::Weight weight);
/**
* Sets the current font matrix to a scale by a factor of @a size, replacing
diff --git a/cairomm/enums.h b/cairomm/enums.h
index 6d1e64e..62d6e74 100644
--- a/cairomm/enums.h
+++ b/cairomm/enums.h
@@ -63,22 +63,6 @@ typedef enum
} Antialias;
/**
- * Specifies variants of a font face based on their weight.
- */
-typedef enum
-{
- /**
- * Normal font weight
- */
- FONT_WEIGHT_NORMAL = CAIRO_FONT_WEIGHT_NORMAL,
-
- /**
- * Bold font weight
- */
- FONT_WEIGHT_BOLD = CAIRO_FONT_WEIGHT_BOLD
-} FontWeight;
-
-/**
* Cairo::Content is used to describe the content that a surface will contain,
* whether color information, alpha information (translucence vs. opacity), or
* both.
diff --git a/cairomm/fontface.cc b/cairomm/fontface.cc
index 83c10f5..c75f355 100644
--- a/cairomm/fontface.cc
+++ b/cairomm/fontface.cc
@@ -81,12 +81,12 @@ FontType FontFace::get_type() const
// 'Toy' fonts
RefPtr<ToyFontFace>
-ToyFontFace::create(const std::string& family, Slant slant, FontWeight weight)
+ToyFontFace::create(const std::string& family, Slant slant, Weight weight)
{
return make_refptr_for_instance<ToyFontFace>(new ToyFontFace(family, slant, weight));
}
-ToyFontFace::ToyFontFace(const std::string& family, Slant slant, FontWeight weight) :
+ToyFontFace::ToyFontFace(const std::string& family, Slant slant, Weight weight) :
FontFace(cairo_toy_font_face_create (family.c_str(),
static_cast<cairo_font_slant_t>(slant),
static_cast<cairo_font_weight_t>(weight)),
@@ -105,9 +105,9 @@ ToyFontFace::Slant ToyFontFace::get_slant() const
return Slant(cairo_toy_font_face_get_slant(m_cobject));
}
-FontWeight ToyFontFace::get_weight() const
+ToyFontFace::Weight ToyFontFace::get_weight() const
{
- return FontWeight(cairo_toy_font_face_get_weight(m_cobject));
+ return Weight(cairo_toy_font_face_get_weight(m_cobject));
}
diff --git a/cairomm/fontface.h b/cairomm/fontface.h
index cec00ff..ffb9c7e 100644
--- a/cairomm/fontface.h
+++ b/cairomm/fontface.h
@@ -127,6 +127,22 @@ public:
};
/**
+ * Specifies variants of a font face based on their weight.
+ */
+ enum class Weight
+ {
+ /**
+ * Normal font weight
+ */
+ NORMAL = CAIRO_FONT_WEIGHT_NORMAL,
+
+ /**
+ * Bold font weight
+ */
+ BOLD = CAIRO_FONT_WEIGHT_BOLD
+ };
+
+ /**
* Creates a font face from a triplet of family, slant, and weight. These font
* faces are used in implementation of the the Context "toy" font API.
*
@@ -141,7 +157,7 @@ public:
* @param slant the slant for the font.
* @param weight the weight for the font.
*/
- static RefPtr<ToyFontFace> create(const std::string& family, Slant slant, FontWeight weight);
+ static RefPtr<ToyFontFace> create(const std::string& family, Slant slant, Weight weight);
/**
* Gets the familly name of a toy font.
@@ -156,10 +172,10 @@ public:
/**
* Gets the weight a toy font.
*/
- FontWeight get_weight() const;
+ Weight get_weight() const;
protected:
- ToyFontFace(const std::string& family, Slant slant, FontWeight weight);
+ ToyFontFace(const std::string& family, Slant slant, Weight weight);
};
diff --git a/examples/text/text-rotate.cc b/examples/text/text-rotate.cc
index 7ab3853..31cde98 100644
--- a/examples/text/text-rotate.cc
+++ b/examples/text/text-rotate.cc
@@ -45,7 +45,7 @@ void draw(Cairo::RefPtr<Cairo::Context> cr, int width, int height)
std::string text("cairo");
cr->select_font_face("Bitstream Vera Sans", Cairo::ToyFontFace::Slant::NORMAL,
- Cairo::FONT_WEIGHT_NORMAL);
+ Cairo::ToyFontFace::Weight::NORMAL);
cr->set_font_size(TEXT_SIZE);
Cairo::FontOptions font_options;
diff --git a/examples/text/toy-text.cc b/examples/text/toy-text.cc
index fe618a1..bcd4c06 100644
--- a/examples/text/toy-text.cc
+++ b/examples/text/toy-text.cc
@@ -26,7 +26,7 @@ int main(int, char**)
auto font =
Cairo::ToyFontFace::create("Bitstream Charter",
Cairo::ToyFontFace::Slant::ITALIC,
- Cairo::FONT_WEIGHT_BOLD);
+ Cairo::ToyFontFace::Weight::BOLD);
cr->set_font_face(font);
cr->set_font_size(FONT_SIZE);
cr->show_text("cairomm!");
diff --git a/examples/text/user-font.cc b/examples/text/user-font.cc
index 8273ead..890b8e1 100644
--- a/examples/text/user-font.cc
+++ b/examples/text/user-font.cc
@@ -124,7 +124,7 @@ int main(int, char**)
auto toy_font =
Cairo::ToyFontFace::create("Bitstream Charter",
Cairo::ToyFontFace::Slant::NORMAL,
- Cairo::FONT_WEIGHT_BOLD);
+ Cairo::ToyFontFace::Weight::BOLD);
cr->set_font_face(toy_font);
cr->set_font_size(FONT_SIZE);
cr->show_text("cairomm!");