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: 
TheEndless
Channel Surfer

Re: Russian (Cyrillic) letters

"EnTerr" wrote:
Which pretty much is "include Cyrillic code points in the system font", easy-peasy.

May be a bit more involved than that. If the font(s) they currently license don't support Cyrillic characters, then it could potentially cause a real pain UI-wise. I'm pretty sure the 2D APIs support Cyrillic characters already, but the built-in font for the 2D APIs is different than the one used for the SDK screens.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
YoJae
Visitor

Re: Russian (Cyrillic) letters

Hi guys,

Could someone give me an example how to use Cyrillic (or different language) on roImageCanvas?
Here is what I have tried and it didn't work:


textUtl=createObject("roUrlTransfer")
textUtl.SetUrl("http:// -this brings me an xml with body containing cyrillic- ")
textUtl.GetToFile("tmp:/text.xml")

xml= CreateObject("roXMLElement")
xml.Parse(ReadAsciiFile("tmp:/text.xml"))
text=xml.GetNamedElements("body").getText()

fontReg = CreateObject("roFontRegistry")
fontReg.Register("pkg:/fonts/OpenSans.ttf")
font = fontReg.Get("OpenSans",20,40,false)

Textbox = {TargetRect:{x:int((width/2)-(boxW/2)),y:130,w:boxW,h:boxH}, text:text, TextAttrs:{Font:font, HAlign:"Justify", VAlign:"Top" }}
canvas.SetLayer(2, textBox)


The text prints on the console as various symbols
BrightScript Debugger> ? xml.GetNamedElements("body").getText()
’ ¶ µ ´ ° ² ½ ¾ ² – ´ ¾ ¼ ¾, ‰ ¾ ‡ ¸ ‚ ° ± µ » Œ ½ � ² ¸ º ¾ € ¸ � ‚ ° ½ ½ � Lorem Ipsum ¿ ¾ » � ³ ° ” µ º � ‚." ¦ µ € ¾ ± ¸ ‚


I have also tried Webdings font (which is all icons) and it displays as squares.

Any ideas why its not working?

Thanks,
Gary
0 Kudos
belltown
Roku Guru

Re: Russian (Cyrillic) letters

I was never able to get Cyrillic fonts working with roImageCanvas. However, roScreen does seem to handle them.

Make sure that the font you use includes the Cyrillic character set.

Note that the console does not support custom fonts, so you cannot use Print statements to check whether your Cyrillic characters will be rendered correctly. You'll have to display them using a BrightScript component, e.g. roScreen.

Also, make sure you check ifXmlElement.Parse () returns True.

For example:


<?xml version="1.0" encoding="utf-8"?>
<корень>
<элемент>Привет мир!</элемент>
</корень>


Sub Main ()
ui = CreateObject ("roScreen")
ui.SetPort (CreateObject ("roMessagePort"))
xml = CreateObject ("roXmlElement")
If Not xml.Parse (ReadAsciiFile ("pkg:/xml/test.xml")) Then Print "Parse Fail" : Return
hello = xml.GetNamedElements ("элемент")[0].GetText ()
fr = CreateObject ("roFontRegistry")
fr.Register ("pkg:/fonts/OpenSans-Regular.ttf")
font = fr.GetFont ("Open Sans", 72, False, False)
fw = font.GetOneLineWidth (hello, ui.GetWidth ())
fh = font.GetOneLineHeight ()
x% = (ui.GetWidth () - fw) / 2
y% = (ui.GetHeight () - fh) / 2
ui.DrawText (hello, x%, y%, &hebebebff, font)
ui.Finish ()
Wait (0, ui.GetMessagePort ())
End Sub
0 Kudos
YoJae
Visitor

Re: Russian (Cyrillic) letters

Gentlemen,

I figured this out. My mistake was in font usage.
1. The thing that is not in SDK, use font = fontReg.Get("Open Sans",20,40,false) instead of fontReg.GetFont() on roImageCanvas. On roScreen, use fontReg.GetFont()
2. Check font family names using ? fontReg.GetFamilies() to get the right thing.
3. You can get the UTF-8 string with simple text = urlTransfer.GetToString() - so for it can be stored and passed around as a String (to check, if the string contains unreadable glyphs on the console - should work)

Many thanks to belltown for the idea.
-Gary
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.