Why can't I vertically center my text over a rectangle...

Ok. Lets put aside text for a second. I tried the following which if you read the code is expected to give me the same rectangle and draw a simple line right in the middle of it. The line is also drawn off-center as my text was earlier on. Am I making a mistake in my code? I don’t think so but just in case I’m missing something here… See attached image for result of the code. 

local widget = require( "widget" ) local titleBarHeight = 100 local splitLeftWidth = 400 local titleBarStrokeWidth = 2 local titleBarFillColor = {247/255, 247/255, 247/255} local titleBarStrokeColor = {192/255, 192/255, 196/255} local titleBarLeftLabel = "Settings" local titleBarLeft = display.newRect(0, 0, splitLeftWidth, titleBarHeight) titleBarLeft.anchorX, titleBarLeft.anchorY = 0, 0 titleBarLeft.strokeWidth = titleBarStrokeWidth titleBarLeft:setFillColor(unpack(titleBarFillColor)) titleBarLeft:setStrokeColor(unpack(titleBarStrokeColor)) local myLine = display.newLine(0, titleBarHeight / 2, splitLeftWidth, titleBarHeight / 2) myLine.anchorX, myLine.anchorY = 0.5, 0.5 myLine:setStrokeColor(0,0,0)

Isn’t it just the titlebar in the way?

Sorry. I don’t understand what you mean. Can you kindly reword? Thanks

Sorry I mean the status bar (with the battery status etc). Try: display.setStatusBar( display.HiddenStatusBar )

Ok. The statusBar height was throwing this off. Hiding it or moving the rectangle further down sorts this issue. Thanks for that catch.

The centering is almost done. The text is still just a little off but not that much. I will build this and put on IOS and Android to see how it behaves on real devices. Appreciate the support. 

Yeah it looks a lot better now :slight_smile: The offset might be fine depending on usage.

Built it and loaded it on 3 devices. I can certainly see the difference in text alignment between my iPad mini, iPhone 4 and Android 2.2 phone. I think I can live with it for now but it is an embarrassment for Corona Labs if this simple centering / placement issue is not fixed in the long run. Thanks for all your support. 

Kerem, I know that you’re eager to blame us for everything even before you check your own code (the status bar height, for example), but please don’t make a very complex issue like text rendering seem like it’s just some “simple fix”. Text rendering is a ferocious beast and always has been, as far back as I’ve been using Corona. It’s not just a Corona thing either, and it varies from platform to platform, OS to OS. If this would have been an “easy fix” as you imply, we would have done so long before now.

Thanks to @jonjonsson for creating some custom methods to help alleviate this issue somewhat.

Brent

Them fighting words… You might notice the following in my original post if you review it again “Can anyone kindly point out my error to me?”. I fully assumed I was doing something wrong leading to the rate of off-center printing of text I was seeing.

I have no idea why you think I am eager to blame Corona Labs for everything. I am one of your biggest champions. I want nothing but success for Corona SDK as it will lead to our success. I just happen to have a different opinion at times on what success may look like for Corona Labs though and that I will not deny. 

Thanks for your post though. Happy Holidays to you and your family.