g4tools  5.4.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
tools::sg::text_hershey Class Reference
Inheritance diagram for tools::sg::text_hershey:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::text_hershey:
Collaboration graph
[legend]

Public Member Functions

virtual const desc_fieldsnode_desc_fields () const
 
virtual void render (render_action &a_action)
 
virtual void pick (pick_action &a_action)
 
virtual void bbox (bbox_action &a_action)
 
 text_hershey ()
 
virtual ~text_hershey ()
 
 text_hershey (const text_hershey &a_from)
 
text_hersheyoperator= (const text_hershey &a_from)
 
virtual void get_bounds (float a_height, float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z) const
 
virtual float ascent (float a_height) const
 
virtual float y_advance (float a_height) const
 
virtual float descent (float a_height) const
 
virtual bool truncate (const std::string &a_string, float a_height, float a_cut_width, std::string &a_out) const
 
- Public Member Functions inherited from tools::sg::base_text
 base_text ()
 
virtual ~base_text ()
 
- Public Member Functions inherited from tools::sg::node
virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const =0
 
virtual nodecopy () const =0
 
virtual unsigned int cls_version () const
 
virtual void search (search_action &a_action)
 
virtual void get_matrix (get_matrix_action &a_action)
 
virtual bool write (write_action &a_action)
 
virtual void event (event_action &)
 
virtual bool read (read_action &a_action)
 
virtual void is_visible (visible_action &)
 
virtual void protocol_one_fields (std::vector< field * > &a_fields) const
 
virtual bool draw_in_frame_buffer () const
 
virtual bool touched ()
 
virtual void reset_touched ()
 
 node ()
 
virtual ~node ()
 
void touch ()
 
fieldfield_from_desc (const field_desc &a_desc) const
 
void dump_field_descs (std::ostream &a_out) const
 
fieldfind_field_by_name (const std::string &a_name) const
 
- Public Member Functions inherited from tools::sg::gstos
size_t num_gstos () const
 

Static Public Member Functions

static void get_bounds (float a_height, const std::string &a_encoding, font_type a_font, const std::vector< std::string > &a_ss, float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z)
 
static void get_bounds (float a_height, const std::string &a_encoding, font_type a_font, const std::string &a_s, float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z)
 

Public Attributes

sf_string encoding
 
sf_enum< font_typefont
 
- Public Attributes inherited from tools::sg::base_text
mf_string strings
 
sf< float > height
 
sf_enum< sg::hjusthjust
 
sf_enum< sg::vjustvjust
 

Protected Types

typedef std::vector< hcharsencoded
 

Protected Member Functions

virtual unsigned int create_gsto (std::ostream &, sg::render_manager &a_mgr)
 
void update_sg ()
 
void get_segments (std::vector< float > &a_segs) const
 
- Protected Member Functions inherited from tools::sg::base_text
 base_text (const base_text &a_from)
 
base_textoperator= (const base_text &a_from)
 
- Protected Member Functions inherited from tools::sg::node
 node (const node &)
 
nodeoperator= (const node &)
 
void add_field (field *a_field)
 
bool write_fields (write_action &a_action)
 
bool read_fields (read_action &a_action)
 
field_desc::offset_t field_offset (const field *a_field) const
 
fieldfind_field (const field_desc &a_rdesc) const
 
void check_fields (std::ostream &a_out) const
 
- Protected Member Functions inherited from tools::sg::gstos
 gstos ()
 
virtual ~gstos ()
 
 gstos (const gstos &)
 
gstosoperator= (const gstos &a_from)
 
unsigned int get_tex_id (std::ostream &a_out, render_manager &a_mgr, const img_byte &a_img, bool a_NEAREST)
 
unsigned int get_gsto_id (std::ostream &a_out, render_manager &a_mgr)
 
void clean_gstos ()
 
void clean_gstos (render_manager *a_mgr)
 
unsigned int _find (render_manager *a_mgr)
 

Static Protected Member Functions

static float _descent (float a_height)
 
static bool _truncate (const std::string &a_string, float a_height, font_type a_font, float a_cut_width, std::string &a_out)
 
