summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@lindenlab.com>2026-05-20 11:57:48 -0400
committerGitHub <noreply@github.com>2026-05-20 11:57:48 -0400
commit9c2ee024bef564ebb6e2e8942b43ffae1d99232c (patch)
tree6c6c6bebf982cda7b056156fb206378dbc443fe7 /indra/llrender
parent491b0b32c74e2186dd34f9be8513bb08d390dfe2 (diff)
parent3f82abe033887ff690398381563100735e008df4 (diff)
Merge pull request #5843 from secondlife/geenz/26.2-to-26.3
26.2 to 26.3
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llfontfreetype.cpp141
-rw-r--r--indra/llrender/llfontfreetype.h15
-rw-r--r--indra/llrender/llfontgl.cpp13
-rw-r--r--indra/llrender/llfontgl.h3
-rw-r--r--indra/llrender/llfontregistry.cpp66
-rw-r--r--indra/llrender/llfontregistry.h31
-rw-r--r--indra/llrender/llrender.cpp63
-rw-r--r--indra/llrender/llrender.h13
8 files changed, 252 insertions, 93 deletions
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp
index d9857a7ad5..075c496ec5 100644
--- a/indra/llrender/llfontfreetype.cpp
+++ b/indra/llrender/llfontfreetype.cpp
@@ -39,6 +39,7 @@
// For some reason, this won't work if it's not wrapped in the ifdef
#ifdef FT_FREETYPE_H
#include FT_FREETYPE_H
+#include FT_MULTIPLE_MASTERS_H
#endif
#include "lldir.h"
@@ -116,6 +117,8 @@ LLFontGlyphInfo::LLFontGlyphInfo(U32 index, EFontGlyphType glyph_type)
mYBitmapOffset(0), // Offset to the origin in the bitmap
mXBearing(0), // Distance from baseline to left in pixels
mYBearing(0), // Distance from baseline to top in pixels
+ mLsbDelta(0),
+ mRsbDelta(0),
mBitmapEntry(std::make_pair(EFontGlyphType::Unspecified, -1)) // Which bitmap in the bitmap cache contains this glyph
{
}
@@ -131,6 +134,8 @@ LLFontGlyphInfo::LLFontGlyphInfo(const LLFontGlyphInfo& fgi)
, mYBitmapOffset(fgi.mYBitmapOffset)
, mXBearing(fgi.mXBearing)
, mYBearing(fgi.mYBearing)
+ , mLsbDelta(fgi.mLsbDelta)
+ , mRsbDelta(fgi.mRsbDelta)
{
mBitmapEntry = fgi.mBitmapEntry;
}
@@ -141,6 +146,7 @@ LLFontFreetype::LLFontFreetype()
mDescender(0.f),
mLineHeight(0.f),
mIsFallback(false),
+ mHinting(EFontHinting::FORCE_AUTOHINT),
mFTFace(nullptr),
mRenderGlyphCount(0),
mStyle(0),
@@ -164,7 +170,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, S32 weight, 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 +194,20 @@ bool LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v
return false;
mIsFallback = is_fallback;
+ mHinting = hinting;
+ mFontFlags = flags;
+ mWeight = weight;
+
+ bool variable_font = false;
+ if (weight >= 0)
+ {
+ variable_font = setVariationAxis("wght", static_cast<F32>(weight));
+
+ // For Inter, also set optical size based on point size
+ // This makes text look better at different sizes
+ setVariationAxis("opsz", point_size);
+ }
+
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 +263,18 @@ 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;
+ }
+ else if (weight >= 600 && variable_font)
+ {
+ // If the font is heavy enough, consider it bold and avoid programmatic bolding
+ // even if it doesn't have the bold style set.
+ mStyle |= LLFontGL::BOLD;
+ }
if(mFTFace->style_flags & FT_STYLE_FLAG_ITALIC)
{
@@ -341,16 +373,10 @@ F32 LLFontFreetype::getXKerning(llwchar char_left, llwchar char_right) const
//llassert(!mIsFallback);
LLFontGlyphInfo* left_glyph_info = getGlyphInfo(char_left, EFontGlyphType::Unspecified);;
- U32 left_glyph = left_glyph_info ? left_glyph_info->mGlyphIndex : 0;
// Kern this puppy.
LLFontGlyphInfo* right_glyph_info = getGlyphInfo(char_right, EFontGlyphType::Unspecified);
- U32 right_glyph = right_glyph_info ? right_glyph_info->mGlyphIndex : 0;
- FT_Vector delta;
-
- llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, ft_kerning_unfitted, &delta));
-
- return delta.x*(1.f/64.f);
+ return getXKerning(left_glyph_info, right_glyph_info);
}
F32 LLFontFreetype::getXKerning(const LLFontGlyphInfo* left_glyph_info, const LLFontGlyphInfo* right_glyph_info) const
@@ -363,9 +389,28 @@ F32 LLFontFreetype::getXKerning(const LLFontGlyphInfo* left_glyph_info, const LL
FT_Vector delta;
- llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, ft_kerning_unfitted, &delta));
+ llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, FT_KERNING_UNFITTED, &delta));
- return delta.x*(1.f/64.f);
+ // Apply the FreeType auto-hinter's subpixel side-bearing correction between
+ // adjacent glyphs. When the hinter has shifted the right side of the left
+ // glyph or the left side of the right glyph, (rsb_delta - lsb_delta) is the
+ // sub-pixel nudge that keeps spacing visually even.
+ F32 delta_correction = 0.0f;
+ if (left_glyph_info && right_glyph_info)
+ {
+ // According to FreeType docs, these delta values should only trigger
+ // discrete ±1 pixel adjustments when they cross certain thresholds.
+ // Substructing delta_diff from delta.x doesn't work as well as treating
+ // it as a thresholds
+ S32 delta_diff = left_glyph_info->mRsbDelta - right_glyph_info->mLsbDelta;
+ if (delta_diff > 32)
+ delta_correction = -1.0f;
+ else if (delta_diff < -31)
+ delta_correction = 1.0f;
+ }
+
+ // ft_kerning_unfitted mode always returns 26.6 fixed-point values
+ return (F32)(delta.x * (1.f / 64.f)) + delta_correction;
}
bool LLFontFreetype::hasGlyph(llwchar wch) const
@@ -510,6 +555,11 @@ LLFontGlyphInfo* LLFontFreetype::addGlyphFromFont(const LLFontFreetype *fontp, l
gi->mHeight = height;
gi->mXBearing = fontp->mFTFace->glyph->bitmap_left;
gi->mYBearing = fontp->mFTFace->glyph->bitmap_top;
+ // FreeType fills these when the glyph has been auto-hinted; they describe how
+ // much the hinter nudged the left/right side bearings (in 26.6 pixels). Keep
+ // them so inter-glyph spacing can be corrected in getXKerning().
+ gi->mLsbDelta = (S32)fontp->mFTFace->glyph->lsb_delta;
+ gi->mRsbDelta = (S32)fontp->mFTFace->glyph->rsb_delta;
// Convert these from 26.6 units to float pixels.
gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f;
gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f;
@@ -635,7 +685,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 +728,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, mWeight, mIsFallback, 0, mHinting, mFontFlags);
if (!mIsFallback)
{
// This is the head of the list - need to rebuild ourself and all fallbacks.
@@ -846,6 +896,73 @@ void LLFontFreetype::setSubImageLuminanceAlpha(U32 x, U32 y, U32 bitmap_num, U32
}
}
+bool LLFontFreetype::setVariationAxis(const std::string& axis_tag, F32 value)
+{
+ if (!mFTFace)
+ return false;
+
+ // Check if this is a variable font
+ FT_MM_Var* master = nullptr;
+ if (FT_Get_MM_Var(mFTFace, &master) != 0)
+ {
+ // Not a variable font - this is not an error, just silently skip
+ return false;
+ }
+
+ // Find the axis by tag (e.g., "wght" for weight)
+ FT_UInt axis_index = 0;
+ bool found = false;
+ for (FT_UInt i = 0; i < master->num_axis; i++)
+ {
+ // Compare the 4-byte tag
+ if (master->axis[i].tag == FT_MAKE_TAG(axis_tag[0], axis_tag[1], axis_tag[2], axis_tag[3]))
+ {
+ axis_index = i;
+ found = true;
+
+ // Clamp value to valid range for this axis
+ F32 min_val = master->axis[i].minimum / 65536.0f;
+ F32 max_val = master->axis[i].maximum / 65536.0f;
+ value = llclamp(value, min_val, max_val);
+
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ FT_Done_MM_Var(gFTLibrary, master);
+ LL_WARNS_ONCE("Font") << "Axis '" << axis_tag << "' not found in font: " << mName << LL_ENDL;
+ return false;
+ }
+
+ FT_UInt num_coords = master->num_axis;
+ FT_Fixed* coords = new FT_Fixed[num_coords];
+
+ // Get current coordinates
+ FT_Get_Var_Design_Coordinates(mFTFace, num_coords, coords);
+
+ // Update the specific axis
+ coords[axis_index] = (FT_Fixed)(value * 65536.0f);
+
+ // Set all coordinates
+ int error = FT_Set_Var_Design_Coordinates(mFTFace, num_coords, coords);
+
+ delete[] coords;
+ FT_Done_MM_Var(gFTLibrary, master);
+
+ if (error != 0)
+ {
+ LL_WARNS() << "Failed to set variation coordinates for " << axis_tag
+ << " = " << value << " in font: " << mName << LL_ENDL;
+ return false;
+ }
+
+ LL_DEBUGS("Font") << "Set " << axis_tag << " = " << value
+ << " for font: " << mName << LL_ENDL;
+ return true;
+}
+
namespace ll
{
diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h
index f7600e40a3..d2164e8fa2 100644
--- a/indra/llrender/llfontfreetype.h
+++ b/indra/llrender/llfontfreetype.h
@@ -43,6 +43,7 @@ struct FT_FaceRec_;
typedef struct FT_FaceRec_* LLFT_Face;
struct FT_StreamRec_;
typedef struct FT_StreamRec_ LLFT_Stream;
+enum class EFontHinting : S32;
namespace ll
{
@@ -87,6 +88,8 @@ struct LLFontGlyphInfo
S32 mYBitmapOffset; // Offset to the origin in the bitmap
S32 mXBearing; // Distance from baseline to left in pixels
S32 mYBearing; // Distance from baseline to top in pixels
+ S32 mLsbDelta; // FreeType subpixel left side bearing delta (26.6 units)
+ S32 mRsbDelta; // FreeType subpixel right side bearing delta (26.6 units)
std::pair<EFontGlyphType, S32> mBitmapEntry; // Which bitmap in the bitmap cache contains this glyph
};
@@ -100,7 +103,7 @@ public:
// is_fallback should be true for fallback fonts that aren't used
// to render directly (Unicode backup, primarily)
- bool loadFace(const std::string& filename, F32 point_size, F32 vert_dpi, F32 horz_dpi, bool is_fallback, S32 face_n);
+ bool loadFace(const std::string& filename, F32 point_size, F32 vert_dpi, F32 horz_dpi, S32 weight, bool is_fallback, S32 face_n, EFontHinting hinting, S32 flags);
S32 getNumFaces(const std::string& filename);
@@ -162,9 +165,14 @@ private:
void resetBitmapCache();
void setSubImageLuminanceAlpha(U32 x, U32 y, U32 bitmap_num, U32 width, U32 height, U8 *data, S32 stride = 0) const;
bool setSubImageBGRA(U32 x, U32 y, U32 bitmap_num, U16 width, U16 height, const U8* data, U32 stride) const;
+ bool setVariationAxis(const std::string& axis_tag, F32 value);
bool hasGlyph(llwchar wch) const; // Has a glyph for this character
LLFontGlyphInfo* addGlyph(llwchar wch, EFontGlyphType glyph_type) const; // Add a new character to the font if necessary
- LLFontGlyphInfo* addGlyphFromFont(const LLFontFreetype *fontp, llwchar wch, U32 glyph_index, EFontGlyphType bitmap_type) const; // Add a glyph from this font to the other (returns the glyph_index, 0 if not found)
+ LLFontGlyphInfo* addGlyphFromFont(
+ const LLFontFreetype *fontp,
+ llwchar wch,
+ U32 glyph_index,
+ EFontGlyphType bitmap_type) const; // Add a glyph from this font to the other (returns the glyph_index, 0 if not found)
void renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, llwchar wch) const;
void insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const;
@@ -180,6 +188,9 @@ private:
LLFT_Face mFTFace;
bool mIsFallback;
+ EFontHinting mHinting;
+ S32 mFontFlags;
+ S32 mWeight = -1;
typedef std::pair<LLPointer<LLFontFreetype>, char_functor_t> fallback_font_t;
typedef std::vector<fallback_font_t> fallback_font_vector_t;
fallback_font_vector_t mFallbackFonts; // A list of fallback fonts to look for glyphs in (for Unicode chars)
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 16eec1fdd2..5d99c35047 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -90,14 +90,14 @@ void LLFontGL::destroyGL()
mFontFreetype->destroyGL();
}
-bool LLFontGL::loadFace(const std::string& filename, F32 point_size, const F32 vert_dpi, const F32 horz_dpi, bool is_fallback, S32 face_n)
+bool LLFontGL::loadFace(const std::string& filename, F32 point_size, const F32 vert_dpi, const F32 horz_dpi, S32 weight, bool is_fallback, S32 face_n, EFontHinting hinting, S32 flags)
{
if(mFontFreetype == reinterpret_cast<LLFontFreetype*>(NULL))
{
mFontFreetype = new LLFontFreetype;
}
- return mFontFreetype->loadFace(filename, point_size, vert_dpi, horz_dpi, is_fallback, face_n);
+ return mFontFreetype->loadFace(filename, point_size, vert_dpi, horz_dpi, weight, is_fallback, face_n, hinting, flags);
}
S32 LLFontGL::getNumFaces(const std::string& filename)
@@ -1115,7 +1115,14 @@ LLFontGL* LLFontGL::getFontSansSerifSmallItalic()
//static
LLFontGL* LLFontGL::getFontSansSerif()
{
- static LLFontGL* fontp = getFont(LLFontDescriptor("SansSerif","Medium",0));
+ static LLFontGL* fontp = getFont(LLFontDescriptor("SansSerif","Small",0));
+ return fontp;
+}
+
+// static
+LLFontGL* LLFontGL::getFontSansSerifMedium()
+{
+ static LLFontGL* fontp = getFont(LLFontDescriptor("SansSerif", "Medium", 0));
return fontp;
}
diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h
index 1c8e036f58..3b82d8e43d 100644
--- a/indra/llrender/llfontgl.h
+++ b/indra/llrender/llfontgl.h
@@ -87,7 +87,7 @@ public:
void destroyGL();
- bool loadFace(const std::string& filename, F32 point_size, const F32 vert_dpi, const F32 horz_dpi, bool is_fallback, S32 face_n);
+ bool loadFace(const std::string& filename, F32 point_size, const F32 vert_dpi, const F32 horz_dpi, S32 weight, bool is_fallback, S32 face_n, EFontHinting hinting, S32 flags);
S32 getNumFaces(const std::string& filename);
S32 getCacheGeneration() const;
@@ -204,6 +204,7 @@ public:
static LLFontGL* getFontSansSerifSmallBold();
static LLFontGL* getFontSansSerifSmallItalic();
static LLFontGL* getFontSansSerif();
+ static LLFontGL* getFontSansSerifMedium();
static LLFontGL* getFontSansSerifBig();
static LLFontGL* getFontSansSerifHuge();
static LLFontGL* getFontSansSerifBold();
diff --git a/indra/llrender/llfontregistry.cpp b/indra/llrender/llfontregistry.cpp
index c48a389f6a..890308ab54 100644
--- a/indra/llrender/llfontregistry.cpp
+++ b/indra/llrender/llfontregistry.cpp
@@ -170,7 +170,7 @@ LLFontDescriptor LLFontDescriptor::normalize() const
if (new_size != s_template_string && new_size.empty() && findSubString(new_name,"Monospace"))
new_size = "Monospace";
if (new_size.empty())
- new_size = "Medium";
+ new_size = "Small";
if (removeSubString(new_name,"Bold"))
new_style |= LLFontGL::BOLD;
@@ -181,16 +181,16 @@ LLFontDescriptor LLFontDescriptor::normalize() const
return LLFontDescriptor(new_name,new_size,new_style, getFontFiles(), getFontCollectionFiles());
}
-void LLFontDescriptor::addFontFile(const std::string& file_name, const std::string& char_functor)
+void LLFontDescriptor::addFontFile(const std::string& file_name, EFontHinting hinting, S32 flags, F32 size_delta, S32 weight, const std::string& char_functor)
{
char_functor_map_t::const_iterator it = mCharFunctors.find(char_functor);
- mFontFiles.push_back(LLFontFileInfo(file_name, (mCharFunctors.end() != it) ? it->second : nullptr));
+ mFontFiles.push_back(LLFontFileInfo(file_name, hinting, flags, size_delta, weight, (mCharFunctors.end() != it) ? it->second : nullptr));
}
-void LLFontDescriptor::addFontCollectionFile(const std::string& file_name, const std::string& char_functor)
+void LLFontDescriptor::addFontCollectionFile(const std::string& file_name, EFontHinting hinting, S32 flags, F32 size_delta, S32 weight, const std::string& char_functor)
{
char_functor_map_t::const_iterator it = mCharFunctors.find(char_functor);
- mFontCollectionFiles.push_back(LLFontFileInfo(file_name, (mCharFunctors.end() != it) ? it->second : nullptr));
+ mFontCollectionFiles.push_back(LLFontFileInfo(file_name, hinting, flags, size_delta, weight, (mCharFunctors.end() != it) ? it->second : nullptr));
}
LLFontRegistry::LLFontRegistry(bool create_gl_textures)
@@ -289,23 +289,69 @@ bool font_desc_init_from_xml(LLXMLNodePtr node, LLFontDescriptor& desc)
{
std::string font_file_name = child->getTextContents();
std::string char_functor;
+ EFontHinting hinting = EFontHinting::FORCE_AUTOHINT;
+ S32 flags = 0;
+ S32 weight = -1;
if (child->hasAttribute("functor"))
{
child->getAttributeString("functor", char_functor);
}
+ if (child->hasAttribute("font_hinting"))
+ {
+ std::string attr_hinting;
+ child->getAttributeString("font_hinting", attr_hinting);
+ LLStringUtil::toLower(attr_hinting);
+
+ if (attr_hinting == "default")
+ {
+ hinting = EFontHinting::DEFAULT;
+ }
+ else if (attr_hinting == "force_auto")
+ {
+ hinting = EFontHinting::FORCE_AUTOHINT;
+ }
+ else if (attr_hinting == "no_hinting")
+ {
+ hinting = EFontHinting::NO_HINTING;
+ }
+ }
+
+ if (child->hasAttribute("flags"))
+ {
+ std::string attr_flags;
+ child->getAttributeString("flags", attr_flags);
+ LLStringUtil::toLower(attr_flags);
+
+ if (attr_flags == "bold")
+ {
+ flags |= LLFontGL::BOLD;
+ }
+ }
+
+ F32 size_delta = 0.f;
+ if (child->hasAttribute("size_delta"))
+ {
+ child->getAttributeF32("size_delta", size_delta);
+ }
+
+ if (child->hasAttribute("font_weight"))
+ {
+ child->getAttributeS32("font_weight", weight);
+ }
+
if (child->hasAttribute("load_collection"))
{
bool col = false;
child->getAttributeBOOL("load_collection", col);
if (col)
{
- desc.addFontCollectionFile(font_file_name, char_functor);
+ desc.addFontCollectionFile(font_file_name, hinting, flags, size_delta, weight, char_functor);
}
}
- desc.addFontFile(font_file_name, char_functor);
+ desc.addFontFile(font_file_name, hinting, flags, size_delta, weight, char_functor);
}
else if (child->hasName("os"))
{
@@ -462,7 +508,7 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc)
// Add ultimate fallback list - generated dynamically on linux,
// null elsewhere.
std::transform(getUltimateFallbackList().begin(), getUltimateFallbackList().end(), std::back_inserter(font_files),
- [](const std::string& file_name) { return LLFontFileInfo(file_name); });
+ [](const std::string& file_name) { return LLFontFileInfo(file_name, EFontHinting::FORCE_AUTOHINT, 0, 0.f, -1); });
// Load fonts based on names.
if (font_files.empty())
@@ -517,8 +563,8 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc)
{
fontp = new LLFontGL;
}
- if (fontp->loadFace(font_path, point_size_scale,
- LLFontGL::sVertDPI, LLFontGL::sHorizDPI, is_fallback, i))
+ if (fontp->loadFace(font_path, point_size_scale + font_file_it->mSizeDelta,
+ LLFontGL::sVertDPI, LLFontGL::sHorizDPI, font_file_it->mWeight, is_fallback, i, font_file_it->mHinting, font_file_it->mFlags))
{
is_font_loaded = true;
if (is_first_found)
diff --git a/indra/llrender/llfontregistry.h b/indra/llrender/llfontregistry.h
index 8bbf5aa30c..fcbb2667e4 100644
--- a/indra/llrender/llfontregistry.h
+++ b/indra/llrender/llfontregistry.h
@@ -34,22 +34,45 @@ class LLFontGL;
typedef std::vector<std::string> string_vec_t;
+enum class EFontHinting : S32
+{
+ DEFAULT = 0,
+ NO_HINTING = 0x8000U,
+ FORCE_AUTOHINT = 0x20,
+};
+
struct LLFontFileInfo
{
- LLFontFileInfo(const std::string& file_name, const std::function<bool(llwchar)>& char_functor = nullptr)
+ LLFontFileInfo(const std::string& file_name, EFontHinting hinting, S32 flags, F32 size_delta, S32 weight, const std::function<bool(llwchar)>& char_functor = nullptr)
: FileName(file_name)
, CharFunctor(char_functor)
+ , mHinting(hinting)
+ , mFlags(flags)
+ , mSizeDelta(size_delta)
+ , mWeight(weight)
{
}
- LLFontFileInfo(const LLFontFileInfo& ffi)
+ LLFontFileInfo(const LLFontFileInfo& ffi, EFontHinting hinting, S32 flags, F32 size_delta, S32 weight)
: FileName(ffi.FileName)
, CharFunctor(ffi.CharFunctor)
+ , mHinting(hinting)
+ , mFlags(flags)
+ , mSizeDelta(size_delta)
+ , mWeight(weight)
{
}
std::string FileName;
std::function<bool(llwchar)> CharFunctor;
+ EFontHinting mHinting;
+ S32 mFlags;
+ S32 mWeight; // -1 - default, whatever is in the file.
+
+ // Not all fonts are the same size, Ex: dejavu is bigger than inter,
+ // so in some cases we want to adjust relative sizes to make characters
+ // from different files match.
+ F32 mSizeDelta;
};
typedef std::vector<LLFontFileInfo> font_file_info_vec_t;
@@ -71,10 +94,10 @@ public:
const std::string& getSize() const { return mSize; }
void setSize(const std::string& size) { mSize = size; }
- void addFontFile(const std::string& file_name, const std::string& char_functor = LLStringUtil::null);
+ void addFontFile(const std::string& file_name, EFontHinting hinting, S32 flags, F32 size_delta, S32 weight, const std::string& char_functor = LLStringUtil::null);
const font_file_info_vec_t & getFontFiles() const { return mFontFiles; }
void setFontFiles(const font_file_info_vec_t& font_files) { mFontFiles = font_files; }
- void addFontCollectionFile(const std::string& file_name, const std::string& char_functor = LLStringUtil::null);
+ void addFontCollectionFile(const std::string& file_name, EFontHinting hinting, S32 flags, F32 size_delta, S32 weight, const std::string& char_functor = LLStringUtil::null);
const font_file_info_vec_t& getFontCollectionFiles() const { return mFontCollectionFiles; }
void setFontCollectionFiles(const font_file_info_vec_t& font_collection_files) { mFontCollectionFiles = font_collection_files; }
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 1a3a499b20..57be8570af 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1774,64 +1774,25 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
return;
}
- LLVector4a vert(x, y, z);
- transform(vert);
- mVerticesp[mCount] = vert;
-
- mCount++;
- mVerticesp[mCount] = mVerticesp[mCount-1];
- mColorsp[mCount] = mColorsp[mCount-1];
- mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
-}
-
-void LLRender::transform(LLVector3& vert)
-{
- if (!mUIOffset.empty())
+ if (mUIOffset.empty())
{
- vert += LLVector3(mUIOffset.back().getF32ptr());
- vert *= LLVector3(mUIScale.back().getF32ptr());
+ mVerticesp[mCount].set(x,y,z);
}
-}
-
-void LLRender::transform(LLVector4a& vert)
-{
- if (!mUIOffset.empty())
+ else
{
+ LLVector4a vert(x, y, z);
vert.add(mUIOffset.back());
vert.mul(mUIScale.back());
+ mVerticesp[mCount] = vert;
}
-}
-
-void LLRender::untransform(LLVector3& vert)
-{
- if (!mUIOffset.empty())
- {
- vert /= LLVector3(mUIScale.back().getF32ptr());
- vert -= LLVector3(mUIOffset.back().getF32ptr());
- }
-}
-
-void LLRender::batchTransform(LLVector4a* verts, U32 vert_count)
-{
- if (!mUIOffset.empty())
- {
- const LLVector4a& offset = mUIOffset.back();
- const LLVector4a& scale = mUIScale.back();
-
- for (U32 i = 0; i < vert_count; ++i)
- {
- verts[i].add(offset);
- verts[i].mul(scale);
- }
- }
-}
-void LLRender::vertexBatchPreTransformed(const std::vector<LLVector4a>& verts)
-{
- vertexBatchPreTransformed(verts.data(), narrow(verts.size()));
+ mCount++;
+ mVerticesp[mCount] = mVerticesp[mCount-1];
+ mColorsp[mCount] = mColorsp[mCount-1];
+ mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
}
-void LLRender::vertexBatchPreTransformed(const LLVector4a* verts, S32 vert_count)
+void LLRender::vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count)
{
if (mCount + vert_count > 4094)
{
@@ -1852,7 +1813,7 @@ void LLRender::vertexBatchPreTransformed(const LLVector4a* verts, S32 vert_count
mVerticesp[mCount] = mVerticesp[mCount-1];
}
-void LLRender::vertexBatchPreTransformed(const LLVector4a* verts, const LLVector2* uvs, S32 vert_count)
+void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 vert_count)
{
if (mCount + vert_count > 4094)
{
@@ -1876,7 +1837,7 @@ void LLRender::vertexBatchPreTransformed(const LLVector4a* verts, const LLVector
}
}
-void LLRender::vertexBatchPreTransformed(const LLVector4a* verts, const LLVector2* uvs, const LLColor4U* colors, S32 vert_count)
+void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLColor4U* colors, S32 vert_count)
{
if (mCount + vert_count > 4094)
{
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index be8539433c..0801c12fb4 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -450,16 +450,9 @@ public:
void diffuseColor4ubv(const U8* c);
void diffuseColor4ub(U8 r, U8 g, U8 b, U8 a);
- void transform(LLVector3& vert);
- void transform(LLVector4a& vert);
- void untransform(LLVector3& vert);
-
- void batchTransform(LLVector4a* verts, U32 vert_count);
-
- void vertexBatchPreTransformed(const std::vector<LLVector4a>& verts);
- void vertexBatchPreTransformed(const LLVector4a* verts, S32 vert_count);
- void vertexBatchPreTransformed(const LLVector4a* verts, const LLVector2* uvs, S32 vert_count);
- void vertexBatchPreTransformed(const LLVector4a* verts, const LLVector2* uvs, const LLColor4U*, S32 vert_count);
+ void vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count);
+ void vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 vert_count);
+ void vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLColor4U*, S32 vert_count);
void setColorMask(bool writeColor, bool writeAlpha);
void setColorMask(bool writeColorR, bool writeColorG, bool writeColorB, bool writeAlpha);