diff options
author | Jacek Antonelli | 2010-09-08 23:55:14 -0500 |
---|---|---|
committer | McCabe Maxsted | 2010-09-10 19:23:20 -0700 |
commit | 0612f98a90e795724baeb1966f1e7e35c5a26289 (patch) | |
tree | 34947fad0b4fa3c4a161048be20c409cc2f3b4bb /linden/indra/llrender | |
parent | Added Preferences > Fonts tab, with basic font chooser. (diff) | |
download | meta-impy-0612f98a90e795724baeb1966f1e7e35c5a26289.zip meta-impy-0612f98a90e795724baeb1966f1e7e35c5a26289.tar.gz meta-impy-0612f98a90e795724baeb1966f1e7e35c5a26289.tar.bz2 meta-impy-0612f98a90e795724baeb1966f1e7e35c5a26289.tar.xz |
Added the concept of aliases to LLFontRegistry.
SansSerif is now an alias for either "DejaVu" or "Liberation",
depending on the user's FontChoice setting.
Diffstat (limited to 'linden/indra/llrender')
-rw-r--r-- | linden/indra/llrender/llfontregistry.cpp | 38 | ||||
-rw-r--r-- | linden/indra/llrender/llfontregistry.h | 14 |
2 files changed, 52 insertions, 0 deletions
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) | |||
177 | // This is potentially a slow directory traversal, so we want to | 177 | // This is potentially a slow directory traversal, so we want to |
178 | // cache the result. | 178 | // cache the result. |
179 | mUltimateFallbackList = LLWindow::getDynamicFallbackFontList(); | 179 | mUltimateFallbackList = LLWindow::getDynamicFallbackFontList(); |
180 | |||
181 | std::string font_choice = gSavedSettings.getString("FontChoice"); | ||
182 | setAlias("SansSerif", font_choice); | ||
180 | } | 183 | } |
181 | 184 | ||
182 | LLFontRegistry::~LLFontRegistry() | 185 | LLFontRegistry::~LLFontRegistry() |
@@ -511,6 +514,13 @@ LLFontGL *LLFontRegistry::getFont(const LLFontDescriptor& orig_desc) | |||
511 | { | 514 | { |
512 | LLFontDescriptor norm_desc = orig_desc.normalize(); | 515 | LLFontDescriptor norm_desc = orig_desc.normalize(); |
513 | 516 | ||
517 | if (hasAlias(norm_desc.getName())) | ||
518 | { | ||
519 | // llinfos << "Font " << norm_desc.getName() << " is alias for " | ||
520 | // << expandAlias(norm_desc.getName()) << llendl; | ||
521 | norm_desc.setName(expandAlias(norm_desc.getName())); | ||
522 | } | ||
523 | |||
514 | font_reg_map_t::iterator it = mFontMap.find(norm_desc); | 524 | font_reg_map_t::iterator it = mFontMap.find(norm_desc); |
515 | if (it != mFontMap.end()) | 525 | if (it != mFontMap.end()) |
516 | return it->second; | 526 | return it->second; |
@@ -649,3 +659,31 @@ void LLFontRegistry::dump() | |||
649 | } | 659 | } |
650 | } | 660 | } |
651 | } | 661 | } |
662 | |||
663 | |||
664 | |||
665 | std::string LLFontRegistry::expandAlias(std::string alias_name) | ||
666 | { | ||
667 | font_alias_map_t::iterator it = mFontAliases.find(alias_name); | ||
668 | if (it != mFontAliases.end()) | ||
669 | { | ||
670 | return it->second; | ||
671 | } | ||
672 | return alias_name; | ||
673 | } | ||
674 | |||
675 | void LLFontRegistry::setAlias(std::string alias_name, std::string orig_name) | ||
676 | { | ||
677 | mFontAliases[alias_name] = orig_name; | ||
678 | } | ||
679 | |||
680 | void LLFontRegistry::clearAlias(std::string alias_name) | ||
681 | { | ||
682 | mFontAliases.erase(alias_name); | ||
683 | } | ||
684 | |||
685 | bool LLFontRegistry::hasAlias(std::string alias_name) | ||
686 | { | ||
687 | font_alias_map_t::iterator it = mFontAliases.find(alias_name); | ||
688 | return (it != mFontAliases.end()); | ||
689 | } | ||
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: | |||
97 | 97 | ||
98 | const string_vec_t& getUltimateFallbackList() const { return mUltimateFallbackList; } | 98 | const string_vec_t& getUltimateFallbackList() const { return mUltimateFallbackList; } |
99 | 99 | ||
100 | // If alias_name is a defined alias, returns the original name. | ||
101 | // Otherwise returns alias_name itself. | ||
102 | std::string expandAlias(std::string alias_name); | ||
103 | // Define alias_name as an alias of orig_name. | ||
104 | void setAlias(std::string alias_name, std::string orig_name); | ||
105 | // Undefines the alias alias_name. Does nothing if it's not an alias. | ||
106 | void clearAlias(std::string alias_name); | ||
107 | // True if the alias is defined. | ||
108 | bool hasAlias(std::string alias_name); | ||
109 | |||
110 | |||
100 | private: | 111 | private: |
101 | LLFontGL *createFont(const LLFontDescriptor& desc); | 112 | LLFontGL *createFont(const LLFontDescriptor& desc); |
102 | typedef std::map<LLFontDescriptor,LLFontGL*> font_reg_map_t; | 113 | typedef std::map<LLFontDescriptor,LLFontGL*> font_reg_map_t; |
103 | typedef std::map<std::string,F32> font_size_map_t; | 114 | typedef std::map<std::string,F32> font_size_map_t; |
115 | typedef std::map<std::string,std::string> font_alias_map_t; | ||
104 | 116 | ||
105 | // Given a descriptor, look up specific font instantiation. | 117 | // Given a descriptor, look up specific font instantiation. |
106 | font_reg_map_t mFontMap; | 118 | font_reg_map_t mFontMap; |
107 | // Given a size name, look up the point size. | 119 | // Given a size name, look up the point size. |
108 | font_size_map_t mFontSizes; | 120 | font_size_map_t mFontSizes; |
121 | // Given an alias name, look up the original name. | ||
122 | font_alias_map_t mFontAliases; | ||
109 | 123 | ||
110 | string_vec_t mUltimateFallbackList; | 124 | string_vec_t mUltimateFallbackList; |
111 | string_vec_t mXUIPaths; | 125 | string_vec_t mXUIPaths; |