static void get_char_bound (char a_char, font_type a_font, float a_scale, bool a_bar, float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z)
 
static void string_segs (bool aGEN_POINTS, const std::string &a_string, float a_height, const std::string &a_encoding, font_type a_font, float &aX, float &aY, std::vector< float > &a_segs, bool a_fill_segs)
 
static float char_segs (bool aGEN_POINTS, char a_char, font_type a_font, float a_scale, bool aBar, float aX, float aY, std::vector< float > &a_segs, bool a_fill_segs)
 
static void decode_plain (const std::string &a_s, sencoded &a_sed)
 
static void decode_PAW (const std::string &a_s, sencoded &a_sed)
 PAW encoding //////////////////////////////////////////////////////////. More...
 

Protected Attributes

std::vector< float > m_segs
 
size_t m_gsto_sz
 
- Protected Attributes inherited from tools::sg::gstos
std::vector< std::pair< unsigned int, render_manager * > > m_gstos
 

Detailed Description

Definition at line 82 of file text_hershey.

Member Typedef Documentation

◆ sencoded

typedef std::vector<hchar> tools::sg::text_hershey::sencoded
protected

Definition at line 557 of file text_hershey.

Constructor & Destructor Documentation

◆ text_hershey() [1/2]

tools::sg::text_hershey::text_hershey ( )
inline

Definition at line 171 of file text_hershey.

172  :parent()
174  ,font(sg::latin)
175  ,m_gsto_sz(0)
176  {
177  add_fields();
178  }

◆ ~text_hershey()

virtual tools::sg::text_hershey::~text_hershey ( )
inlinevirtual

Definition at line 179 of file text_hershey.

179 {}

◆ text_hershey() [2/2]

tools::sg::text_hershey::text_hershey ( const text_hershey a_from)
inline

Definition at line 181 of file text_hershey.

182  :parent(a_from)
183  ,gstos(a_from)
184  ,encoding(a_from.encoding)
185  ,font(a_from.font)
186  ,m_gsto_sz(0)
187  {
188  add_fields();
189  }

Member Function Documentation

◆ _descent()

static float tools::sg::text_hershey::_descent ( float  a_height)
inlinestaticprotected

Definition at line 336 of file text_hershey.

336  {
337  // '/' seems to be the char with the max descent.
338  float mn_x,mn_y,mn_z;
339  float mx_x,mx_y,mx_z;
340  get_char_bound('/',sg::latin,a_height,false,
341  mn_x,mn_y,mn_z,
342  mx_x,mx_y,mx_z);
343  return -mn_y; //return then a positive number.
344  }

◆ _truncate()

static bool tools::sg::text_hershey::_truncate ( const std::string &  a_string,
float  a_height,
font_type  a_font,
float  a_cut_width,
std::string &  a_out 
)
inlinestaticprotected

Definition at line 346 of file text_hershey.

349  {
350  //It does not take into account encoding.
351 
352  a_out.clear();
353 
354  float width = 0;
355 
356  const unsigned int mx_poly = 4;
357  const unsigned int mx_point = 160;
358 
359  int max_point[mx_poly];
360  float xp[mx_point];
361  float yp[mx_point];
362 
363  tools_sforcit(a_string,it) {
364 
365  float cwidth;
366  int number;
367  if (a_font==sg::greek) {
368  hershey::greek_char_points(*it,a_height,number,max_point,xp,yp,cwidth);
369  } else if (a_font==sg::special) {
370  hershey::special_char_points(*it,a_height,number,max_point,xp,yp,cwidth);
371  } else {
372  hershey::latin_char_points(*it,a_height,number,max_point,xp,yp,cwidth);
373  }
374 
375  float advance = cwidth + a_height * 0.01F;
376 
377  if((width+cwidth)>=a_cut_width) return true;
378  a_out += *it;
379  width += advance;
380  }
381 
382  return true;
383  }

◆ ascent()

virtual float tools::sg::text_hershey::ascent ( float  a_height) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 206 of file text_hershey.

