diff options
author | Jacek Antonelli | 2010-09-10 14:39:00 -0500 |
---|---|---|
committer | McCabe Maxsted | 2010-09-10 19:23:34 -0700 |
commit | f42f2c7aa4f5c9b2f1db249495f66845385f7239 (patch) | |
tree | 24d96be9ff5b06b6f81bd5c78e1461dda89ec225 /linden/indra/llrender/llfontregistry.cpp | |
parent | Added the concept of aliases to LLFontRegistry. (diff) | |
download | meta-impy-f42f2c7aa4f5c9b2f1db249495f66845385f7239.zip meta-impy-f42f2c7aa4f5c9b2f1db249495f66845385f7239.tar.gz meta-impy-f42f2c7aa4f5c9b2f1db249495f66845385f7239.tar.bz2 meta-impy-f42f2c7aa4f5c9b2f1db249495f66845385f7239.tar.xz |
Added the concept of font size multiplier (size_mult).
This compensates for inherent size differences in each font family,
so that UI text is a consistent size, no matter which font you use.
Diffstat (limited to 'linden/indra/llrender/llfontregistry.cpp')
-rw-r--r-- | linden/indra/llrender/llfontregistry.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/linden/indra/llrender/llfontregistry.cpp b/linden/indra/llrender/llfontregistry.cpp index cbd0d5a..b1d8c5c 100644 --- a/linden/indra/llrender/llfontregistry.cpp +++ b/linden/indra/llrender/llfontregistry.cpp | |||
@@ -48,7 +48,8 @@ using std::map; | |||
48 | bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc); | 48 | bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc); |
49 | 49 | ||
50 | LLFontDescriptor::LLFontDescriptor(): | 50 | LLFontDescriptor::LLFontDescriptor(): |
51 | mStyle(0) | 51 | mStyle(0), |
52 | mSizeMult(1.0) | ||
52 | { | 53 | { |
53 | } | 54 | } |
54 | 55 | ||
@@ -59,7 +60,8 @@ LLFontDescriptor::LLFontDescriptor(const std::string& name, | |||
59 | mName(name), | 60 | mName(name), |
60 | mSize(size), | 61 | mSize(size), |
61 | mStyle(style), | 62 | mStyle(style), |
62 | mFileNames(file_names) | 63 | mFileNames(file_names), |
64 | mSizeMult(1.0) | ||
63 | { | 65 | { |
64 | } | 66 | } |
65 | 67 | ||
@@ -68,7 +70,8 @@ LLFontDescriptor::LLFontDescriptor(const std::string& name, | |||
68 | const U8 style): | 70 | const U8 style): |
69 | mName(name), | 71 | mName(name), |
70 | mSize(size), | 72 | mSize(size), |
71 | mStyle(style) | 73 | mStyle(style), |
74 | mSizeMult(1.0) | ||
72 | { | 75 | { |
73 | } | 76 | } |
74 | 77 | ||
@@ -165,7 +168,9 @@ LLFontDescriptor LLFontDescriptor::normalize() const | |||
165 | if (removeSubString(new_name,"Italic")) | 168 | if (removeSubString(new_name,"Italic")) |
166 | new_style |= LLFontGL::ITALIC; | 169 | new_style |= LLFontGL::ITALIC; |
167 | 170 | ||
168 | return LLFontDescriptor(new_name,new_size,new_style,getFileNames()); | 171 | LLFontDescriptor norm(new_name,new_size,new_style,getFileNames()); |
172 | norm.setSizeMult(mSizeMult); | ||
173 | return norm; | ||
169 | } | 174 | } |
170 | 175 | ||
171 | LLFontRegistry::LLFontRegistry(const string_vec_t& xui_paths) | 176 | LLFontRegistry::LLFontRegistry(const string_vec_t& xui_paths) |
@@ -255,6 +260,12 @@ bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc) | |||
255 | } | 260 | } |
256 | 261 | ||
257 | desc.setSize(s_template_string); | 262 | desc.setSize(s_template_string); |
263 | |||
264 | F32 attr_size_mult; | ||
265 | if (node->getAttributeF32("size_mult",attr_size_mult)) | ||
266 | { | ||
267 | desc.setSizeMult(attr_size_mult); | ||
268 | } | ||
258 | } | 269 | } |
259 | 270 | ||
260 | LLXMLNodePtr child; | 271 | LLXMLNodePtr child; |
@@ -363,7 +374,6 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) | |||
363 | return NULL; | 374 | return NULL; |
364 | } | 375 | } |
365 | llinfos << "createFont " << norm_desc.getName() << " size " << norm_desc.getSize() << " style " << ((S32) norm_desc.getStyle()) << llendl; | 376 | llinfos << "createFont " << norm_desc.getName() << " size " << norm_desc.getSize() << " style " << ((S32) norm_desc.getStyle()) << llendl; |
366 | F32 fallback_scale = 1.0; | ||
367 | 377 | ||
368 | // Find corresponding font template (based on same descriptor with no size specified) | 378 | // Find corresponding font template (based on same descriptor with no size specified) |
369 | LLFontDescriptor template_desc(norm_desc); | 379 | LLFontDescriptor template_desc(norm_desc); |
@@ -431,13 +441,13 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) | |||
431 | LLFontGL *fontp = new LLFontGL; | 441 | LLFontGL *fontp = new LLFontGL; |
432 | std::string font_path = local_path + *file_name_it; | 442 | std::string font_path = local_path + *file_name_it; |
433 | BOOL is_fallback = !is_first_found; | 443 | BOOL is_fallback = !is_first_found; |
434 | F32 extra_scale = (is_fallback)?fallback_scale:1.0; | 444 | F32 size_mult = (is_fallback ? 1 : match_desc->getSizeMult()); |
435 | if (!fontp->loadFace(font_path, extra_scale * point_size, | 445 | if (!fontp->loadFace(font_path, point_size * size_mult, |
436 | LLFontGL::sVertDPI, LLFontGL::sHorizDPI, 2, is_fallback)) | 446 | LLFontGL::sVertDPI, LLFontGL::sHorizDPI, 2, is_fallback)) |
437 | { | 447 | { |
438 | font_path = sys_path + *file_name_it; | 448 | font_path = sys_path + *file_name_it; |
439 | 449 | ||
440 | if (!fontp->loadFace(font_path, extra_scale * point_size, | 450 | if (!fontp->loadFace(font_path, point_size * size_mult, |
441 | LLFontGL::sVertDPI, LLFontGL::sHorizDPI, 2, is_fallback)) | 451 | LLFontGL::sVertDPI, LLFontGL::sHorizDPI, 2, is_fallback)) |
442 | { | 452 | { |
443 | LL_INFOS_ONCE("LLFontRegistry") << "Couldn't load font " << *file_name_it << LL_ENDL; | 453 | LL_INFOS_ONCE("LLFontRegistry") << "Couldn't load font " << *file_name_it << LL_ENDL; |
@@ -526,12 +536,12 @@ LLFontGL *LLFontRegistry::getFont(const LLFontDescriptor& orig_desc) | |||
526 | return it->second; | 536 | return it->second; |
527 | else | 537 | else |
528 | { | 538 | { |
529 | LLFontGL *fontp = createFont(orig_desc); | 539 | LLFontGL *fontp = createFont(norm_desc); |
530 | if (!fontp) | 540 | if (!fontp) |
531 | { | 541 | { |
532 | llwarns << "getFont failed, name " << orig_desc.getName() | 542 | llwarns << "getFont failed, name " << norm_desc.getName() |
533 | <<" style=[" << ((S32) orig_desc.getStyle()) << "]" | 543 | <<" style=[" << ((S32) norm_desc.getStyle()) << "]" |
534 | << " size=[" << orig_desc.getSize() << "]" << llendl; | 544 | << " size=[" << norm_desc.getSize() << "]" << llendl; |
535 | } | 545 | } |
536 | return fontp; | 546 | return fontp; |
537 | } | 547 | } |
@@ -649,6 +659,7 @@ void LLFontRegistry::dump() | |||
649 | llinfos << "Font: name=" << desc.getName() | 659 | llinfos << "Font: name=" << desc.getName() |
650 | << " style=[" << ((S32)desc.getStyle()) << "]" | 660 | << " style=[" << ((S32)desc.getStyle()) << "]" |
651 | << " size=[" << desc.getSize() << "]" | 661 | << " size=[" << desc.getSize() << "]" |
662 | << " size_mult=[" << desc.getSizeMult() << "]" | ||
652 | << " fileNames=" | 663 | << " fileNames=" |
653 | << llendl; | 664 | << llendl; |
654 | for (string_vec_t::const_iterator file_it=desc.getFileNames().begin(); | 665 | for (string_vec_t::const_iterator file_it=desc.getFileNames().begin(); |