diff options
author | Jacek Antonelli | 2010-09-10 14:39:00 -0500 |
---|---|---|
committer | Jacek Antonelli | 2010-09-10 18:50:19 -0500 |
commit | 25e64d972829a4be5aedeeed105c4c40081dc474 (patch) | |
tree | 59cdef5cb4ec9f2a959d3a3d8f65e275800beda9 /linden | |
parent | Added the concept of aliases to LLFontRegistry. (diff) | |
download | meta-impy-25e64d972829a4be5aedeeed105c4c40081dc474.zip meta-impy-25e64d972829a4be5aedeeed105c4c40081dc474.tar.gz meta-impy-25e64d972829a4be5aedeeed105c4c40081dc474.tar.bz2 meta-impy-25e64d972829a4be5aedeeed105c4c40081dc474.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 '')
-rw-r--r-- | linden/indra/llrender/llfontregistry.cpp | 35 | ||||
-rw-r--r-- | linden/indra/llrender/llfontregistry.h | 4 | ||||
-rw-r--r-- | linden/indra/newview/skins/default/xui/en-us/fonts.xml | 18 |
3 files changed, 38 insertions, 19 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(); |
diff --git a/linden/indra/llrender/llfontregistry.h b/linden/indra/llrender/llfontregistry.h index 0add372..67a529f 100644 --- a/linden/indra/llrender/llfontregistry.h +++ b/linden/indra/llrender/llfontregistry.h | |||
@@ -56,6 +56,9 @@ public: | |||
56 | void setName(const std::string& name) { mName = name; } | 56 | void setName(const std::string& name) { mName = name; } |
57 | const std::string& getSize() const { return mSize; } | 57 | const std::string& getSize() const { return mSize; } |
58 | void setSize(const std::string& size) { mSize = size; } | 58 | void setSize(const std::string& size) { mSize = size; } |
59 | F32 getSizeMult() const { return mSizeMult; } | ||
60 | void setSizeMult(F32 size_mult) { mSizeMult = size_mult; } | ||
61 | |||
59 | const std::vector<std::string>& getFileNames() const { return mFileNames; } | 62 | const std::vector<std::string>& getFileNames() const { return mFileNames; } |
60 | std::vector<std::string>& getFileNames() { return mFileNames; } | 63 | std::vector<std::string>& getFileNames() { return mFileNames; } |
61 | const U8 getStyle() const { return mStyle; } | 64 | const U8 getStyle() const { return mStyle; } |
@@ -64,6 +67,7 @@ public: | |||
64 | private: | 67 | private: |
65 | std::string mName; | 68 | std::string mName; |
66 | std::string mSize; | 69 | std::string mSize; |
70 | F32 mSizeMult; | ||
67 | string_vec_t mFileNames; | 71 | string_vec_t mFileNames; |
68 | U8 mStyle; | 72 | U8 mStyle; |
69 | }; | 73 | }; |
diff --git a/linden/indra/newview/skins/default/xui/en-us/fonts.xml b/linden/indra/newview/skins/default/xui/en-us/fonts.xml index df1356b..1aa44fb 100644 --- a/linden/indra/newview/skins/default/xui/en-us/fonts.xml +++ b/linden/indra/newview/skins/default/xui/en-us/fonts.xml | |||
@@ -26,25 +26,29 @@ | |||
26 | 26 | ||
27 | 27 | ||
28 | <font name="DejaVu" | 28 | <font name="DejaVu" |
29 | comment="Name of DejaVu font"> | 29 | comment="Name of DejaVu font" |
30 | size_mult="1.00"> | ||
30 | <file>DejaVuSansCondensed.ttf</file> | 31 | <file>DejaVuSansCondensed.ttf</file> |
31 | </font> | 32 | </font> |
32 | 33 | ||
33 | <font name="DejaVu" | 34 | <font name="DejaVu" |
34 | comment="Name of DejaVu font (bold)" | 35 | comment="Name of DejaVu font (bold)" |
35 | font_style="BOLD"> | 36 | size_mult="1.00" |
37 | font_style="BOLD"> | ||
36 | <file>DejaVuSansCondensed-Bold.ttf</file> | 38 | <file>DejaVuSansCondensed-Bold.ttf</file> |
37 | </font> | 39 | </font> |
38 | 40 | ||
39 | <font name="DejaVu" | 41 | <font name="DejaVu" |
40 | comment="Name of DejaVu font (italic)" | 42 | comment="Name of DejaVu font (italic)" |
41 | font_style="ITALIC"> | 43 | size_mult="1.00" |
44 | font_style="ITALIC"> | ||
42 | <file>DejaVuSansCondensed-Oblique.ttf</file> | 45 | <file>DejaVuSansCondensed-Oblique.ttf</file> |
43 | </font> | 46 | </font> |
44 | 47 | ||
45 | <font name="DejaVu" | 48 | <font name="DejaVu" |
46 | comment="Name of DejaVu font (bold italic)" | 49 | comment="Name of DejaVu font (bold italic)" |
47 | font_style="BOLD|ITALIC"> | 50 | size_mult="1.00" |
51 | font_style="BOLD|ITALIC"> | ||
48 | <file>DejaVuSansCondensed-BoldOblique.ttf</file> | 52 | <file>DejaVuSansCondensed-BoldOblique.ttf</file> |
49 | </font> | 53 | </font> |
50 | 54 | ||