206  {
207  // '/' seems to be the char with the max ascent.
208  // NOTE : If 'A', the ascent = height.value().
209  float mn_x,mn_y,mn_z;
210  float mx_x,mx_y,mx_z;
211  get_char_bound('/',sg::latin,a_height,false,
212  mn_x,mn_y,mn_z,
213  mx_x,mx_y,mx_z);
214  return mx_y;
215  }

◆ bbox()

virtual void tools::sg::text_hershey::bbox ( bbox_action a_action)
inlinevirtual

Reimplemented from tools::sg::node.

Reimplemented in tools::sg::text_hershey_marker.

Definition at line 155 of file text_hershey.

155  {
156  if(touched()) {
157  update_sg();
158  reset_touched();
159  }
160 
161  float x,y;
162  std::vector<float>::const_iterator it;
163  for(it=m_segs.begin();it!=m_segs.end();) {
164  x = *it;it++;
165  y = *it;it++;
166  a_action.add_one_point(x,y,0);
167  }
168  }

◆ char_segs()

static float tools::sg::text_hershey::char_segs ( bool  aGEN_POINTS,
char  a_char,
font_type  a_font,
float  a_scale,
bool  aBar,
float  aX,
float  aY,
std::vector< float > &  a_segs,
bool  a_fill_segs 
)
inlinestaticprotected

Definition at line 488 of file text_hershey.

498  {
499  const unsigned int mx_poly = 8;
500  const unsigned int mx_point = 160;
501 
502  int max_point[mx_poly];
503  float xp[mx_point];
504  float yp[mx_point];
505 
506  int number;
507  float width;
508  if (a_font==sg::greek) {
509  hershey::greek_char_points(a_char,a_scale,number,max_point,xp,yp,width);
510  } else if (a_font==sg::special) {
511  hershey::special_char_points(a_char,a_scale,number,max_point,xp,yp,width);
512  } else {
513  hershey::latin_char_points(a_char,a_scale,number,max_point,xp,yp,width);
514  }
515  if(!aGEN_POINTS) return width;
516 
517  float ymax = 0;
518 
519  int ipoint = 0;
520  int pointn;
521  for (int ipoly=0;ipoly<number;ipoly++) {
522  pointn = max_point[ipoly];
523  if(pointn>0) {
524  for(int count=0;count<pointn-1;count++) {
525  ymax = mx<float>(ymax,yp[ipoint]);
526  if(a_fill_segs) {
527  a_segs.push_back(aX+xp[ipoint]);
528  a_segs.push_back(aY+yp[ipoint]);
529  }
530  ymax = mx<float>(ymax,yp[ipoint+1]);
531  if(a_fill_segs) {
532  a_segs.push_back(aX+xp[ipoint+1]);
533  a_segs.push_back(aY+yp[ipoint+1]);
534  }
535  ipoint ++;
536  }
537  ipoint ++;
538  }
539  }
540 
541  if(aBar) { //Draw a bar on top of the character.
542  float xbar = 0;
543  float ybar = ymax * 1.3F;
544 
545  if(a_fill_segs) {
546  a_segs.push_back(aX+xbar);
547  a_segs.push_back(aY+ybar);
548 
549  a_segs.push_back(aX+xbar+width);
550  a_segs.push_back(aY+ybar);
551  }
552  }
553 
554  return width;
555  }

◆ create_gsto()

virtual unsigned int tools::sg::text_hershey::create_gsto ( std::ostream &  ,
sg::render_manager a_mgr 
)
inlineprotectedvirtual

Reimplemented from tools::sg::gstos.

Definition at line 103 of file text_hershey.

103  {
104  std::vector<float> gsto_data;
105 
106  {size_t npts = m_segs.size()/2; //2 coords
107  size_t ngsto = npts*3; //3 coords.
108  size_t sz = gsto_data.size();
109  gsto_data.resize(sz+ngsto);
110  float* pxyz = vec_data<float>(gsto_data)+sz;
111  const float* data = vec_data<float>(m_segs);
112  gl::cvt_2to3(npts,data,pxyz);}
113 
114  m_gsto_sz = gsto_data.size();
115 
116  if(gsto_data.empty()) return 0;
117 
118  return a_mgr.create_gsto_from_data(gsto_data);
119  }

