Huge problem with font positioning between simulator and device!

I have a very hard time right now as my whole application renders different on the device than on the emulator using “MarkerFelt-Thin” as font!

When I render in the Simulator I get very different placing than on the device!

To illustrate this try the following code and compare device with simulator output!

local rec1=display.newRect(50,90,200,3)  
rec1:setFillColor( 255,255,255 )  
  
local txt1=display.newText("Test\_\_\_\_", 50, 50, "MarkerFelt-Thin", 40 )  
txt1:setTextColor( 255,0,0 )  
  
local txt2=display.newText("Test\_\_\_\_", 50, 50, "Helvetica", 40 )  
txt2:setTextColor( 0,255,0 )  
  
local txt3=display.newText("Test\_\_\_\_", 50, 50, "Verdana", 40 )  
txt3:setTextColor( 0,0,255 )  
  
local rec2=display.newRect(50,220,200,3)  
rec2:setFillColor( 255,255,255 )  
  
local txt4=display.newText("Test\_\_\_\_", 50, 0, "MarkerFelt-Thin", 40 )  
txt4:setTextColor( 255,0,0 )  
txt4.y=200  
  
local txt5=display.newText("Test\_\_\_\_", 50, 0, "Helvetica", 40 )  
txt5:setTextColor( 0,255,0 )  
txt5.y=200  
  
local txt6=display.newText("Test\_\_\_\_", 50, 0, "Verdana", 40 )  
txt6:setTextColor( 0,0,255 )  
txt6.y=200  

Not only that I believe that the baseline of all those different texts need to go in exactly the same position.

That the placing differences for 1-3 and 4-6 is different even the same numbers are used in all cases.

But the most disturbing fact is how big the rendering differences between the simulator and the device are (and why nobody complains about this?)!

Any hint how I can fix this till it is fixed in the SDK (Beta 4 and Beta 5 give the same results for me) [import]uid: 6928 topic_id: 1192 reply_id: 301192[/import]

On the iPhone you don’t have the same fonts as you do on your desktop machine. I’ve never heard of markerfelt-thin before, so I’m just guessing here, but it’s probably not available on your iphone.

There’s a list of fonts in the docs, I believe. If not they’re on the forums here somewhere. Search usually turns up the list for me.

Scott [import]uid: 5659 topic_id: 1192 reply_id: 3197[/import]

@Scott

This is an available font on the iPhone. It is used by Apple for the build in notes taking application for example :slight_smile:

I am not complaining about different looking fonts anyway. I complain about different position of the rendered font in the display between simulator and iPhone. And if I see it right the font-rendering in the Simulator also has a different letter spacing for some fonts too.

I would suggest you try the sample code to see what I am talking about! [import]uid: 6928 topic_id: 1192 reply_id: 3199[/import]

@OderWat

I agree that this is a simulator problem. The baseline of the three fonts are offset on the simulator but look fine on my iPhone 3GS.

Your example code had a offset problem where it showed the bottom set of fonts at a different offset from the “rect” baseline. At first I thought this was an issue too. Here is my modified code. I also switched the order of the bottom fonts to see if the layering made any difference (it didn’t).

Tom

[code]
– Create a baseline Rect
local rec1=display.newRect(50,90,200,3)
rec1:setFillColor( 255,255,255 )

local txt1=display.newText(“Test____”, 50, 50, “MarkerFelt-Thin”, 40 )
txt1:setTextColor( 255,0,0 )

local txt2=display.newText(“Test____”, 50, 50, “Helvetica”, 40 )
txt2:setTextColor( 0,255,0 )

local txt3=display.newText(“Test____”, 50, 50, “Verdana”, 40 )
txt3:setTextColor( 0,0,255 )

– Create a baseline Rect
local rec2=display.newRect(50,220,200,3)
rec2:setFillColor( 255,255,255 )

– Reverse the display order
local txt6=display.newText(“Test____”, 50, 180, “Verdana”, 40 )
txt6:setTextColor( 0,0,255 )
–txt6.y=200

local txt5=display.newText(“Test____”, 50, 180, “Helvetica”, 40 )
txt5:setTextColor( 0,255,0 )
–txt5.y=200

local txt4=display.newText(“Test____”, 50, 180, “MarkerFelt-Thin”, 40 )
txt4:setTextColor( 255,0,0 )
–txt4.y=200

[/code] [import]uid: 6119 topic_id: 1192 reply_id: 3200[/import]

@Scott: It’s a device font. There is a nice free font displaying app called FONTS! It will show you all the fonts of the device, even with samples.

@OderWat: Been there, done that. And guess what… we have already complained about it. So you are not the first who discovered this. How you can fix it? Man that is a difficult question. Use a different positioning when you deploy to the device. Work around it till Ansca finds a way to fix it. Easy, isn’t it. :slight_smile: [import]uid: 5712 topic_id: 1192 reply_id: 3201[/import]

We do have a case opened on it, but haven’t gotten to actually fix it yet. [import]uid: 54 topic_id: 1192 reply_id: 3202[/import]

@Fogview: The second three test cases are meant as I wrote them. By setting the y value after creating the object with y=0 at create time… to illustrate the change in the reference point.

This is also what I use what I use in my code… .because this way I have easier positioning for my case which needs to place numbers on some kind of grid. Which is easier with the reference being the center of the object. The reference line itself was only roughly placed.

@MikeHart: Well… If we can fix it in our code… Ansca should be able to fix it to hopefully.

