Skip to content
This repository

Add support for uppercase/lowercase in the font.xml <style> tag #966

Merged
merged 3 commits into from almost 2 years ago

6 participants

jmarshallnz PatFrost Jezz babca HitcherUK ronie
jmarshallnz
Owner

Also allows more than one style to be set (they're OR'd internally) using a space separated list.

HitcherUK

Very welcome addition Jonathan but one question - how does it handle accents?

Thanks.

Owner

It handles Australian, New Zealand, English, Scottish, Irish, Canadian (not Quebec though) and US at least :p

It's exactly the same as it's always been basically. The only way to get full accent support is through use of ICU or similar, which I don't think anyone is working on.

OK thanks.

PatFrost

hi,
very cool, I tested under window work fine, but no accents uppercase in french eg: Quebec :)

but with this subText.ToUpper(std::locale("")); at line 407 and 427 in GUITextLayout.cpp it's ok

sorry for french quote
[quote]
toupper() retourne la version en masjuscules du caractère passé en paramètre.
Le second paramètre de la fonction, locale(""), permet de prendre en charge les caractères spéciaux comme les accents.
Aucun paramètre signifie l'anglais. Une chaîne vide correspondra à la localité utilisée sur la machine,
et vous pouvez forcer l'utilisation d'une localité en entrant le nom de celle-ci.
[quote/]

screenshot: http://imageshack.us/photo/my-images/26/screenshot007w.png/

jmarshallnz
Owner

Thanks @PatFrost - will investigate further.

jmarshallnz
Owner

@PatFrost - the problem is that the ctype facet isn't transferred when we set the global locale. So no need to set locale in the ToUpper()'s once this is fixed.

PatFrost

ah ok :)
but this 44c1ac4
fixe uppercase accent. yes !

Jezz
Collaborator
JezzX commented June 01, 2012

Right finally got around to trying this and works as expected I do have a few minor pokes at it.
First is the options to put into are case sensitive and don&#39;t really match what the normal skin code is (they are the same as what it used to be) for example uppercase works but UPPERCASE doesn&#39;t when in the skin we normally use [UNNPERCASE][/UPPERCASE] so might be something to look at to get some uniformity?</p> <p>Also on a side note and probably unrelated to this change font clipping is bad in italics and the font gets cut off <a href="http://img703.imageshack.us/img703/6327/screenshot063ye.png">http://img703.imageshack.us/img703/6327/screenshot063ye.png</a></p>

Jezz
Collaborator
JezzX commented June 01, 2012

wow git but royally is screwing up my last comment

jmarshallnz
Owner

The style tag has always been case-sensitive. Having it so is fine IMO.

Jezz
Collaborator
JezzX commented June 01, 2012

yeah it was more of consistency between how its done in the rest of the files but probably not something we want to mess with this late in the game since its always been lower case in that 1 file and upper case in the rest of the uses :)

jmarshallnz jmarshallnz merged commit 0d2cd50 into from June 01, 2012
jmarshallnz jmarshallnz closed this June 01, 2012
babca

XBMC Frodo looks pretty ugly after this merge, the uppercase feature doesn't work well at least with French, Czech, Slovak, Hungarian...

http://imageshack.us/a/img834/8011/screenshot000m.png
http://imageshack.us/a/img585/6621/screenshot20120924at221.png
http://imageshack.us/a/img802/6621/screenshot20120924at221.png

I hope there is an easy fix for this :-)

Jezz
Collaborator

Its just the font and always was like it you need to go into Settings\appearance\skin\ and change the "- fonts" to either "arial" or "Default no caps"

HitcherUK

Is this platform dependant because it works on Windows but not openelec for me?

Windows - https://dl.dropbox.com/u/19745842/Images/screenshot000.jpg

OE - https://dl.dropbox.com/u/19745842/Images/screenshot001.jpg

babca

Apparently, it is. I'm using Raspberry Pi (OpenELEC ARM), OpenELEC @ i386, OS X and iPad, the same issue across devices. It handles accents fine only on Windows.

"Its just the font" - I don't understand, the default font does contain ÁÍÉĚŠČŘŽÝÁÍÉÚŮ characters... There is an issue in a function converting strings to caps.

If any fix is not planned, thank you for a workaround – "Default no caps" is better than nothing :-)

HitcherUK

@jmarshallnz Can you confirm platform dependency please?

Thanks.

jmarshallnz
Owner

While this commit here doesn't have anything to do with it, but 44c1ac4 does.

By the looks there is a difference with Linux (.UTF-8 is appended) but I don't know if that's the problem you're facing.

HitcherUK

@jmarshallnz just curious as to whether there will be a fix for Frodo as this is currently only works on Windows platforms, and Confluence uses it for the home screen so you might get reports about it.

Windows -

Windows

OpenELEC -

OpenELEC

jmarshallnz
Owner

I don't have an openelec system so can't really test it there. I dunno if the same thing applies on OSX or not - will try and test it later.

babca

Yes it applies to OS X too.

HitcherUK

@jmarshallnz friendly bump as I'd just like to know whether to revert back to using a separate caps only font set.

Thanks.

jmarshallnz
Owner

See #1887

HitcherUK

Thanks, missed that one.

ronie
Collaborator

same issue on linux btw.

HitcherUK

Another solution would be to use a caps only font for the home items but I'm not sure how easy that will be.

ronie
Collaborator

isn't that how confluence used to do it, before this change?
if i'm not mistaken it did include an all caps fontfile at one point.

no idea if it contained all charsets for all the languages though.

HitcherUK

