~ubuntu-branches/debian/sid/gource/sid

« back to all changes in this revision

Viewing changes to src/core/fxfont.cpp

  • Committer: Package Import Robot
  • Author(s): Andrew Caudwell
  • Date: 2014-04-15 16:30:17 UTC
  • mfrom: (1.2.15)
  • Revision ID: package-import@ubuntu.com-20140415163017-ucdr2josj1spzrga
Tags: 0.41-1
* New upstream release
* Made VCS URIs canonical
* Changed watch file to look at Github for releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
    if(FT_New_Face(freetype, fontfile.c_str(), 0, &ftface)) {
229
229
        throw FXFontException(fontfile);
230
230
    }
231
 
 
 
231
   
232
232
    int ft_font_size = 64 * size;
233
233
 
234
234
    FT_Set_Char_Size( ftface, ft_font_size, ft_font_size, dpi, dpi );
235
235
 
 
236
    double em_size = 1.0 * ftface->units_per_EM;
 
237
 
 
238
    unit_scale = vec2( ftface->size->metrics.x_ppem / em_size, ftface->size->metrics.y_ppem / em_size);
 
239
    
236
240
    precache("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;:'\",<.>/?-_=+!@#$%^&*()\\ ");
237
241
}
238
242
 
308
312
    return max_height;
309
313
}
310
314
 
 
315
float FXGlyphSet::getAscender() const {
 
316
    return getFTFace()->ascender * unit_scale.y;
 
317
}
 
318
 
 
319
float FXGlyphSet::getDescender() const {
 
320
    return getFTFace()->descender * unit_scale.y;
 
321
}
 
322
 
311
323
float FXGlyphSet::getWidth(const std::string& text) {
312
324
 
313
325
    FTUnicodeStringItr<unsigned char> unicode_text((const unsigned char*)text.c_str());
325
337
    return width;
326
338
}
327
339
 
328
 
float FXGlyphSet::getAscender() const {
329
 
    return getFTFace()->ascender / 64.0f;
330
 
}
331
 
 
332
340
void FXGlyphSet::drawToVBO(vec2& cursor, const std::string& text, const vec4& colour) {
333
341
    FTUnicodeStringItr<unsigned char> unicode_text((const unsigned char*)text.c_str());
334
342
 
498
506
    return glyphset->getAscender();
499
507
}
500
508
 
 
509
float FXFont::getDescender() const {
 
510
    return glyphset->getDescender();
 
511
}
 
512
 
501
513
void FXFont::render(float x, float y, const std::string& text, const vec4& colour) const{
502
514
 
503
515
    if(fontmanager.use_vbo) {
538
550
    }
539
551
 
540
552
    if(align_top) {
541
 
        y += getFontSize() + (glyphset->getFTFace()->descender / 64.0f);
 
553
        y += glm::ceil(getAscender() + getDescender());
542
554
    }
543
555
 
544
556
    if(round) {