ciack404
Visitor

Whitespace character

Hi,

I am trying to show a whitespace character in a custom keyboard, using the default fonts

...
fontInstance = createobject("rofontregistry")
useFont = fontInstance.GetDefaultFont()
...
roScreen.drawText("␣", someX, someY, useFont)


While this code works for symbols like @, %, :, ;... it doesn't for ␣

What is involved in order to show that symbol? Should I add it to a custom font or are there other (better) solutions?

Thanks.
Tags (1)
0 Kudos
4 REPLIES 4
belltown
Roku Guru

Re: Whitespace character

What character are you using? Have you tried the non-breaking space: http://www.fileformat.info/info/unicode/char/00a0/index.htm?
Tags (1)
0 Kudos
RokuMarkn
Visitor

Re: Whitespace character

It looks like you're using U+2423 (OPEN BOX). This character is not in the default font. So you can either use your own font which contains this character, or choose a different character which is in the default font, like _ (underscore).

--Mark
Tags (1)
0 Kudos
ciack404
Visitor

Re: Whitespace character

Thanks for the replies.

"RokuMarkn" wrote:
It looks like you're using U+2423 (OPEN BOX). This character is not in the default font. So you can either use your own font which contains this character, or choose a different character which is in the default font, like _ (underscore).

--Mark


I added the character to a custom font, but I still can't see it displayed using .drawText(. How should I reference the new character in my code? Is there an example I can follow? I searched but can't find anything.

I tried:

roScreen.drawText("␣", someX, someY, useFont)


ba = CreateObject("roByteArray")
ba.FromHexString("e290a3")
renderedText = ba.ToAsciiString()
roScreen.drawText(renderedText, someX, someY, useFont)


renderedText = Chr(&H2423)
roScreen.drawText(renderedText, someX, someY, useFont)

but I still can't see anything.
I'm using this font: http://www.fontex.org/download/inconsolata.otf (according to this website it has the open box character http://www.fileformat.info/info/unicode ... upport.htm)
Tags (1)
0 Kudos
ciack404
Visitor

Re: Whitespace character

Ok solved.

I was using GetFont() in a wrong way.

Thanks for the help.
Tags (1)
0 Kudos
Community is Temporarily in Read-Only Mode!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

Thanks for your patience — we’re excited to share what’s next!