◆ decode_PAW()

static void tools::sg::text_hershey::decode_PAW ( const std::string &  a_s,
sencoded a_sed 
)
inlinestaticprotected

PAW encoding //////////////////////////////////////////////////////////.

Definition at line 586 of file text_hershey.

586  {
587  a_sed.clear();
588 
590  hchar::e_move move = hchar::none;
591  bool back = false;
592  bool bar = false;
593  //bool upper = true; //to be done.
594 
595  tools_sforcit(a_s,it) {
596  char c = *it;
597  // Control characters :
598  if(c=='[') {
599  font = sg::greek;
600  continue;
601  } else if(c==']') {
602  font = sg::latin;
603  continue;
604  } else if(c=='"') {
605  font = sg::special;
606  continue;
607  } else if(c=='#') {
608  font = sg::latin;
609  continue;
610  } else if(c=='!') {
611  move = hchar::none;
612  continue;
613  } else if(c=='^') {
614  move = hchar::up;
615  continue;
616  } else if(c=='?') {
617  move = hchar::down;
618  continue;
619  } else if(c=='&') {
620  back = true;
621  continue;
622  } else if(c=='<') {
623  //upper = false;
624  continue;
625  } else if(c=='>') {
626  //upper = true;
627  continue;
628  }
629 
630  hchar hc;
631  hc.m_y_move = move;
632  hc.m_back = back;
633  hc.m_bar = bar;
634  hc.m_font = font;
635  hc.m_char = c;
636 
637  a_sed.push_back(hc);
638 
639  back = false;
640  bar = false;
641  }
642 
643  if(a_sed.size()) a_sed[a_sed.size()-1].m_cr = true;
644  }

◆ decode_plain()

static void tools::sg::text_hershey::decode_plain ( const std::string &  a_s,
sencoded a_sed 
)
inlinestaticprotected

Definition at line 559 of file text_hershey.

559  {
560  a_sed.clear();
561  tools_sforcit(a_s,it) {
562  hchar hc;
563  hc.m_char = *it;
564  a_sed.push_back(hc);
565  }
566  if(a_sed.size()) a_sed[a_sed.size()-1].m_cr = true;
567  }

◆ descent()

virtual float tools::sg::text_hershey::descent ( float  a_height) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 222 of file text_hershey.

222 {return _descent(a_height);}

◆ get_bounds() [1/3]

static void tools::sg::text_hershey::get_bounds ( float  a_height,
const std::string &  a_encoding,
font_type  a_font,
const std::string &  a_s,
float &  a_mn_x,
float &  a_mn_y,
float &  a_mn_z,
float &  a_mx_x,
float &  a_mx_y,
float &  a_mx_z 
)
inlinestatic

Definition at line 259 of file text_hershey.

264  {
265  float HEIGHT = a_height;
266  float Y_ADVANCE = 2 * HEIGHT;
267  float width = 0;
268  float Y = 0;
269  std::vector<float> dummy;
270  float XL = 0;
271  string_segs(false,a_s,a_height,a_encoding,a_font,XL,Y,dummy,false);
272  Y -= Y_ADVANCE;
273  width = mx<float>(width,XL);
274 
275  a_mn_x = 0;
276  a_mn_y = -_descent(a_height);
277  a_mn_z = 0;
278  a_mx_x = width;
279  a_mx_y = HEIGHT;
280  a_mx_z = 0;
281  }

◆ get_bounds() [2/3]

static void tools::sg::text_hershey::get_bounds ( float  a_height,
const std::string &  a_encoding,
font_type  a_font,
const std::vector< std::string > &  a_ss,
float &  a_mn_x,
float &  a_mn_y,
float &  a_mn_z,
float &  a_mx_x,
float &  a_mx_y,
float &  a_mx_z 
)
inlinestatic

Definition at line 229 of file text_hershey.

