4 #ifndef tools_sg_text_hershey
5 #define tools_sg_text_hershey
17 #include "../lina/box_3f"
37 mem::increment(s_class().c_str());
42 mem::decrement(s_class().c_str());
55 mem::increment(s_class().c_str());
104 std::vector<float> gsto_data;
106 {
size_t npts =
m_segs.size()/2;
107 size_t ngsto = npts*3;
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);
116 if(gsto_data.empty())
return 0;
162 std::vector<float>::const_iterator it;
199 float& a_mn_x,
float& a_mn_y,
float& a_mn_z,
200 float& a_mx_x,
float& a_mx_y,
float& a_mx_z)
const {
203 a_mn_x,a_mn_y,a_mn_z,
204 a_mx_x,a_mx_y,a_mx_z);
206 virtual float ascent(
float a_height)
const {
209 float mn_x,mn_y,mn_z;
210 float mx_x,mx_y,mx_z;
217 float HEIGHT = a_height;
224 virtual bool truncate(
const std::string& a_string,
float a_height,
float a_cut_width,std::string& a_out)
const {
230 const std::string& a_encoding,
232 const std::vector<std::string>& a_ss,
233 float& a_mn_x,
float& a_mn_y,
float& a_mn_z,
234 float& a_mx_x,
float& a_mx_y,
float& a_mx_z){
236 float HEIGHT = a_height;
237 float Y_ADVANCE = 2 * HEIGHT;
240 std::vector<float> dummy;
243 string_segs(
false,*it,a_height,a_encoding,a_font,XL,Y,dummy,
false);
245 width = mx<float>(width,XL);
249 a_mn_y = -Y_ADVANCE*(a_ss.size()-1)-
_descent(a_height);
260 const std::string& a_encoding,
262 const std::string& a_s,
263 float& a_mn_x,
float& a_mn_y,
float& a_mn_z,
264 float& a_mx_x,
float& a_mx_y,
float& a_mx_z){
265 float HEIGHT = a_height;
266 float Y_ADVANCE = 2 * HEIGHT;
269 std::vector<float> dummy;
271 string_segs(
false,a_s,a_height,a_encoding,a_font,XL,Y,dummy,
false);
273 width = mx<float>(width,XL);
295 float mn_x,mn_y,mn_z;
296 float mx_x,mx_y,mx_z;
298 float szy = mx_y - mn_y;
308 float Y_ADVANCE = 2 * HEIGHT;
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;
338 float mn_x,mn_y,mn_z;
339 float mx_x,mx_y,mx_z;
349 std::string& a_out) {
356 const unsigned int mx_poly = 4;
357 const unsigned int mx_point = 160;
359 int max_point[mx_poly];
375 float advance = cwidth + a_height * 0.01F;
377 if((width+cwidth)>=a_cut_width)
return true;
387 float a_scale,
bool a_bar,
388 float& a_mn_x,
float& a_mn_y,
float& a_mn_z,
389 float& a_mx_x,
float& a_mx_y,
float& a_mx_z){
392 const unsigned int mx_poly = 4;
393 const unsigned int mx_point = 160;
395 int max_point[mx_poly];
412 for (
int ipoly=0;ipoly<number;ipoly++) {
413 int pointn = max_point[ipoly];
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);
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);
430 float ybar = ymax * 1.3F;
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);
438 ,
const std::string& a_string
440 ,
const std::string& a_encoding
444 ,std::vector<float>& a_segs
448 float HEIGHT = a_height;
450 bool encod_PAW = (a_encoding==
encoding_PAW()?
true:
false);
457 const hchar& hc = *it;
463 hershey_font = a_font;
466 float scale = HEIGHT;
473 ymove = -HEIGHT*0.6F;
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;
496 ,std::vector<float>& a_segs
499 const unsigned int mx_poly = 8;
500 const unsigned int mx_point = 160;
502 int max_point[mx_poly];
515 if(!aGEN_POINTS)
return width;
521 for (
int ipoly=0;ipoly<number;ipoly++) {
522 pointn = max_point[ipoly];
524 for(
int count=0;count<pointn-1;count++) {
525 ymax = mx<float>(ymax,yp[ipoint]);
527 a_segs.push_back(aX+xp[ipoint]);
528 a_segs.push_back(aY+yp[ipoint]);
530 ymax = mx<float>(ymax,yp[ipoint+1]);
532 a_segs.push_back(aX+xp[ipoint+1]);
533 a_segs.push_back(aY+yp[ipoint+1]);
543 float ybar = ymax * 1.3F;
546 a_segs.push_back(aX+xbar);
547 a_segs.push_back(aY+ybar);
549 a_segs.push_back(aX+xbar+width);
550 a_segs.push_back(aY+ybar);
566 if(a_sed.size()) a_sed[a_sed.size()-1].m_cr =
true;
643 if(a_sed.size()) a_sed[a_sed.size()-1].m_cr =
true;