Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
adrianc1982
Visitor

displaying Fast Forward character ►►

hey guys i want to print a text on screen that tells the user that the fast forward will do a fast scroll in my custom GUI

i read that unicode will not work, but i have the hex code too

so i tried:

myString = HexToAscii("►") doesnt work
myString = str(HexToAscii("►")) doesnt work

any ideas how to get this ►► to string?

just to add to the post hex value is:
◄ ◄
► ►

if any of you want more information about these characters you can even get the decimal value here:

http://la.remifa.so/unicode/unicode.php ... 0&end=25FF

Thanks!
0 Kudos
11 REPLIES 11
belltown
Roku Guru

Re: displaying Fast Forward character ►►

1. Make sure your font supports the characters you're trying to display.
2. Use the UTF-8 representation for the desired characters. Your example uses UTF-16, which is not supported by Roku.

The UTF-8 value for a Black Right-Pointing Pointer is e296ba, see http://www.fileformat.info/info/unicode/char/25ba/index.htm

For example:


Sub Main ()
port = CreateObject ("roMessagePort")
ui = CreateObject ("roScreen")
ui.SetPort (port)
ui.Clear (&h00)
ba = CreateObject ("roByteArray")
ba.FromHexString ("E296BA")
rightPointer = ba.ToAsciiString ()
fr = CreateObject ("roFontRegistry")
fr.Register ("pkg:/fonts/Font.ttf")
font = fr.GetFont ("Liberation Sans", 30, False, False)
ui.DrawText (rightPointer, 200, 200, &h00ff00ff, font)
ui.Finish ()
Wait (0, port)
End Sub
0 Kudos
RokuMarkn
Visitor

Re: displaying Fast Forward character ►►

You can also pass Unicode values to the Chr function which will return UTF-8:

rightPointer = Chr(&h25BA)


--Mark
0 Kudos
adrianc1982
Visitor

Re: displaying Fast Forward character ►►

"RokuMarkn" wrote:
You can also pass Unicode values to the Chr function which will return UTF-8:

rightPointer = Chr(&h25BA)


--Mark


thanks i will now have to look for a font to display the character on screen 🙂
0 Kudos
adrianc1982
Visitor

Re: displaying Fast Forward character ►►

"belltown" wrote:
1. Make sure your font supports the characters you're trying to display.
2. Use the UTF-8 representation for the desired characters. Your example uses UTF-16, which is not supported by Roku.

The UTF-8 value for a Black Right-Pointing Pointer is e296ba, see http://www.fileformat.info/info/unicode/char/25ba/index.htm

For example:


Sub Main ()
port = CreateObject ("roMessagePort")
ui = CreateObject ("roScreen")
ui.SetPort (port)
ui.Clear (&h00)
ba = CreateObject ("roByteArray")
ba.FromHexString ("E296BA")
rightPointer = ba.ToAsciiString ()
fr = CreateObject ("roFontRegistry")
fr.Register ("pkg:/fonts/Font.ttf")
font = fr.GetFont ("Liberation Sans", 30, False, False)
ui.DrawText (rightPointer, 200, 200, &h00ff00ff, font)
ui.Finish ()
Wait (0, port)
End Sub


could you rewrite the exampel with a roImageCanvas, please? 🙂
0 Kudos
belltown
Roku Guru

Re: displaying Fast Forward character ►►

Sub Main ()
port = CreateObject ("roMessagePort")
ui = CreateObject ("roImageCanvas")
ui.SetMessagePort (port)
rightPointer = Chr (&h25BA) ' Using RokuMarkn's suggestion
fr = CreateObject ("roFontRegistry")
fr.Register ("pkg:/fonts/LiberationSans-Regular.ttf") ' Obtained from http://www.dafont.com/liberation-sans.font
fontObject = fr.GetFont ("Liberation Sans", 30, False, False)
fontString = fr.Get ("Liberation Sans", 30, False, False)
ui.SetLayer (0, {Color: "#FF000000", CompositionMode: "Source"})
ui.SetLayer (1, [
{
Text: rightPointer,
TextAttrs: { Color: "#FF00FF00",
Font: fontString,
HAlign: "HCenter",
VAlign: "VCenter" },
TargetRect: { X: 200,
Y: 200,
W: fontObject.GetOneLineWidth (rightPointer, ui.GetCanvasRect ().W) - 200,
H: fontObject.GetOneLineHeight () }
}
])
ui.Show ()
Wait (0, port)
End Sub
0 Kudos
adrianc1982
Visitor

