Font.cc
1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Font.cc
*
* Created on: 30 oct. 2013
* Author: CS
*/
#include "Font.hh"
#include "DefaultPlotConfiguration.hh"
#include <ostream>
namespace plot {
const std::vector<std::string> Font::sFamily = { "sans-serif", "serif", "monospace", "script", "symbol" };
const std::vector<std::string> Font::sStyle = { "upright", "italic", "oblique" };
const std::vector<std::string> Font::sWeight = { "medium", "bold" };
Font::Font(const std::string& pname, int psize) :
_name(pname), _size(psize), _style(0), _weight(0) {
}
Font::Font(const Font& pfont) :
_name(pfont._name), _size(pfont._size), _style(pfont._style), _weight(pfont._weight) {
}
Font::~Font() {
}
void Font::setName (const std::string & name) {
_name = name;
}
void Font::setSize (int size) {
_size = size;
}
void Font::setStyle (const std::string & style) {
for (size_t i = 0; i < sStyle.size(); ++i) {
if (style.compare(sStyle[i]) == 0) {
_style = i;
}
}
}
void Font::setWeight (const std::string & weight) {
for (size_t i = 0; i < sWeight.size(); ++i) {
if (weight.compare(sWeight[i]) == 0) {
_weight = i;
}
}
}
std::ostream& operator <<(std::ostream& out,const Font& font) {
out << "[FONT]" << std::endl;
out << "font.name=" << font._name << std::endl;
out << "font.size=" << font._size << std::endl;
out << "font.style=" << font.sStyle[font._style] << std::endl;
out << "font.weight=" << font.sWeight[font._weight] << std::endl;
return out;
}
} /* namespace plot */