Hi.
i discovered that some fonts (well not some, a lot of them) display different from Android and IOS.
Same code, same font, different output alignments.
i’ve made a simple code to test this:
--------------------------- version 1 -- no text height defined -- no text width defined -- rect anchorY=0.5 -- text anchorY=0.5 local font=nil -- change this to test fonts ---------------- local rect=display.newRect(100,100,150,30) rect:setFillColor(0.5,0.5,0.5) local params={ text="HELLO WORLD!", fontSize=18, x=100, y=100, font=font } local text=display.newText(params) --------------------------- version 2 -- no text height defined -- no text width defined -- rect alignY=0 -- text alignY=0 ---------------- local rect=display.newRect(100,150,150,30) rect:setFillColor(0.5,0.5,0.5) rect.anchorY=0 local params={ text="HELLO WORLD!", fontSize=18, x=100, y=150, font=font } local text=display.newText(params) text.anchorY=0 --------------------------- version 3 -- text height = 30 -- text width =100 -- rect alignY=0 -- text alignY=0 ---------------- local rect=display.newRect(100,200,150,30) rect:setFillColor(0.5,0.5,0.5) rect.anchorY=0 local params={ text="HELLO WORLD!", fontSize=18, x=100, y=200, width=150, height=30, font=font } local text=display.newText(params) text.anchorY=0 --------------------------- version 4 -- text height = 30 -- text width =100 -- rect alignY=0 -- text alignY=0.5 ---------------- local rect=display.newRect(100,250,150,30) rect:setFillColor(0.5,0.5,0.5) rect.anchorY=0 local params={ text="HELLO WORLD!", fontSize=18, x=100, y=250, width=150, height=30, font=font } local text=display.newText(params) text.anchorY=0.5 --------------------------- version 5 -- no text height -- no text width -- rect alignY=0 -- text alignY=0.5 ---------------- local rect=display.newRect(100,300,150,30) rect:setFillColor(0.5,0.5,0.5) rect.anchorY=0 local params={ text="HELLO WORLD!", fontSize=18, x=100, y=300, font=font } local text=display.newText(params) text.anchorY=0.5 --------------------------- version 6 -- text height = 30 -- text width = 150 -- rect alignY=0 -- text alignY=0 ---------------- local rect=display.newRect(100,350,150,30) rect:setFillColor(0.5,0.5,0.5) rect.anchorY=0 local params={ text="HELLO WORLD!", fontSize=18, x=100, y=350, width=150, height=30, font=font } local text=display.newText(params) text.anchorY=0
if you change the line “local font=nil” to any font you have in your resource directory to test. you will encounter different outputs on Mac/IOS Vs Windows/Android.
this is a known issue? i know that with default fonts it works on both like it should. i don’t know why it doesn’t work on all fonts like it should (i’m asking to much?). any logic explanation for this to happen?
the only thing that i change is width, height, and anchorY.