Re: displaying Fast Forward character ►►

thank you a lot ill give it a go tomorrow 🙂
0 Kudos
adrianc1982
Visitor

Re: displaying Fast Forward character ►►

didnt work for me..

i want to display a text that says something like fast scrolling in the footer so i made a function that i could turn on or off acording to the situation heres what i did...

Function drawFooter(statement as Boolean) as Void
footerItems = []
canvas = getCanvas()
canvasLayerToChange = 6
rightPointer = Chr (&h25BA)

fr = CreateObject ("roFontRegistry")
fr.Register ("pkg:/fonts/Font.ttf") ' I renamed the file for the font i got from the web page you linked...
fontObject = fr.GetFont ("Liberation Sans", 30, False, False)
fontString = fr.Get ("Liberation Sans", 30, False, False)

if statement = True
footerItems.Push({
Text: "Right Pointer:"+rightPointer
TextAttrs: { Color: "#FF00FF00",
Font: fontString,
HAlign: "HCenter",
VAlign: "VCenter" }
TargetRect:{x:15,y:200,w:500,h:50}
})

canvas.SetLayer(canvasLayerToChange, footerItems)
canvas.Show()
end if
End Function


The text Right Pointer: shows but not the right arrow..
No errors where found while debugging, which raises the question does the font actually has the right arrow?
Edit: yes it has the character:
http://www.fontspace.com/red-hat-inc/li ... 04.charmap
still not showing on screen..
font not loaded properly?

P.S. the position thats set right now is just to test..
0 Kudos
adrianc1982
Visitor

Re: displaying Fast Forward character ►►

Ran both examples you wrote roScreen and roImageCanvas

roScreen displays the arrow correctly
roImageCanvas gives out this error:

------ Running ------
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Current Function:
012: {
013: Text: rightPointer,
014: TextAttrs: { Color: "#FF00FF00",
015: Font: fontString,
016: HAlign: "HCenter",
017: VAlign: "VCenter" },
018: TargetRect: { X: 200,
019: Y: 200,
020:* W: fontObject.GetOneLineWidth (rightPointer, ui.GetCanvasRect ().W) - 200,
021: H: fontObject.GetOneLineHeight () }
022: }
023: ])
024: ui.Show ()
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in pkg:/source/Kids.brs(20)
020: W: fontObject.GetOneLineWidth (rightPointer, ui.GetCanvasRect ().W) - 200,
Backtrace:
#1 Function kidsmain() As Void
file/line: pkg:/source/Kids.brs(20)
#0 Function main() As Void
file/line: pkg:/source/appMain.brs(72)
Local Variables:
global rotINTERFACE:ifGlobal
m roAssociativeArray refcnt=3 count:29
port bsc:roMessagePort refcnt=2
ui bsc:roImageCanvas refcnt=2
rightpointer roString (2.1 was String) refcnt=2 val:" º"
fr bsc:roFontRegistry refcnt=1
fontobject Invalid
fontstring roString (2.1 was String) refcnt=2 val:"Liberation Sans,30,-1,5,1,0,0,0,0,0"
BrightScript Debugger>


Error seems related to the fontObject, I replaced that with w: 500 and h: 500(just to test)
Test ran fine, arrow is showing, ill fiddle with my code see wheres my error. Thanks!
0 Kudos
belltown
Roku Guru

Re: displaying Fast Forward character ►►

In my roScreen example, I had the font file in Font.ttf, a file I copied from one of my other projects.

In the roImageCanvas example, just to make sure I could give you the exact font I was using, I downloaded it again from dafont.com, and used the file name it had there, LiberationSans-Regular.ttf.

The latter example is probably not working for you if your font file is still Font.ttf. Just change the filename in the example code to Font.ttf and your fontObject should be set up correctly.
0 Kudos