ChristineKrizsa / streambaby

Automatically exported from code.google.com/p/streambaby
0 stars 0 forks source link

Captions - tags not working i.e. <i></i> #70

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Watch a program with captions in an SRT file
2. Have captions on
3.

What is the expected output? What do you see instead?
Should see italics, bold, colors.  Instead the text and tags are displayed 
(i.e. Back on <i>Odyssey</i>...)

What version of the product are you using? On what operating system?
Streambaby 0.29 on Ubuntu 10.04

Please provide any additional information below.
Searched wiki and issues - could not find any mention of this

Original issue reported on code.google.com by dr...@comcast.net on 23 Apr 2011 at 2:49

GoogleCodeExporter commented 8 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

GoogleCodeExporter commented 8 years ago
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: