Hi all,
I use a custom font “Chalkduster.ttf” to make a text with mulitline function.
When I get the height or contentHeight in android device, the height is not correct.
I tested for other font, it can display the similar height in android device.
Does anyone have ideas on how can I use this font to get the correct height ?
local textFont = "Chalkduster" local textSize = 33 local posX = 100 local posY = 100 local offsetX = 100 local textWidth = 200 local stringData = { "single", "the height is larger in the android device" } for i=1, #stringData do local x = posX + textWidth \* (i - 1) + offsetX \* (i - 1) local y = posY local test = display.newText( stringData[i], x, y, textWidth, 0, textFont, textSize ) test.anchorX = 0 test.anchorY = 0 local width = test.contentWidth local height = test.contentHeight local resultString = "W: " .. width .. " H: " .. height local resultText = display.newText( resultString, x, y-50, textFont, textSize ) resultText.anchorX = 0 resultText.anchorY = 0 if ( i == 1 ) then resultText:setFillColor(1, 0, 0, 1) else resultText:setFillColor(0, 1, 1, 1) end local resultArea = display.newRect ( x, y, width, height ) resultArea.anchorX = 0 resultArea.anchorY = 0 resultArea.alpha = 0.5 if ( i == 1 ) then resultArea:setFillColor(1, 0, 0, 1) else resultArea:setFillColor(0, 1, 1, 1) end end
Attached with the captured image by simulator and android tablet device.
The link of the font: (Chalkduster.ttf)
http://www.sendspace.com/file/1pm2za
Thank for thanks.
Sam