Displaying Unicode text [Solved]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
SirDust
Prole
Posts: 15
Joined: Sat Feb 11, 2017 12:53 am

Displaying Unicode text [Solved]

Post by SirDust »

Hello all,
I have a simple question, why is it when I run the following piece of code in main.lua, the japanese text in the .txt file does not display properly (the text is displayed as boxes) and how do I fix this?

Code: Select all

love.graphics.setFont(love.graphics.newFont'NotoMono.ttf')
local text = love.filesystem.read'japanese.txt'

function love.draw()
	love.graphics.print(text,0,0)
end
I am using Google's NotoMono font, which does support japanese text.

As you can guess, my larger question is how to display in the love window any string of Unicode text that a font supports.
Last edited by SirDust on Tue Sep 05, 2017 7:52 am, edited 1 time in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Displaying Unicode text

Post by raidho36 »

You need a font that contains relevant characters. Either your font doesn't have kana or kanji characters or your text isn't japanese (and your font is missing those characters anyway).

I've lifted a random kanji font from the internet and tested it with a phrase in japanese i lifted from the same page, and it worked.

Code: Select all

function love.load ( )
	love.graphics.setFont ( love.graphics.newFont ( "senobi.ttf" ) )
end

function love.draw ( )
	love.graphics.print ( "このフォントの使用に関してはすべて無保証とさせていただきます", 10, 10 )
end
Attachments
Screenshot from 2017-09-05 10-04-22.png
Screenshot from 2017-09-05 10-04-22.png (8.4 KiB) Viewed 3267 times
User avatar
SirDust
Prole
Posts: 15
Joined: Sat Feb 11, 2017 12:53 am

Re: Displaying Unicode text

Post by SirDust »

Whoops, I didn't realize that the version of the font I was using didn't support Japanese text, now that I found the Japanese version, it's working fine now. Thanks.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests