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
rightPointer = Chr(&h25BA)
"RokuMarkn" wrote:
You can also pass Unicode values to the Chr function which will return UTF-8:
rightPointer = Chr(&h25BA)
--Mark
"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
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
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
------ 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>