| | 483 | int txf_width( const TexFont* tf, const char* it, const char* end ) |
| | 484 | { |
| | 485 | TexGlyphInfo* prev = 0; |
| | 486 | TexGlyphInfo* tgi; |
| | 487 | int width = 0; |
| | 488 | |
| | 489 | while( it != end ) |
| | 490 | { |
| | 491 | if( *it == '\n' ) |
| | 492 | break; |
| | 493 | if( *it == ' ' ) |
| | 494 | { |
| | 495 | tgi = txf_glyph( tf, ' ' ); |
| | 496 | if( tgi ) |
| | 497 | width += tgi->advance; |
| | 498 | prev = 0; |
| | 499 | } |
| | 500 | else |
| | 501 | { |
| | 502 | tgi = txf_glyph( tf, *it ); |
| | 503 | if( tgi ) |
| | 504 | { |
| | 505 | width += tgi->advance; |
| | 506 | if( prev ) |
| | 507 | width += txf_kerning( tf, prev, tgi ); |
| | 508 | prev = tgi; |
| | 509 | } |
| | 510 | } |
| | 511 | ++it; |
| | 512 | } |
| | 513 | |
| | 514 | return width; |
| | 515 | } |
| | 516 | |
| | 517 | |
| | 518 | int txf_linespacing( const TexFont* tf ) |
| | 519 | { |
| | 520 | return tf->max_ascent + (tf->max_ascent / 2); |
| | 521 | } |
| | 522 | |
| | 523 | |