Points and Pixels

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Points and Pixels

Post by RossG » Tue May 10, 2016 7:32 pm

I've long been intrigued as to why the default height
for buttons and labels is 21. Can anyone explain?
I assume that's pixels. I have reset it to 20 - a
nice round number.

An even number would seem more convenient.

This leads to the real question: If I use a 12-point
font with the eight pixel default margin
the text isn't central between top and bottom.

When I change the margin to 7 this is fixed.

From the internet (where else?) I see that a
12-point fond is 16 pixels.

If 16 + 7 is still 23 this doesn't seem to add up.

Another question: While the Inspector only
shows one number for margins in the Text
settings window the code to set margins requires
four parameters for top, bottom, left and right.

Does the one setting allowed under "Text" apply
to all four parameters?

Is there anywhere to set the other three?

What's the right code to set them in a stack?
All my attempts are given the raspberry by
the debugger.

Update: Seems that the default margin setting of 8
positions the text centrally - but only if the font name
and size are in the Inspector fields.
Last edited by RossG on Tue May 10, 2016 8:13 pm, edited 1 time in total.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Points and Pixels

Post by FourthWorld » Tue May 10, 2016 8:12 pm

RossG wrote:I've long been intrigued as to why the default height
for buttons and labels is 21. Can anyone explain?
I assume that's pixels.
On Mac and Windows that conforms to the Human Interface Guidelines. Of course with seven platforms no single size will serve all needs, and the rect of any control is adjustable in script if needed.
This leads to the real question: If I use a 12-point
font with the eight pixel default margin
the text isn't central between top and bottom.
Which version of LiveCode are you using, and on which OS version? In v8 the font metrics have been greatly improved, but there are a surprisingly wide range of nuances in each OS that can make it difficult for the engine to adjust text baselines optimally. The margins property can help with that, as you've found.
From the internet (where else?) I see that a
12-point fond is 16 pixels.
Depends on the system doing the rendering. Are you referring to web metrics? LC uses Google's Skia rendering subsystem, which on the desktop provides more of less 1:1 for pt:px, except for "retina" displays where it's 1:2, and on mobile uses device-specific metrics. Web metrics tend to be very different, defining points in ways that conform to the W3C specs and which often differ from the specs provided by OS vendors.
Another question: While the Inspector only
shows one number for margins in the Text
settings window the code to set margins requires
four parameters for top, bottom, left and right.
As described in the Dictionary entry for the margin property, that value can be a single number, or it can be four comma-delimited items. When a single number is provided that value is used for all four sides. When a comma-delimited list is provided each item sets the margin for a given edge, in L,T,R,B order. The field provided should be wide enough to accept both forms.

FWIW, you can also set margin edges individually using the leftMargin, topMargin, rightMargin, and bottomMargin properties.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: Points and Pixels

Post by RossG » Wed May 11, 2016 12:22 pm

Thanks for the detailed and interesting reply.

I also uncheck the "Fixed Line Size" which helps.

Win XP as usual, and for ever if Bill allows.
Rev/LC versions since around 2.8.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

Post Reply