summaryrefslogtreecommitdiff
path: root/indra/llrender/llfontfreetype.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llfontfreetype.cpp')
-rw-r--r--indra/llrender/llfontfreetype.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp
index 62b551f1e0..9a3ae6c55f 100644
--- a/indra/llrender/llfontfreetype.cpp
+++ b/indra/llrender/llfontfreetype.cpp
@@ -144,6 +144,7 @@ LLFontFreetype::LLFontFreetype()
pFtStream(NULL),
#endif
mIsFallback(false),
+ mHinting(EFontHinting::FORCE_AUTOHINT),
mFTFace(NULL),
mRenderGlyphCount(0),
mStyle(0),
@@ -186,7 +187,7 @@ void ft_close_cb(FT_Stream stream) {
}
#endif
-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.
@@ -215,6 +216,8 @@ bool LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v
}
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 */
@@ -272,6 +275,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)
{
@@ -422,7 +431,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
@@ -437,7 +451,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
@@ -700,7 +719,7 @@ void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, ll
if (mFTFace == NULL)
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
@@ -743,7 +762,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.