Text candy and non US chars (ÅÄÖ) = problem

Hi I just purchased Text candy
and when I test with vector fonts and ÅÄÖ I get
only “???” on windows and nothing on mac

the font have these chars

Is Text Candy working whit non US chars ?

[lua]local screenW = display.contentWidth
local screenH = display.contentHeight

– LOAD THE LIBRARY
TextCandy = require(“lib_text_candy”)

– LOAD & ADD A CHARSET
TextCandy.AddVectorFont (“Yard Sale”, “THISDONTWORKÅÄÖ!123”, 28)

– BACKGROUND IMAGE
–local BG = display.newImage (“background.png”)

– CREATE A TEXT OBJECT USING THIS CHARSET
local MyText = TextCandy.CreateText({
fontName = “Yard Sale”,
x = screenW*.5,
y = screenH*.5,
text = “THIS DONT WORK ÅÄÖ!123”,
originX = “CENTER”,
originY = “CENTER”,
textFlow = “CENTER”,
wrapWidth = 500,
charBaseLine = “CENTER”,
showOrigin = false,
})
MyText:addDropShadow(1,1,200)
MyText:setColor(255,0,255, 200)
MyText:applyDeform({
type = TextCandy.DEFORM_ZIGZAG,
toggleY = 1,
toggleAngle = 8,
toggleScale = 0,
minScale = 1.0
})

MyText:applyInOutTransition({
inDelay = 0,
inCharDelay = 20,
inMode = “RANDOM”,
AnimateFrom = { alpha = 0.0, time = 200, transition = easing.outExpo,x=1,y=1 },

hideCharsBefore = false,
hideCharsAfter = false,
startNow = true,
loop = false,
autoRemoveText = false,
restartOnChange = true
})
–This works
local foo2 = display.newText( “THIS WORK ÅÄÖ!123”, 152, screenH*.11, 200,300, “Yard Sale”,18)
foo2:setTextColor(0,0,0, 150)

local foo = display.newText( “THIS WORK ÅÄÖ!123”, 150, screenH*.1, 200,300, “Yard Sale”,18)
foo:setTextColor(255,0,255, 200)
foo2.y = foo.y+1
foo2.x = foo.x+1

[/lua]

[import]uid: 147488 topic_id: 27512 reply_id: 327512[/import]

an answer from x-pressive.com concerning Widget Candy for Corona perhaps help you, I have the same problem with french accented letters like éèàçù.

“this depends on the font you are using. Also try to save your .lua file in UTF-8 format.” [import]uid: 6666 topic_id: 27512 reply_id: 112633[/import]

Had same problem for polish letters (? ? ? ? ? ó ? ?). Solution? Uppercase letters in png file, uppercase letters for US chars and small letters for Polish chars.

[lua]TextCandy.AddVectorFont (“Yard Sale”, “THISDONTWORKabo!123”, 28)[/lua]

and

[lua]local MyText = TextCandy.CreateText({
fontName = “Yard Sale”,
x = screenW*.5,
y = screenH*.5,
text = “THIS DONT WORK abo!123”, [/lua]

“Ugly hack” but works fine for me :slight_smile:
Regards [import]uid: 12704 topic_id: 27512 reply_id: 112640[/import]

Hello

I can confirm that non us chars don’t work whit TextCandy.AddVectorFont

i fund the solution!
no thanks to the bad support from x-pressive.com (non existing)

The problem is whit the string.len and string.sub in the corona SDK count wrong on no US chars this results in non showing chars

to fix this replace the sub and len functions in TextCandy whit utf8.sub and utf8.len
and all is woking like a normal newText in corna
if the font dont support the char you will get a default font char
so all text is displayed

It is one more problem in TextCandy.AddVectorFont
that it how the chars are positioned

this can also easy be fixed
by adding Temp.x = 0

Hope this helps some one

@x-pressive.com
If you sell a product online at least you can do is to answer support mail !!!

Here is the utf-8 functions (not mine found it here)
[lua]utf8 ={
charbytes = function (s, i)
– argument defaults
i = i or 1
local c = string.byte(s, i)
– determine bytes needed for character, based on RFC 3629
if c > 0 and c <= 127 then
– UTF8-1
return 1
elseif c >= 194 and c <= 223 then
– UTF8-2
local c2 = string.byte(s, i + 1)
return 2
elseif c >= 224 and c <= 239 then
– UTF8-3
local c2 = s:byte(i + 1)
local c3 = s:byte(i + 2)
return 3
elseif c >= 240 and c <= 244 then
– UTF8-4
local c2 = s:byte(i + 1)
local c3 = s:byte(i + 2)
local c4 = s:byte(i + 3)
return 4
end
end

– returns the number of characters in a UTF-8 string
,len = function (s)
if(s~=nil) then
local pos = 1
local bytes = string.len(s)
local lenX = 0
while pos <= bytes and lenX ~= chars do
local c = string.byte(s,pos)
lenX = lenX + 1

pos = pos + utf8.charbytes(s, pos)
end
if chars ~= nil then
return pos - 1
end

return lenX
end
return 0
end

– functions identically to string.sub except that i and j are UTF-8 characters
– instead of bytes
,sub = function(s, i, j)
j = j or -1

if i == nil then
return “”
end
local pos = 1
local bytes = string.len(s)
local len = 0
– only set l if i or j is negative
local l = (i >= 0 and j >= 0) or utf8.len(s)
local startChar = (i >= 0) and i or l + i + 1
local endChar = (j >= 0) and j or l + j + 1

– can’t have start before end!
if startChar > endChar then
return “”
end

– byte offsets to pass to string.sub
local startByte, endByte = 1, bytes

while pos <= bytes do
len = len + 1

if len == startChar then
startByte = pos
end

pos = pos + utf8.charbytes(s, pos)

if len == endChar then
endByte = pos - 1
break
end
end

return string.sub(s, startByte, endByte)
end

– replace UTF-8 characters based on a mapping table
,replace = function(s, mapping)
local pos = 1
local bytes = string.len(s)
local charbytes
local newstr = “”

while pos <= bytes do
charbytes = utf8.charbytes(s, pos)
local c = string.sub(s, pos, pos + charbytes - 1)
newstr = newstr … (mapping[c] or c)
pos = pos + charbytes
end

return newstr
end
}[/lua]

[import]uid: 147488 topic_id: 27512 reply_id: 112649[/import]