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!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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 |
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
@Scott
This is an available font on the iPhone. It is used by Apple for the build in notes taking application for example :)
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!
@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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | -- 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 |
@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. :-)
We do have a case opened on it, but haven't gotten to actually fix it yet.
@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 :(
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.
> 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.
Ah ok... we use trac for our projects .. but more because I like a bit(e) of python for lunch :)
Something else but a bit related... would it be better... performance wise to have all little images instead of the newText() objects?
@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
@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.
1 | labelText.y = top + labelText.stageHeight * 0.5 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ---- 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 |
@fogview
Hehe :) yeah... funny thing is that my project currently has no icon :-P
Another very easy way is something like this:
1 2 3 4 5 6 | // first line! if system.getTimer() > 10 then // device else // simulator end |
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?
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
Sex Invaders completed! For Android 2.2 or higher, w/ Facebook highscores!
Importing modules. How you do this?
My wish list (keyboard jumping, move to other view, etc)
Looking for a Good .lua programmer
How do you close a WebPopup without the Back Button
Changing an objects image during runtime
Fog not working
Corona in the high school classroom
minimum iOS version of 4.3 to work?