diff options
| author | Jonathan "Geenz" Goodman <geenz@lindenlab.com> | 2026-04-10 13:10:01 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-10 13:10:01 -0400 |
| commit | 8ffb73b4c0f5141d03cbbdfa8213421effed8eb0 (patch) | |
| tree | a964a5bba0e8d8e8bbe288cff98a357cbdc7daab /indra/llrender/llfontfreetype.cpp | |
| parent | f4bc7652f8ec4dac7c41e40287615c56ac1cec10 (diff) | |
| parent | 7fc1d9a1aec58acfc4359ffa45c8b1ce342fb2d8 (diff) | |
Merge pull request #5475 from secondlife/project/Flat_UI
Flat UI Alpha
Diffstat (limited to 'indra/llrender/llfontfreetype.cpp')
| -rw-r--r-- | indra/llrender/llfontfreetype.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index d37b16ce0c..063e308da0 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -141,6 +141,7 @@ LLFontFreetype::LLFontFreetype() mDescender(0.f), mLineHeight(0.f), mIsFallback(false), + mHinting(EFontHinting::FORCE_AUTOHINT), mFTFace(nullptr), mRenderGlyphCount(0), mStyle(0), @@ -164,7 +165,7 @@ LLFontFreetype::~LLFontFreetype() // mFallbackFonts cleaned up by LLPointer destructor } -bool LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 vert_dpi, F32 horz_dpi, bool is_fallback, S32 face_n) +bool LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 vert_dpi, F32 horz_dpi, bool is_fallback, S32 face_n, EFontHinting hinting, S32 flags) { // Don't leak face objects. This is also needed to deal with // changed font file names. @@ -188,6 +189,8 @@ bool LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v return false; mIsFallback = is_fallback; + mHinting = hinting; + mFontFlags = flags; F32 pixels_per_em = (point_size / 72.f)*vert_dpi; // Size in inches * dpi error = FT_Set_Char_Size(mFTFace, /* handle to face object */ @@ -243,6 +246,12 @@ bool LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v { mStyle |= LLFontGL::BOLD; } + else if (flags & LLFontGL::BOLD) + { + // FontGL applies programmatic bolding to fonts that are a part of 'bold' descriptor but don't have the bold style set. + // Ex: Inter SemiBold doesn't have FT_STYLE_FLAG_BOLD and without this style it would be bolded programmatically. + mStyle |= LLFontGL::BOLD; + } if(mFTFace->style_flags & FT_STYLE_FLAG_ITALIC) { @@ -350,7 +359,12 @@ F32 LLFontFreetype::getXKerning(llwchar char_left, llwchar char_right) const llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, ft_kerning_unfitted, &delta)); - return delta.x*(1.f/64.f); + if (mFTFace->face_flags & FT_FACE_FLAG_SCALABLE) + { + // Return the X advance + return (F32)(delta.x * (1.0 / 64.0)); + } + return (F32)delta.x; } F32 LLFontFreetype::getXKerning(const LLFontGlyphInfo* left_glyph_info, const LLFontGlyphInfo* right_glyph_info) const @@ -365,7 +379,12 @@ F32 LLFontFreetype::getXKerning(const LLFontGlyphInfo* left_glyph_info, const LL llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, ft_kerning_unfitted, &delta)); - return delta.x*(1.f/64.f); + if (mFTFace->face_flags & FT_FACE_FLAG_SCALABLE) + { + // Return the X advance + return (F32)(delta.x * (1.0 / 64.0)); + } + return (F32)delta.x; } bool LLFontFreetype::hasGlyph(llwchar wch) const @@ -635,7 +654,7 @@ void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, ll if (mFTFace == nullptr) return; - FT_Int32 load_flags = FT_LOAD_FORCE_AUTOHINT; + FT_Int32 load_flags = (FT_Int32)mHinting; if (EFontGlyphType::Color == bitmap_type) { // We may not actually get a color render so our caller should always examine mFTFace->glyph->bitmap.pixel_mode @@ -678,7 +697,7 @@ void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, ll void LLFontFreetype::reset(F32 vert_dpi, F32 horz_dpi) { resetBitmapCache(); - loadFace(mName, mPointSize, vert_dpi ,horz_dpi, mIsFallback, 0); + loadFace(mName, mPointSize, vert_dpi ,horz_dpi, mIsFallback, 0, mHinting, mFontFlags); if (!mIsFallback) { // This is the head of the list - need to rebuild ourself and all fallbacks. |
