Open GoogleCodeExporter opened 9 years ago
I wrote some code to fix this (untested). I'll test tonight and update this
comment. Hopefully Keary can incorporate this into the project. This only
supports the <i> and tags. <u> and <font color=""> are not implemented as part
of this.
// package com.unwiredappeal.tivo.config.StreamBabyConfig
public static ConfigEntry cfgCCStyledText = new ConfigEntry("cc.text.styled",
"false", "Show bold and italic text in CC");
// pacakge com.unwiredappeal.tivo.views.TivoCharacters
// Only supports tags spanning entire line
public int getFontStyle(String str) {
int style = BView.FONT_PLAIN;
boolean italic = false;
boolean bold = false;
int stop = false;
while (!stop) {
if (str.matches("^<[Ii]>.*</[Ii]>$")) {
italic = true;
str = str.replaceAll("^<[Ii]>(.*)</[Ii]>$", "$1");
continue;
}
if (str.matches("^<[Bb]>.*</[Bb]>$")) {
bold = true
str = str.replaceAll("^<[Bb]>(.*)</[Bb]>$", "$1");
continue;
}
stop = true;
}
if (italic) {
style = bold ? BView.FONT_BOLDITALIC : BView.FONT_ITALIC;
} else if (bold) {
style = BView.FONT_BOLD;
}
return style;
}
// package com.unwiredappeal.tivo.views.bgtext
// before
value = tc.stripInvalidChars(value);
h = (int)(fm.getHeight()+0.99)+1;
// after
value = tc.stripInvalidChars(value);
if (StreamBabyConfig.cfgCCStyledText.getBool()) {
int style = tc.getFontStyle(value);
font.setStyle(style);
}
h = (int)(fm.getHeight()+0.99)+1;
Original comment by br...@bricemciver.com
on 26 Apr 2012 at 4:47
Ok, I've got a working patch to the code. This only supports the <i> and tags.
<u> and <font color=""> are not implemented as part of this.
The other oddity is that even if the tags don't enclose the entire line, the
style will still persist. Example:
This text is <i>italic</i>.
would be interpreted as
<i>This text is italic.</i>
The configuration setting to enable this is "cc.textstyled", default value is
false, true to enable.
Original comment by br...@bricemciver.com
on 28 Apr 2012 at 7:29
Attachments:
Original issue reported on code.google.com by
dr...@comcast.net
on 23 Apr 2011 at 2:49