234  {
235  if(a_ss.size()) {
236  float HEIGHT = a_height;
237  float Y_ADVANCE = 2 * HEIGHT;
238  float width = 0;
239  float Y = 0;
240  std::vector<float> dummy;
241  tools_vforcit(std::string,a_ss,it) {
242  float XL = 0;
243  string_segs(false,*it,a_height,a_encoding,a_font,XL,Y,dummy,false);
244  Y -= Y_ADVANCE;
245  width = mx<float>(width,XL);
246  }
247 
248  a_mn_x = 0;
249  a_mn_y = -Y_ADVANCE*(a_ss.size()-1)-_descent(a_height);
250  a_mn_z = 0;
251  a_mx_x = width;
252  a_mx_y = HEIGHT;
253  a_mx_z = 0;
254  } else {
255  box_3f_make_empty(a_mn_x,a_mn_y,a_mn_z,a_mx_x,a_mx_y,a_mx_z);
256  }
257  }

◆ get_bounds() [3/3]

virtual void tools::sg::text_hershey::get_bounds ( float  a_height,
float &  a_mn_x,
float &  a_mn_y,
float &  a_mn_z,
float &  a_mx_x,
float &  a_mx_y,
float &  a_mx_z 
) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 198 of file text_hershey.

200  {
201  get_bounds(a_height,encoding.value(),font.value(),
202  strings.values(),
203  a_mn_x,a_mn_y,a_mn_z,
204  a_mx_x,a_mx_y,a_mx_z);
205  }

◆ get_char_bound()

static void tools::sg::text_hershey::get_char_bound ( char  a_char,
font_type  a_font,
float  a_scale,
bool  a_bar,
float &  a_mn_x,
float &  a_mn_y,
float &  a_mn_z,
float &  a_mx_x,
float &  a_mx_y,
float &  a_mx_z 
)
inlinestaticprotected

Definition at line 385 of file text_hershey.

389  {
390  box_3f_make_empty(a_mn_x,a_mn_y,a_mn_z,a_mx_x,a_mx_y,a_mx_z);
391 
392  const unsigned int mx_poly = 4;
393  const unsigned int mx_point = 160;
394 
395  int max_point[mx_poly];
396  float xp[mx_point];
397  float yp[mx_point];
398 
399  int number;
400  float width;
401  if (a_font==sg::greek) {
402  hershey::greek_char_points(a_char,a_scale,number,max_point,xp,yp,width);
403  } else if (a_font==sg::special) {
404  hershey::special_char_points(a_char,a_scale,number,max_point,xp,yp,width);
405  } else {
406  hershey::latin_char_points(a_char,a_scale,number,max_point,xp,yp,width);
407  }
408 
409  float ymax = 0;
410 
411  int ipoint = 0;
412  for (int ipoly=0;ipoly<number;ipoly++) {
413  int pointn = max_point[ipoly];
414  if(pointn>0) {
415  for(int count=0;count<pointn-1;count++) {
416  ymax = mx<float>(ymax,yp[ipoint]);
417  box_3f_extend_by(a_mn_x,a_mn_y,a_mn_z,a_mx_x,a_mx_y,a_mx_z,xp[ipoint],yp[ipoint],0);
418 
419  ymax = mx<float>(ymax,yp[ipoint+1]);
420  box_3f_extend_by(a_mn_x,a_mn_y,a_mn_z,a_mx_x,a_mx_y,a_mx_z,xp[ipoint+1],yp[ipoint+1],0);
421 
422  ipoint ++;
423  }
424  ipoint ++;
425  }
426  }
427 
428  if(a_bar) { //Draw a bar on top of the character.
429  float xbar = 0;
430  float ybar = ymax * 1.3F;
431  box_3f_extend_by(a_mn_x,a_mn_y,a_mn_z,a_mx_x,a_mx_y,a_mx_z,xbar,ybar,0);
432  box_3f_extend_by(a_mn_x,a_mn_y,a_mn_z,a_mx_x,a_mx_y,a_mx_z,xbar+width,ybar,0);
433  }
434  }

◆ get_segments()

void tools::sg::text_hershey::get_segments ( std::vector< float > &  a_segs) const
inlineprotected

