diff options
Diffstat (limited to 'linden/indra/llrender/llfont.cpp')
-rw-r--r-- | linden/indra/llrender/llfont.cpp | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/linden/indra/llrender/llfont.cpp b/linden/indra/llrender/llfont.cpp index ed787e0..b07d0d6 100644 --- a/linden/indra/llrender/llfont.cpp +++ b/linden/indra/llrender/llfont.cpp | |||
@@ -31,10 +31,11 @@ | |||
31 | #include "llfont.h" | 31 | #include "llfont.h" |
32 | 32 | ||
33 | // Freetype stuff | 33 | // Freetype stuff |
34 | #if LL_LINUX // I had to do some work to avoid the system-installed FreeType headers... --ryan. | 34 | #if !defined(LL_LINUX) || defined(LL_STANDALONE) |
35 | #include "llfreetype2/freetype/ft2build.h" | 35 | # include <ft2build.h> |
36 | #else | 36 | #else |
37 | #include <ft2build.h> | 37 | // I had to do some work to avoid the system-installed FreeType headers... --ryan. |
38 | # include "llfreetype2/freetype/ft2build.h" | ||
38 | #endif | 39 | #endif |
39 | 40 | ||
40 | // For some reason, this won't work if it's not wrapped in the ifdef | 41 | // For some reason, this won't work if it's not wrapped in the ifdef |
@@ -178,11 +179,20 @@ F32 LLFont::getDescenderHeight() const | |||
178 | 179 | ||
179 | BOOL LLFont::loadFace(const std::string& filename, const F32 point_size, const F32 vert_dpi, const F32 horz_dpi, const S32 components, BOOL is_fallback) | 180 | BOOL LLFont::loadFace(const std::string& filename, const F32 point_size, const F32 vert_dpi, const F32 horz_dpi, const S32 components, BOOL is_fallback) |
180 | { | 181 | { |
182 | // Don't leak face objects. This is also needed to deal with | ||
183 | // changed font file names. | ||
184 | if (mFTFace) | ||
185 | { | ||
186 | FT_Done_Face(mFTFace); | ||
187 | mFTFace = NULL; | ||
188 | } | ||
189 | |||
181 | int error; | 190 | int error; |
191 | |||
182 | error = FT_New_Face( gFTLibrary, | 192 | error = FT_New_Face( gFTLibrary, |
183 | filename.c_str(), | 193 | filename.c_str(), |
184 | 0, | 194 | 0, |
185 | &mFTFace ); | 195 | &mFTFace ); |
186 | 196 | ||
187 | if (error) | 197 | if (error) |
188 | { | 198 | { |
@@ -326,6 +336,9 @@ BOOL LLFont::hasGlyph(const llwchar wch) const | |||
326 | 336 | ||
327 | BOOL LLFont::addChar(const llwchar wch) | 337 | BOOL LLFont::addChar(const llwchar wch) |
328 | { | 338 | { |
339 | if (mFTFace == NULL) | ||
340 | return FALSE; | ||
341 | |||
329 | llassert(!mIsFallback); | 342 | llassert(!mIsFallback); |
330 | //lldebugs << "Adding new glyph for " << wch << " to font" << llendl; | 343 | //lldebugs << "Adding new glyph for " << wch << " to font" << llendl; |
331 | 344 | ||
@@ -378,6 +391,9 @@ void LLFont::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const | |||
378 | 391 | ||
379 | BOOL LLFont::addGlyphFromFont(LLFont *fontp, const llwchar wch, const U32 glyph_index) | 392 | BOOL LLFont::addGlyphFromFont(LLFont *fontp, const llwchar wch, const U32 glyph_index) |
380 | { | 393 | { |
394 | if (mFTFace == NULL) | ||
395 | return FALSE; | ||
396 | |||
381 | llassert(!mIsFallback); | 397 | llassert(!mIsFallback); |
382 | fontp->renderGlyph(glyph_index); | 398 | fontp->renderGlyph(glyph_index); |
383 | S32 width = fontp->mFTFace->glyph->bitmap.width; | 399 | S32 width = fontp->mFTFace->glyph->bitmap.width; |
@@ -501,6 +517,9 @@ BOOL LLFont::addGlyph(const llwchar wch, const U32 glyph_index) | |||
501 | 517 | ||
502 | F32 LLFont::getXAdvance(const llwchar wch) const | 518 | F32 LLFont::getXAdvance(const llwchar wch) const |
503 | { | 519 | { |
520 | if (mFTFace == NULL) | ||
521 | return 0.0; | ||
522 | |||
504 | llassert(!mIsFallback); | 523 | llassert(!mIsFallback); |
505 | U32 glyph_index; | 524 | U32 glyph_index; |
506 | 525 | ||
@@ -569,6 +588,9 @@ F32 LLFont::getXAdvance(const llwchar wch) const | |||
569 | 588 | ||
570 | void LLFont::renderGlyph(const U32 glyph_index) | 589 | void LLFont::renderGlyph(const U32 glyph_index) |
571 | { | 590 | { |
591 | if (mFTFace == NULL) | ||
592 | return; | ||
593 | |||
572 | int error = FT_Load_Glyph(mFTFace, glyph_index, FT_LOAD_DEFAULT ); | 594 | int error = FT_Load_Glyph(mFTFace, glyph_index, FT_LOAD_DEFAULT ); |
573 | llassert(!error); | 595 | llassert(!error); |
574 | 596 | ||
@@ -579,6 +601,9 @@ void LLFont::renderGlyph(const U32 glyph_index) | |||
579 | 601 | ||
580 | F32 LLFont::getXKerning(const llwchar char_left, const llwchar char_right) const | 602 | F32 LLFont::getXKerning(const llwchar char_left, const llwchar char_right) const |
581 | { | 603 | { |
604 | if (mFTFace == NULL) | ||
605 | return 0.0; | ||
606 | |||
582 | llassert(!mIsFallback); | 607 | llassert(!mIsFallback); |
583 | LLFontGlyphInfo* left_glyph_info = get_if_there(mCharGlyphInfoMap, char_left, (LLFontGlyphInfo*)NULL); | 608 | LLFontGlyphInfo* left_glyph_info = get_if_there(mCharGlyphInfoMap, char_left, (LLFontGlyphInfo*)NULL); |
584 | U32 left_glyph = left_glyph_info ? left_glyph_info->mGlyphIndex : 0; | 609 | U32 left_glyph = left_glyph_info ? left_glyph_info->mGlyphIndex : 0; |