From 0612f98a90e795724baeb1966f1e7e35c5a26289 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Wed, 8 Sep 2010 23:55:14 -0500 Subject: Added the concept of aliases to LLFontRegistry. SansSerif is now an alias for either "DejaVu" or "Liberation", depending on the user's FontChoice setting. --- linden/indra/llrender/llfontregistry.cpp | 38 ++++++++++++++++++++++++++++++++ linden/indra/llrender/llfontregistry.h | 14 ++++++++++++ 2 files changed, 52 insertions(+) (limited to 'linden/indra/llrender') diff --git a/linden/indra/llrender/llfontregistry.cpp b/linden/indra/llrender/llfontregistry.cpp index 619228e..cbd0d5a 100644 --- a/linden/indra/llrender/llfontregistry.cpp +++ b/linden/indra/llrender/llfontregistry.cpp @@ -177,6 +177,9 @@ LLFontRegistry::LLFontRegistry(const string_vec_t& xui_paths) // This is potentially a slow directory traversal, so we want to // cache the result. mUltimateFallbackList = LLWindow::getDynamicFallbackFontList(); + + std::string font_choice = gSavedSettings.getString("FontChoice"); + setAlias("SansSerif", font_choice); } LLFontRegistry::~LLFontRegistry() @@ -511,6 +514,13 @@ LLFontGL *LLFontRegistry::getFont(const LLFontDescriptor& orig_desc) { LLFontDescriptor norm_desc = orig_desc.normalize(); + if (hasAlias(norm_desc.getName())) + { + // llinfos << "Font " << norm_desc.getName() << " is alias for " + // << expandAlias(norm_desc.getName()) << llendl; + norm_desc.setName(expandAlias(norm_desc.getName())); + } + font_reg_map_t::iterator it = mFontMap.find(norm_desc); if (it != mFontMap.end()) return it->second; @@ -649,3 +659,31 @@ void LLFontRegistry::dump() } } } + + + +std::string LLFontRegistry::expandAlias(std::string alias_name) +{ + font_alias_map_t::iterator it = mFontAliases.find(alias_name); + if (it != mFontAliases.end()) + { + return it->second; + } + return alias_name; +} + +void LLFontRegistry::setAlias(std::string alias_name, std::string orig_name) +{ + mFontAliases[alias_name] = orig_name; +} + +void LLFontRegistry::clearAlias(std::string alias_name) +{ + mFontAliases.erase(alias_name); +} + +bool LLFontRegistry::hasAlias(std::string alias_name) +{ + font_alias_map_t::iterator it = mFontAliases.find(alias_name); + return (it != mFontAliases.end()); +} diff --git a/linden/indra/llrender/llfontregistry.h b/linden/indra/llrender/llfontregistry.h index 523e184..0add372 100644 --- a/linden/indra/llrender/llfontregistry.h +++ b/linden/indra/llrender/llfontregistry.h @@ -97,15 +97,29 @@ public: const string_vec_t& getUltimateFallbackList() const { return mUltimateFallbackList; } + // If alias_name is a defined alias, returns the original name. + // Otherwise returns alias_name itself. + std::string expandAlias(std::string alias_name); + // Define alias_name as an alias of orig_name. + void setAlias(std::string alias_name, std::string orig_name); + // Undefines the alias alias_name. Does nothing if it's not an alias. + void clearAlias(std::string alias_name); + // True if the alias is defined. + bool hasAlias(std::string alias_name); + + private: LLFontGL *createFont(const LLFontDescriptor& desc); typedef std::map font_reg_map_t; typedef std::map font_size_map_t; + typedef std::map font_alias_map_t; // Given a descriptor, look up specific font instantiation. font_reg_map_t mFontMap; // Given a size name, look up the point size. font_size_map_t mFontSizes; + // Given an alias name, look up the original name. + font_alias_map_t mFontAliases; string_vec_t mUltimateFallbackList; string_vec_t mXUIPaths; -- cgit v1.1