This needs to be fixed asap in my eyes! These are basics which should work as one expects. I spent hours today to find and universal fix :frowning:

I have about between 100-200 texts (mostly just one number per object) on the screen in different font-sizes and font-styles and I was going to implement the possibility of theming into the game which means that the font can be changed too.

Well I had conditional code for different fonts out of my prototype code (written on windows in python some months ago) because I experimented with fonts. So I create a little “onDevice” true/false and wrote some conditional code trying to keep the needed changes minimal.

Basically it seems as if I have to substract about 1/8 of the fontsize for the y position to have consistent positioning (roughly tested and by eye only)

The change of the reference point when using the newText(…,x,y,…) and manipulation of obj.x, obj.y after the object is created also seems a bit inconsistent to me?

BTW… is there a way to see the open cases!? I only get error pages when I access the bug-tracker which is listet in the sticky … and get permission denied errros for some links I got in emails for new opened cases. [import]uid: 6928 topic_id: 1192 reply_id: 3203[/import]

> is there a way to see the open cases!?

We’re working on that. Unfortunately the solution we chose doesn’t do everything we want, and we’re looking at transitioning to another system.
[import]uid: 54 topic_id: 1192 reply_id: 3204[/import]

@OderWat

I thought that might be the case with your second set of fonts but I didn’t notice much difference. I too had problems positioning text with newText and started using ui.newLabel instead.

I think the previous text rendering bug is #126.
http://developer.anscamobile.com/forum/2010/03/16/simulator-rendering-problems

Tom [import]uid: 6119 topic_id: 1192 reply_id: 3206[/import]

Ah ok… we use trac for our projects … but more because I like a bit(e) of python for lunch :slight_smile:

Something else but a bit related… would it be better… performance wise to have all little images instead of the newText() objects? [import]uid: 6928 topic_id: 1192 reply_id: 3205[/import]

@Fogview

ui library is to much overhead for this… After all I just want to place single Digits on the screen and it is just “Lua”.

It uses the type of positioning I showed in my second example together with using the stageHeight of the object.

labelText.y = top + labelText.stageHeight \* 0.5  

This does not solve the problem with different positioning between the device and the simulator. I did not notice those problems till I used the MarkerFelt-Thin font because Helvetica which I used before is not as far off as this font is.

The remaining “Lable” stuff is for horizontal placement and not related to the problem I describe here which is solely a problem of y position :frowning:

And don’t get me wrong guys… I can handle those problems… in fact my app looks pretty close on all targets. Besides of the difference in font spacing (which should be a case too).

I hoped for a solution like “set the center point to this or that to avoid the problems” but that just wont work…

Simplest solution is to define an device dependent offset like this

local onDevice=true  
if string.sub(system.pathForFile("hashdata.dat", system.ResourceDirectory),1,6)=='/Users' then  
 onDevice=false  
end  
  
local dnewText2=display.newText  
  
function dnewText(text,x,y,font,size)  
 if onDevice~=true then  
 y=y-(size\*0.128)  
 end  
 local t=dnewText2(text,x,y,font,size)  
 return t  
end  

Which only covers the top-left origin creation of objects but this is ok if you place them inside of groups anyway for placement.

But all of this could just go away if the simulator gets fixed in that respect! [import]uid: 6928 topic_id: 1192 reply_id: 3211[/import]

I like your onDevice detection code. I modified it a little to check for the Icon.png file which should be in every build.

Thanks,
Tom

[code]
---- Check if running on device or simulator ----
onDevice = false – assume running on simulator
local path = system.pathForFile(“Icon.png”, system.ResourceDirectory)
if path and string.sub(path,1,6) ~=’/Users’ then
– Found device if Icon.png found and not in /Users folder
onDevice = true
end
path = nil

if onDevice then
print(“Running onDevice …”)
else
print(“Running in Simulator …”)
end
[/code] [import]uid: 6119 topic_id: 1192 reply_id: 3216[/import]

@fogview

Hehe :slight_smile: yeah… funny thing is that my project currently has no icon :stuck_out_tongue:

Another very easy way is something like this:

// first line!  
if system.getTimer() \> 10 then  
 // device  
else  
 // simulator  
end  

which worked very well for me but is of course a bit risky … hehe

I hope this will be addressed by Ansca with the definition of a flag like system.device … which could return “iphone” “ipad” “simulator” … whatever dunno… [import]uid: 6928 topic_id: 1192 reply_id: 3218[/import]

Wow, I’m running into the same problem and it’s still not fixed. WTF?

Anyone figure out a good way of measuring the offset to fix the font position? [import]uid: 88628 topic_id: 1192 reply_id: 85871[/import]

Is this problem resolved yet? I still have similar issue… [import]uid: 153864 topic_id: 1192 reply_id: 125513[/import]

Is this problem resolved yet? I still have similar issue… [import]uid: 153864 topic_id: 1192 reply_id: 125513[/import]

When you fix this error? [import]uid: 138593 topic_id: 1192 reply_id: 145184[/import]

Sorry for the slight OT-ness, but what is wrong with:

_G.isSimulator = ( “simulator” == system.getInfo( “environment” ) )
[import]uid: 46639 topic_id: 1192 reply_id: 145201[/import]

When you fix this error? [import]uid: 138593 topic_id: 1192 reply_id: 145184[/import]

Sorry for the slight OT-ness, but what is wrong with:

_G.isSimulator = ( “simulator” == system.getInfo( “environment” ) )
[import]uid: 46639 topic_id: 1192 reply_id: 145201[/import]