MCPcopy Create free account
hub / github.com/davisking/dlib / adjust_metrics

Method adjust_metrics

dlib/gui_widgets/fonts.cpp:454–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452// ----------------------------------------------------------------------------------------
453
454 void bdf_font::adjust_metrics(
455 )
456 {
457 if ( is_initialized == false )
458 return;
459 // set starting values for fbb
460 if ( gl[default_char].num_of_points() > 0 )
461 {
462 letter& g = gl[default_char];
463 fbb.set_top( g[0].y );
464 fbb.set_bottom( g[0].y );
465 fbb.set_left( g[0].x );
466 fbb.set_right( g[0].x );
467 }
468 else
469 {
470 // ok, the default char was a space
471 // let's just choose some safe arbitrary values then...
472 fbb.set_top( 10000 );
473 fbb.set_bottom( -10000 );
474 fbb.set_left( 10000 );
475 fbb.set_right( -10000 );
476 }
477 right_overflow_ = 0;
478 for ( unichar n = 0; n < gl.size(); n++ )
479 {
480 letter& g = gl[n];
481 unsigned short nr_pts = g.num_of_points();
482 for ( unsigned short k = 0;k < nr_pts;k++ )
483 {
484 fbb.set_top( std::min( fbb.top(), (long)g[k].y ) );
485 fbb.set_left( std::min( fbb.left(), (long)g[k].x ) );
486 fbb.set_bottom( std::max( fbb.bottom(), (long)g[k].y ) );
487 fbb.set_right( std::max( fbb.right(), (long)g[k].x ) );
488 right_overflow_ = std::max( right_overflow_, (unsigned long)(g[k].x - g.width()) ); // superfluous?
489 }
490 }
491 }
492
493// ----------------------------------------------------------------------------------------
494

Callers 1

metadata_editorMethod · 0.80

Calls 13

num_of_pointsMethod · 0.80
set_topMethod · 0.80
set_bottomMethod · 0.80
set_leftMethod · 0.80
set_rightMethod · 0.80
minFunction · 0.50
maxFunction · 0.50
sizeMethod · 0.45
topMethod · 0.45
leftMethod · 0.45
bottomMethod · 0.45
rightMethod · 0.45

Tested by

no test coverage detected