Definition at line 290 of file text_hershey.

290  {
291 
292  float Y = 0;
293  if( (vjust.value()==sg::middle) ||
294  (vjust.value()==sg::top) ){
295  float mn_x,mn_y,mn_z;
296  float mx_x,mx_y,mx_z;
297  get_bounds(height.value(),mn_x,mn_y,mn_z,mx_x,mx_y,mx_z);
298  float szy = mx_y - mn_y;
299 
300  if(vjust.value()==sg::middle) {
301  Y -= 0.5F * szy;
302  } else if(vjust.value()==sg::top) {
303  Y -= szy;
304  }
305  }
306 
307  float HEIGHT = height.value();
308  float Y_ADVANCE = 2 * HEIGHT;
309 
310  const std::string& encod = encoding.value();
311 
312  const std::vector<std::string>& ss = strings.values();
313  tools_vforcit(std::string,ss,it) {
314 
315  float X = 0;
316  if( (hjust.value()==sg::center) ||
317  (hjust.value()==sg::right) ){
318  float mn_x,mn_y,mn_z;
319  float mx_x,mx_y,mx_z;
321  mn_x,mn_y,mn_z,mx_x,mx_y,mx_z);
322  float szx = mx_x - mn_x;
323 
324  if(hjust.value()==sg::center) {
325  X -= 0.5F * szx;
326  } else if(hjust.value()==sg::right) {
327  X -= szx;
328  }
329  }
330 
331  string_segs(true,*it,HEIGHT,encod,font.value(),X,Y,a_segs,true);
332  Y -= Y_ADVANCE;
333  }
334  }

◆ node_desc_fields()

virtual const desc_fields& tools::sg::text_hershey::node_desc_fields ( ) const
inlinevirtual

Reimplemented from tools::sg::base_text.

Definition at line 89 of file text_hershey.

89  {
91  static const desc_fields s_v(parent::node_desc_fields(),2, //WARNING : take care of count.
94  );
95  return s_v;
96  }

◆ operator=()

text_hershey& tools::sg::text_hershey::operator= ( const text_hershey a_from)
inline

Definition at line 190 of file text_hershey.

190  {
191  parent::operator=(a_from);
192  gstos::operator=(a_from);
193  encoding = a_from.encoding;
194  font = a_from.font;
195  return *this;
196  }

◆ pick()

virtual void tools::sg::text_hershey::pick ( pick_action a_action)
inlinevirtual

Reimplemented from tools::sg::node.

Reimplemented in tools::sg::text_hershey_marker.

Definition at line 147 of file text_hershey.

147  {
148  if(touched()) {
149  update_sg();
150  reset_touched();
151  }
152  a_action.add__lines_xy(*this,m_segs,true);
153  }

◆ render()

virtual void tools::sg::text_hershey::render ( render_action a_action)
inlinevirtual

_id

Reimplemented from tools::sg::node.

Reimplemented in tools::sg::text_hershey_marker.

Definition at line 121 of file text_hershey.

121  {
122  if(touched()) {
123  update_sg();
124  reset_touched();
125  }
126  const state& state = a_action.state();
127  if(state.m_use_gsto) {
128  unsigned int _id = get_gsto_id(a_action.out(),a_action.render_manager());
129  if(_id) {
130  a_action.begin_gsto(_id);
131  a_action.draw_gsto_v(gl::lines(),m_gsto_sz/3,0);
132  a_action.end_gsto();
133  return;
134 
135  } else {
136  // use immediate rendering.
137  }
138 
139  } else {
140  clean_gstos(&a_action.render_manager());
141  }
142 
143  // immediate rendering :
144  a_action.draw_vertex_array_xy(gl::lines(),m_segs);
145  }

◆ string_segs()

static void tools::sg::text_hershey::string_segs ( bool  aGEN_POINTS,
const std::string &  a_string,
float  a_height,
const std::string &  a_encoding,
font_type  a_font,
float &  aX,
float &  aY,
std::vector< float > &  a_segs,
bool  a_fill_segs 
)
inlinestaticprotected

