g4tools  5.4.0
base_freetype
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_sg_base_freetype
5 #define tools_sg_base_freetype
6 
7 #include "base_text"
8 #include "gstos"
9 #include "sf_string"
10 
11 // abstract class to handle freetype text.
12 
13 namespace tools {
14 namespace sg {
15 
16 class base_freetype : public base_text, public gstos {
18 public:
20  sf_enum<winding_type> front_face; //default is ccw.
22  typedef unsigned int unichar;
23  typedef std::vector<unichar> uniline;
25  //mf_string font_dirs; //do we want that ? It is costly. We should have a sg::font node.
26 public:
27  virtual const desc_fields& node_desc_fields() const {
29  static const desc_fields s_v(parent::node_desc_fields(),4, //WARNING : take care of count.
32 
38 
40  //TOOLS_ADD_FIELD_DESC(font_dirs)
41  );
42  return s_v;
43  }
44 private:
45  void add_fields(){
46  add_field(&font);
50  //add_field(&font_dirs);
51  }
52 public:
54  :parent()
55  ,gstos()
56 
57  ,font("")
60  ,unitext()
61  //,font_dirs()
62  {
63  add_fields();
64  }
65  virtual ~base_freetype(){}
66 public:
68  :parent(a_from)
69  ,gstos(a_from)
70 
71  ,font(a_from.font)
72  ,front_face(a_from.front_face)
73  ,modeling(a_from.modeling)
74  ,unitext(a_from.unitext)
75  //,font_dirs(a_from.font_dirs)
76  {
77  add_fields();
78  }
79 
81  parent::operator=(a_from);
82  gstos::operator=(a_from);
83  font = a_from.font;
84  front_face = a_from.front_face;
85  modeling = a_from.modeling;
86  unitext = a_from.unitext;
87  //font_dirs = a_from.font_dirs;
88  return *this;
89  }
90 
91 public:
92  void dump_unitext(std::ostream& a_out) {
93  //unitext.values().size()
94  a_out << "unitext size : " << unitext.values().size() << std::endl;
95  std::vector<uniline>::const_iterator vit;
96  for(vit=unitext.values().begin();vit!=unitext.values().end();++vit) {
97  const uniline& line = *vit;
98  a_out << "beg line :" << std::endl;
99  //a_out << line << std::endl;
100  std::vector<unichar>::const_iterator it;
101  for(it=line.begin();it!=line.end();++it) {
102  a_out << ((unsigned int)*it) << std::endl;
103  }
104  a_out << "end line." << std::endl;
105  }
106  }
107 public:
108  static base_freetype* create(const base_freetype& a_ttf) {
109  return safe_cast<node,base_freetype>(*(a_ttf.copy()));
110  }
111 
112 };
113 
114 }}
115 
116 #endif
tools::sg::mf_std_vec< unichar >
tools::sg::gstos
Definition: gstos:16
tools::sg::font_pixmap
@ font_pixmap
Definition: enums:94
tools::sg::base_freetype::~base_freetype
virtual ~base_freetype()
Definition: base_freetype:65
tools::sg::base_text
Definition: base_text:17
tools::sg::base_freetype::base_freetype
base_freetype()
Definition: base_freetype:53
tools::sg::base_freetype::uniline
std::vector< unichar > uniline
Definition: base_freetype:23
tools::sg::base_freetype::front_face
sf_enum< winding_type > front_face
Definition: base_freetype:20
tools::sg::winding_ccw
@ winding_ccw
Definition: enums:105
TOOLS_ARG_FIELD_DESC_ENUMS_BEG
#define TOOLS_ARG_FIELD_DESC_ENUMS_BEG(a__field, a__num)
Definition: field:77
tools::sg::node::copy
virtual node * copy() const =0
tools::sg::base_freetype::modeling
sf_enum< font_modeling > modeling
Definition: base_freetype:21
tools::sg::node
Definition: node:28
tools::sg::base_freetype::unichar
unsigned int unichar
Definition: base_freetype:22
tools::sg::base_freetype
Definition: base_freetype:16
tools::sg::base_freetype::operator=
base_freetype & operator=(const base_freetype &a_from)
Definition: base_freetype:80
sf_string
tools::sg::base_freetype::base_freetype
base_freetype(const base_freetype &a_from)
Definition: base_freetype:67
tools::sg::desc_fields
Definition: field_desc:148
tools::sg::node::operator=
node & operator=(const node &)
Definition: node:124
tools::sg::gstos::operator=
gstos & operator=(const gstos &a_from)
Definition: gstos:22
tools::sg::bmf::values
const std::vector< T > & values() const
Definition: bmf:71
tools::sg::sf_enum< winding_type >
TOOLS_HEADER
#define TOOLS_HEADER(a__class, a__sclass, a__parent)
Definition: HEADER:10
tools::sg::base_freetype::font
sf_string font
Definition: base_freetype:19
tools::sg::font_outline
@ font_outline
Definition: enums:92
gstos
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::sg::node::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: node:48
tools::sg::node::add_field
void add_field(field *a_field)
Definition: node:128
tools::sg::base_freetype::create
static base_freetype * create(const base_freetype &a_ttf)
Definition: base_freetype:108
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
TOOLS_ARG_ENUM
#define TOOLS_ARG_ENUM(a__value)
Definition: field:85
tools::sg::sf_string
Definition: sf_string:15
tools::line
Definition: line:13
tools::sg::base_freetype::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: base_freetype:27
tools::sg::font_filled
@ font_filled
Definition: enums:93
base_text
tools::sg::base_freetype::dump_unitext
void dump_unitext(std::ostream &a_out)
Definition: base_freetype:92
tools::sg::base_freetype::unitext
mf_std_vec< unichar > unitext
Definition: base_freetype:24
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71
TOOLS_ARG_FIELD_DESC_ENUMS_END
#define TOOLS_ARG_FIELD_DESC_ENUMS_END
Definition: field:83