LOVE offers 'printf' and 'font:getWrap' for word wrapping, and it works great on Latin alphabets. However, it does not breaks line between east asian letter.
* For Chinese and Japanese (and perhaps some other languages), you often have to indicate where line break may 'naturally' happen between specific letters when it is needed (e.g. between words).
* For Korean, it is much more common practice to allow line-breaking between every Hangul letter(it is also default setting of web browsers and most commercial programs, but not on LOVE).
For both cases, zero-width space should be simple solution for proper formatting. However, this doesn't work as expected : it occupies same width as normal space letter, and does not allow line breaking. To say, it works as if it's another letter or non-breaking space.
Maybe for Korean, something like this can be possible :
Code: Select all
font, limit = love.graphics.setNewFont("font.ttf"), 300
text = "AAAA AAA AAAA A AAAAA AAAA" -- consider A's as Korean Hangul letters.
lines = []
while #text > 0 do
_, wt = font:getWrap(text, limit)
line = wt[1] -- shortest possible line
while #line < #text do
line2 = line .. utf8_next_letter(text, #line)
if font:getWidth(line2) < limit then
line = line2
else -- we can not add more letter in this line.
lines[#lines+1] = line2
text = text:sub(#line2+1)
end
end
return lines = [] -- wrapped texts.
Is there any workaround to problems above?