Definition at line 436 of file text_hershey.

446  {
447  float oldX = 0;
448  float HEIGHT = a_height;
449 
450  bool encod_PAW = (a_encoding==encoding_PAW()?true:false);
451 
452  sencoded sed;
453  if(encod_PAW) decode_PAW(a_string,sed);
454  else decode_plain(a_string,sed);
455 
456  tools_vforcit(hchar,sed,it) {
457  const hchar& hc = *it;
458 
459  font_type hershey_font = hc.m_font;
460  if(encod_PAW) {
461  hershey_font = hc.m_font;
462  } else {
463  hershey_font = a_font;
464  }
465 
466  float scale = HEIGHT;
467  float ymove = 0;
468  if(hc.m_y_move==hchar::up) {
469  scale = HEIGHT*0.6F;
470  ymove = HEIGHT*0.6F;
471  } else if(hc.m_y_move==hchar::down) {
472  scale = HEIGHT*0.6F;
473  ymove = -HEIGHT*0.6F;
474  }
475  if(hc.m_back) aX = oldX;
476  oldX = aX;
477  //FIXME : bar
478  aY += ymove;
479 
480  float advance = char_segs(aGEN_POINTS,hc.m_char,hershey_font,scale,hc.m_bar,aX,aY,a_segs,a_fill_segs) + HEIGHT * 0.01F;
481 
482  aX += advance;
483 
484  aY -= ymove;
485  }
486  }

◆ truncate()

virtual bool tools::sg::text_hershey::truncate ( const std::string &  a_string,
float  a_height,
float  a_cut_width,
std::string &  a_out 
) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 224 of file text_hershey.

224  {
225  return _truncate(a_string,a_height,font.value(),a_cut_width,a_out);
226  }

◆ update_sg()

void tools::sg::text_hershey::update_sg ( )
inlineprotected

Definition at line 284 of file text_hershey.

284  {
285  clean_gstos();
286  m_segs.clear();
288  }

◆ y_advance()

virtual float tools::sg::text_hershey::y_advance ( float  a_height) const
inlinevirtual

Implements tools::sg::base_text.

Definition at line 216 of file text_hershey.

216  {
217  float HEIGHT = a_height;
218  return 2 * HEIGHT; //Y_ADVANCE
219  }

Member Data Documentation

◆ encoding

sf_string tools::sg::text_hershey::encoding

Definition at line 86 of file text_hershey.

◆ font

sf_enum<font_type> tools::sg::text_hershey::font

Definition at line 87 of file text_hershey.

◆ m_gsto_sz

size_t tools::sg::text_hershey::m_gsto_sz
protected

Definition at line 648 of file text_hershey.

◆ m_segs

std::vector<float> tools::sg::text_hershey::m_segs
protected

Definition at line 647 of file text_hershey.


The documentation for this class was generated from the following file:
tools::sg::font_type
font_type
Definition: enums:85
tools::sg::text_hershey::decode_PAW
static void decode_PAW(const std::string &a_s, sencoded &a_sed)
PAW encoding //////////////////////////////////////////////////////////.
Definition: text_hershey:586
tools::sg::gstos::gstos
gstos()
Definition: gstos:18
tools::sg::text_hershey::get_bounds
virtual void get_bounds(float a_height, float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z) const
Definition: text_hershey:198
tools::sg::text_hershey::sencoded
std::vector< hchar > sencoded
Definition: text_hershey:557
tools::sg::base_text::height
sf< float > height
Definition: base_text:30
tools::hershey::greek_char_points
static void greek_char_points(char a_char, float a_scale, int &a_number, int *a_mx_point, float *aX, float *aY, float &a_width)
Definition: hershey:161
tools::hershey::special_char_points
static void special_char_points(char a_char, float a_scale, int &a_number, int *a_mx_point, float *aX, float *aY, float &a_width)
Definition: hershey:30
tools::sg::base_text::hjust
sf_enum< sg::hjust > hjust
Definition: base_text:31
tools::sg::gstos::clean_gstos
void clean_gstos()
Definition: gstos:89
tools::gl::lines
mode_t lines()
Definition: glprims:17
tools::sg::encoding_PAW
const std::string & encoding_PAW()
Definition: strings:42
tools::box_3f_make_empty
void box_3f_make_empty(float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z)
Definition: box_3f:15
tools::sg::right
@ right
Definition: enums:76
tools::sg::text_hershey::encoding
sf_string encoding
Definition: text_hershey:86
tools::sg::text_hershey::m_segs
std::vector< float > m_segs
Definition: text_hershey:647
tools::sg::text_hershey
Definition: text_hershey:82
tools::sg::top
@ top
Definition: enums:82
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::text_hershey::string_segs
static void string_segs(bool aGEN_POINTS, const std::string &a_string, float a_height, const std::string &a_encoding, font_type a_font, float &aX, float &aY, std::vector< float > &a_segs, bool a_fill_segs)
Definition: text_hershey:436
tools::sg::text_hershey::update_sg
void update_sg()
Definition: text_hershey:284
tools::sg::latin
@ latin
Definition: enums:86
tools::sg::base_text::vjust
sf_enum< sg::vjust > vjust
Definition: base_text:32
tools::sg::hchar::none
@ none
Definition: text_hershey:69
tools::sg::special
@ special
Definition: enums:88
tools::sg::hchar::e_move
e_move
Definition: text_hershey:68
tools::sg::encoding_none
const std::string & encoding_none()
Definition: strings:38
tools::sg::greek
@ greek
Definition: enums:87
tools::sg::text_hershey::_descent
static float _descent(float a_height)
Definition: text_hershey:336
tools::sg::gstos::get_gsto_id
unsigned int get_gsto_id(std::ostream &a_out, render_manager &a_mgr)
Definition: gstos:60
tools::sg::middle
@ middle
Definition: enums:81
tools::sg::text_hershey::char_segs
static float char_segs(bool aGEN_POINTS, char a_char, font_type a_font, float a_scale, bool aBar, float aX, float aY, std::vector< float > &a_segs, bool a_fill_segs)
Definition: text_hershey:488
tools::sg::text_hershey::get_char_bound
static void get_char_bound(char a_char, font_type a_font, float a_scale, bool a_bar, float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z)
Definition: text_hershey:385
tools::sg::node::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: node:48
tools::sg::hchar::up
@ up
Definition: text_hershey:70
tools::sg::base_text::strings
mf_string strings
Definition: base_text:29
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
tools_sforcit
#define tools_sforcit(a__s, a__it)
Definition: forit:34
tools::hershey::latin_char_points
static void latin_char_points(char a_char, float a_scale, int &a_number, int *a_mx_point, float *aX, float *aY, float &a_width)
Definition: hershey:37
tools::gl::cvt_2to3
void cvt_2to3(size_t a_npt, const float *a_xys, float *&a_xyzs)
Definition: glprims:39
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::hchar::down
@ down
Definition: text_hershey:71
tools::sg::text_hershey::m_gsto_sz
size_t m_gsto_sz
Definition: text_hershey:648
tools::sg::text_hershey::font
sf_enum< font_type > font
Definition: text_hershey:87
tools::sg::center
@ center
Definition: enums:75
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::sg::text_hershey::_truncate
static bool _truncate(const std::string &a_string, float a_height, font_type a_font, float a_cut_width, std::string &a_out)
Definition: text_hershey:346
tools::sg::text_hershey::decode_plain
static void decode_plain(const std::string &a_s, sencoded &a_sed)
Definition: text_hershey:559
tools::sg::node::touched
virtual bool touched()
Definition: node:96
tools::box_3f_extend_by
void box_3f_extend_by(float &a_mn_x, float &a_mn_y, float &a_mn_z, float &a_mx_x, float &a_mx_y, float &a_mx_z, float a_x, float a_y, float a_z)
Definition: box_3f:24
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71
tools::sg::node::reset_touched
virtual void reset_touched()
Definition: node:102
tools::sg::text_hershey::get_segments
void get_segments(std::vector< float > &a_segs) const
Definition: text_hershey:290