/* * Font.hh * * Created on: 30 oct. 2013 * Author: CS */ #ifndef FONT_HH_ #define FONT_HH_ #include #include #include #include #include namespace plot { typedef std::pair CharSize; class Font { public: enum class Style { NORMAL, ITALIC, OBLIQUE }; enum class Weight { NORMAL, BOLD }; Font(const std::string& pname, int psize); Font(const Font& pfont); virtual ~Font(); static const std::vector sFamily; static const std::vector sStyle; static const std::vector sWeight; bool isSet(){ return !_name.empty() && _size > 0; } static Style getStyleByStr(std::string style) { boost::trim(style); if (style.compare("italic") == 0) { return Style::ITALIC; } else if (style.compare("oblique") == 0) { return Style::OBLIQUE; } return Style::NORMAL; } static Weight getWeightByStr(std::string weight) { boost::trim(weight); if (weight.compare("bold") == 0) { return Weight::BOLD; } return Weight::NORMAL; } void setName (const std::string & name); void setSize (int size); void setStyle (Style style); void setWeight (Weight weight); std::string getName() const; int getSize() const; Style getStyle() const; Weight getWeight() const; void dump(std::ostream& out, std::string& prefix); private: std::string _name; int _size; Style _style; Weight _weight; }; inline std::ostream& operator <<(std::ostream& out, Font::Style const & style) { std::string strStyle; switch (style) { case Font::Style::ITALIC: strStyle = "italic"; break; case Font::Style::OBLIQUE: strStyle = "oblique"; break; case Font::Style::NORMAL: default: strStyle = "normal"; } out << strStyle; return out; } inline std::ostream& operator <<(std::ostream& out, Font::Weight const & weight) { std::string strWeight; switch (weight) { case Font::Weight::BOLD: strWeight = "bold"; break; case Font::Weight::NORMAL: default: strWeight = "normal"; } out << strWeight; return out; } std::ostream& operator << (std::ostream& out, const Font& font); } /* namespace plot */ #endif /* FONT_HH_ */