Just checked Eden and you're correct but for Frodo the style of font has changed as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 3 unique commits by 1 author.

May 14, 2012
adds support for uppercase + lowercase in <style> tags of font.xml d76567e
May 15, 2012
remove FONT_STYLE_BOLD_ITALICS as not required 9a76d92
allow more than one style to be specified (space separated) in the <s…
…tyle> tag of fonts
3999675
This page is out of date. Refresh to see the latest.
2  xbmc/guilib/GUIFont.cpp
@@ -50,7 +50,7 @@ CGUIFont::CGUIFont(const CStdString& strFontName, uint32_t style, color_t textCo
50 50
 		   color_t shadowColor, float lineSpacing, float origHeight, CGUIFontTTFBase *font)
51 51
 {
52 52
   m_strFontName = strFontName;
53  
-  m_style = style & 3;
  53
+  m_style = style & FONT_STYLE_MASK;
54 54
   m_textColor = textColor;
55 55
   m_shadowColor = shadowColor;
56 56
   m_lineSpacing = lineSpacing;
4  xbmc/guilib/GUIFont.h
@@ -49,7 +49,9 @@ class CGUIFontTTFBase;
49 49
 #define FONT_STYLE_NORMAL       0
50 50
 #define FONT_STYLE_BOLD         1
51 51
 #define FONT_STYLE_ITALICS      2
52  
-#define FONT_STYLE_BOLD_ITALICS 3
  52
+#define FONT_STYLE_UPPERCASE    4
  53
+#define FONT_STYLE_LOWERCASE    8
  54
+#define FONT_STYLE_MASK       0xF
53 55
 
54 56
 class CScrollInfo
55 57
 {
25  xbmc/guilib/GUIFontManager.cpp
@@ -31,6 +31,7 @@
31 31
 #include "filesystem/SpecialProtocol.h"
32 32
 #include "utils/log.h"
33 33
 #include "utils/URIUtils.h"
  34
+#include "utils/StringUtils.h"
34 35
 #include "windowing/WindowingFactory.h"
35 36
 
36 37
 using namespace std;
@@ -429,16 +430,22 @@ void GUIFontManager::LoadFonts(const TiXmlNode* fontNode)
429 430
             if (iSize <= 0) iSize = 20;
430 431
 
431 432
             pNode = fontNode->FirstChild("style");
432  
-            if (pNode)
  433
+            if (pNode && pNode->FirstChild())
433 434
             {
434  
-              CStdString style = pNode->FirstChild()->Value();
435  
-              iStyle = FONT_STYLE_NORMAL;
436  
-              if (style == "bold")
437  
-                iStyle = FONT_STYLE_BOLD;
438  
-              else if (style == "italics")
439  
-                iStyle = FONT_STYLE_ITALICS;
440  
-              else if (style == "bolditalics")
441  
-                iStyle = FONT_STYLE_BOLD_ITALICS;
  435
+              vector<string> styles = StringUtils::Split(pNode->FirstChild()->ValueStr(), " ");
  436
+              for (vector<string>::iterator i = styles.begin(); i != styles.end(); ++i)
  437
+              {
  438
+                if (*i == "bold")
  439
+                  iStyle |= FONT_STYLE_BOLD;
  440
+                else if (*i == "italics")
  441
+                  iStyle |= FONT_STYLE_ITALICS;
  442
+                else if (*i == "bolditalics") // backward compatibility
  443
+                  iStyle |= (FONT_STYLE_BOLD | FONT_STYLE_ITALICS);
  444
+                else if (*i == "uppercase")
  445
+                  iStyle |= FONT_STYLE_UPPERCASE;
  446
+                else if (*i == "lowercase")
  447
+                  iStyle |= FONT_STYLE_LOWERCASE;
  448
+              }
442 449
             }
443 450
 
444 451
             XMLUtils::GetFloat(fontNode, "linespacing", lineSpacing);
2  xbmc/guilib/GUITextLayout.cpp
@@ -332,8 +332,6 @@ void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, v
332 332
   // these aren't independent, but that's probably not too much of an issue
333 333
   // eg [UPPERCASE]Glah[LOWERCASE]FReD[/LOWERCASE]Georeg[/UPPERCASE] will work (lower case >> upper case)
334 334
   // but [LOWERCASE]Glah[UPPERCASE]FReD[/UPPERCASE]Georeg[/LOWERCASE] won't
335  
-#define FONT_STYLE_UPPERCASE 4
336  
-#define FONT_STYLE_LOWERCASE 8
337 335
 
338 336
   int startPos = 0;
339 337
   size_t pos = text.Find(L'[');
2  xbmc/settings/GUISettings.cpp
@@ -752,7 +752,7 @@ void CGUISettings::Initialize()
752 752
   fontStyles.insert(make_pair(738, FONT_STYLE_NORMAL));
753 753
   fontStyles.insert(make_pair(739, FONT_STYLE_BOLD));
754 754
   fontStyles.insert(make_pair(740, FONT_STYLE_ITALICS));
755  
-  fontStyles.insert(make_pair(741, FONT_STYLE_BOLD_ITALICS));
  755
+  fontStyles.insert(make_pair(741, FONT_STYLE_BOLD | FONT_STYLE_ITALICS));
756 756
 
757 757
   AddInt(sub, "subtitles.style", 736, FONT_STYLE_BOLD, fontStyles, SPIN_CONTROL_TEXT);
758 758
   AddInt(sub, "subtitles.color", 737, SUBTITLE_COLOR_START + 1, SUBTITLE_COLOR_START, 1, SUBTITLE_COLOR_END, SPIN_CONTROL_TEXT);
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.