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!

  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

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


rightPointer = Chr(&h25BA)

–Mark

“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 :slightly_smiling_face:

“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? :slightly_smiling_face:

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

thank you a lot ill give it a go tomorrow :slightly_smiling_face:

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..

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!

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.

i fixed it during the AM, just couldnt get back to post it.

i was loading the font inside a function and the scope of the function was messing around with the canvas, the font has to be loaded in the same scope as the canvas for it to work.

So i load the font in the same scope as the canvas and then i set it as a global object and access it through the scope of my new function :slightly_smiling_face:

all is good and working, thanks very much, the only downside to using the font is the size of the font file its over 100kb thats a lot for the small space we are allowed to use in our proyects :disappointed_face:

But still my proyect is in line with the size of roku apps..

“adrianc1982” wrote:
i fixed it during the AM, just couldnt get back to post it.

… the only downside to using the font is the size of the font file its over 100kb thats a lot for the small space we are allowed to use in our projects :disappointed_face:
I’m glad you got it working.

Note that it’s the compressed size of the font file that matters, as far as how much space we are allowed to use is concerned. When I downloaded the Liberation Sans font, the uncompressed size was 131KB, but only 84KB after compressing with 7-Zip. That’s not too bad for a decent font with lots of special characters. If it’s an issue, there are font editors you can use to remove the characters you’re not interested in to save space, although it’s not something I’ve needed to do so far, and I’ve even used that font with channels that were developed to work with the (now deprecated) legacy Roku firmware that only has a limit of around 750KB for channel packages.