Re: Standardize Font Appearance

2022-09-11 Thread Neville Smythe via use-livecode
I have enough datapoints to report some findings from my comparison of the 
appearance of fonts across platforms, in particular on the length of strings in 
fields and text baselines, and to correct some of my previous statements. My 
intention is to compile a database for some 7000+ fonts in 7 different font 
sizes ranging from 9pt to 18pt on Mac Windows and Linux system; but for now 
(for reasons given below) I looked at four basic fonts in common use: Arial, 
Times New Roman, Noto Sans and Noto Serif.

The good news is that the horrible problem of different strings lengths is no 
longer a problem, as long as your target platforms are just Mac or Windows 10. 
For each of these four fonts, strings in (right or left justified) fields have 
the same rendered length (they differ between fonts of course). I would be 
confident that holds for all TrueType fonts installed on these platforms, 
starting from the advent of Windows 10. My former claim about a difference 
between High Sierra and Monterey on the Mac is incorrect, the result of a 
coding error. Of course the field or stack must have a font assigned: leaving 
the font to empty will result in the system using its own font, which will be 
consistent with the look-and-feel of the platform/system version, but which 
will certainly be quite different between platforms.

On LInux (Ubuntu 18.x) however, string lengths for all the fonts in all sizes 
are quite different, sometimes longer and sometimes shorter than on the other 
platforms. The biggest difference was for Noto Sans 9pt, the sample Linux 
string being 14% longer; this was an outlier, mostly the Linux strings were 
less than 8% longer. In the other directions was Arial 15pt, where Linux was 5% 
shorter. So if Linux is a target platform, allow some extra length for your 
fields (on the right  for a left justified field, on the left for a right 
justified label).

A more difficult problem is the vertical placement of text. With the default 
settings for fields, strings in Windows will typically appear 2 or 3 pixels 
lower than on a Mac, which can mess with your layout — text carefully 
positioned on one platform will appear too close to nearby objects on the 
other, or will not align with text in adjacent fields. This can be fixed by 
adjusting the topMargin of the field, but the details are not straightforward..

The baseline for rendered strings is determined by the font metrics and the 
font size; unfortunately Mac Windows and Linux all use different metrics from 
each other. It would be nice if LC had a function which returned the baseline 
for the rendered string, but I couldn’t find such a function. The closest 
formula I can get is (for text using the textFont and textSize of the owner 
field, and consigning to oblivion the formula I had previously proposed which 
was caused by the aforementioned error plus a glitch in the data processing 
unit, ie my brain.)

 first baseline relative to the top of the field = the topMargin of the 
field + fontAscent - 6
 where
fontAscent = - (item 2 of measureText(fld ,fld ,”bounds”)

Why the magic number -6? It seems this places text in a common font such as 
Time New Roman or Arial in medium range textSizes such as 11 to 15 so that the 
top of the lower case character “x” is at ...approximately... the topMargin of 
the field. This would be the ideal placement for text at all fonts and sizes, 
but of course in general 6 is nothing like the difference between the 
fontAscent (the height of the capital “A” above the baseline) and the height of 
“x”, and anyway the fontAscent is not the actual height of the font, so for 
other sizes and fonts the placement is wildly different from the ideal. The 
simplification is probably a legacy of a decision originally made for speed 
given the complications of dealing with different font formats; a correction 
now would break all existing stacks.

Actually while my formula fits precisely most of the time, it occasionally is 
out by 1 pixel. And that precision holds for all fonts I have looked at, even 
for the gorgeously extravagant Zapfino at 64pt. So the discrepancy is probably 
some floating point rounding from the correct formula. If anyone (LC 
engineer’s?) can provide the correct formula that would be nice, but I have the 
feeling it may involve a font metric not directly exposed by the LC api.

The formula can be used to adjust the topMargin so that the baseline is fixed, 
to within 1 pixel anyway The adjustment would have to be done at runtime, or 
applied to a stack before building a standalone for a particular platform, 
using a pre-cooked fontAscent. Hence my database project. Just at the moment 
this has hit a bit of snag: as far as I can see, fonts have to be added to 
Windows 10 one at a time -- on a Mac you just dump a folder of fonts onto Font 
Book. Does anyone know how to do this in Windows and Linux? If necessary, 
following Ralph’s post I believe I could work out where the Mac and Windows 10 

Re: Sort Ascending DateTime - failure

2022-09-11 Thread Paul Hibbert via use-livecode
Should have waited to send this, on further investigation, I found the 
useSystemDate property, now all is well. Sorry for the noise!

> On 11Sep, 2022, at 8:29 PM, Paul Hibbert via use-livecode 
>  wrote:
> 
> While playing around with the PolyGrid, I wanted to try adding sorting 
> options by clicking the PolyGrid Header Labels. The solution I came up with 
> drove me nuts until I discovered that there appears to be an issue associated 
> with the sort command and dateTime.
> 
> According to the dictionary, text can be sorted by dateTime, and the entry 
> for dateTime states…
> 
> "The dateTime keyword recognizes all LiveCode's date and time formats and 
> sorts them in time order, rather than alphabetical or numeric order."
> 
> Date Formats:
> 
> the [{ long | abbreviated | short }] [{ english | system }] date
> 
> …So I was expecting to be able to sort the PolyGrid by the dates as entered, 
> because they are set to the same format as the system date on my Mac, 
> however, sorting by dateTime fails (on my Mac) when the system is set to use 
> dashes as date separators. e.g.: 11-09-2022, it works fine with any other 
> format. e.g.: 11/09/2022
> 
> I know that I can work around this fairly easily, but I see this as a bug. 
> Before I report it, I figured it would be best to ask here if anyone else has 
> come across this, or am I missing something? Seems like this should have been 
> caught a long time ago.
> 
> macOS Monterey
> Version 12.5.1
> LiveCode 9.6.8 & 10.0.0 (dp 4)
> 
> Paul
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Sort Ascending DateTime - failure

2022-09-11 Thread Paul Hibbert via use-livecode
While playing around with the PolyGrid, I wanted to try adding sorting options 
by clicking the PolyGrid Header Labels. The solution I came up with drove me 
nuts until I discovered that there appears to be an issue associated with the 
sort command and dateTime.

According to the dictionary, text can be sorted by dateTime, and the entry for 
dateTime states…

"The dateTime keyword recognizes all LiveCode's date and time formats and sorts 
them in time order, rather than alphabetical or numeric order."

Date Formats:

the [{ long | abbreviated | short }] [{ english | system }] date

…So I was expecting to be able to sort the PolyGrid by the dates as entered, 
because they are set to the same format as the system date on my Mac, however, 
sorting by dateTime fails (on my Mac) when the system is set to use dashes as 
date separators. e.g.: 11-09-2022, it works fine with any other format. e.g.: 
11/09/2022

I know that I can work around this fairly easily, but I see this as a bug. 
Before I report it, I figured it would be best to ask here if anyone else has 
come across this, or am I missing something? Seems like this should have been 
caught a long time ago.

macOS Monterey
Version 12.5.1
LiveCode 9.6.8 & 10.0.0 (dp 4)

Paul
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Livecode Builder -how t write to a file?

2022-09-11 Thread Mike Kerner via use-livecode
one other note on execute script, if you choose to go that route: you
cannot use it until the OnLoad() and OnCreate() events achieve.


On Sun, Sep 11, 2022 at 7:44 PM Mike Kerner 
wrote:

> From Brian, answering the same question on the LCB Missing Manual repo
> "See the contents of file File in the LCB dictionary. The actual name is
> FileContents"
>
> On Sun, Sep 11, 2022 at 11:20 AM Mike Kerner 
> wrote:
>
>> Try execute script
>> that throws you over the wall into LCS
>>
>>
>> On Mon, Aug 22, 2022 at 6:46 PM matthias rebbe via use-livecode <
>> use-livecode@lists.runrev.com> wrote:
>>
>>> Thanks Zryip,
>>>
>>> i think that is a good workaround. ;)
>>>
>>> Thanks.
>>>
>>> Regards,
>>> Matthias
>>>
>>>
>>> > Am 22.08.2022 um 00:38 schrieb zryip theSlug via use-livecode <
>>> use-livecode@lists.runrev.com>:
>>> >
>>> > Dear Matthias,
>>> >
>>> > I do not have the answer but a possible workaround.
>>> >
>>> > For debugging purposes I'm using the post message.
>>> >
>>> > In LCB add this handler:
>>> > private handler throwWidgetError(in pError as String) returns nothing
>>> >  post "catchWidgetError" with [pError]
>>> > end handler
>>> >
>>> > Call it by using:
>>> > throwWidgetError("Something to log")
>>> >
>>> > And catch it by adding this handler into the card script where you test
>>> > your widget:
>>> >
>>> > *command* catchWidgetError pTheError
>>> > *   put* pTheError & cr after msg
>>> > *end* catchWidgetError
>>> >
>>> > This might be verbose as the message box will take the focus, and the
>>> > widget will refresh, so logging in a file instead of the message box
>>> would
>>> > be a possibility.
>>> >
>>> > *command* catchWidgetError pTheError
>>> > *   write *pTheError to file "xxx"
>>> > *end* catchWidgetError
>>> >
>>> > On Sun, 21 Aug 2022 at 20:59, matthias rebbe via use-livecode <
>>> > use-livecode@lists.runrev.com> wrote:
>>> >
>>> >> Hi.
>>> >>
>>> >> From time to time and when time allows i am trying to get used to with
>>> >> Livecode Builder.
>>> >> For debugging i would like my lcb script to write some debug code to a
>>> >> file, but i really do not see how this can be done.
>>> >> I found the experimental com.livecode.file module and the operator
>>> 'the
>>> >> filecontents of file...', but unfortunately no script example.
>>> >>
>>> >> Does anyone know, if and how i can write some data to an external
>>> file on
>>> >> hard disk in LCB?
>>> >>
>>> >>
>>> >> Regards,
>>> >> Matthias
>>> >>
>>> >>
>>> >> ___
>>> >> use-livecode mailing list
>>> >> use-livecode@lists.runrev.com
>>> >> Please visit this url to subscribe, unsubscribe and manage your
>>> >> subscription preferences:
>>> >> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> >>
>>> >
>>> >
>>> > --
>>> > Zryip TheSlug
>>> > http://www.aslugontheroad.com
>>> > ___
>>> > use-livecode mailing list
>>> > use-livecode@lists.runrev.com
>>> > Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> > http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>>> ___
>>> use-livecode mailing list
>>> use-livecode@lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>
>>
>> --
>> On the first day, God created the heavens and the Earth
>> On the second day, God created the oceans.
>> On the third day, God put the animals on hold for a few hours,
>>and did a little diving.
>> And God said, "This is good."
>>
>
>
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
>and did a little diving.
> And God said, "This is good."
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Livecode Builder -how t write to a file?

2022-09-11 Thread Mike Kerner via use-livecode
>From Brian, answering the same question on the LCB Missing Manual repo
"See the contents of file File in the LCB dictionary. The actual name is
FileContents"

On Sun, Sep 11, 2022 at 11:20 AM Mike Kerner 
wrote:

> Try execute script
> that throws you over the wall into LCS
>
>
> On Mon, Aug 22, 2022 at 6:46 PM matthias rebbe via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
>> Thanks Zryip,
>>
>> i think that is a good workaround. ;)
>>
>> Thanks.
>>
>> Regards,
>> Matthias
>>
>>
>> > Am 22.08.2022 um 00:38 schrieb zryip theSlug via use-livecode <
>> use-livecode@lists.runrev.com>:
>> >
>> > Dear Matthias,
>> >
>> > I do not have the answer but a possible workaround.
>> >
>> > For debugging purposes I'm using the post message.
>> >
>> > In LCB add this handler:
>> > private handler throwWidgetError(in pError as String) returns nothing
>> >  post "catchWidgetError" with [pError]
>> > end handler
>> >
>> > Call it by using:
>> > throwWidgetError("Something to log")
>> >
>> > And catch it by adding this handler into the card script where you test
>> > your widget:
>> >
>> > *command* catchWidgetError pTheError
>> > *   put* pTheError & cr after msg
>> > *end* catchWidgetError
>> >
>> > This might be verbose as the message box will take the focus, and the
>> > widget will refresh, so logging in a file instead of the message box
>> would
>> > be a possibility.
>> >
>> > *command* catchWidgetError pTheError
>> > *   write *pTheError to file "xxx"
>> > *end* catchWidgetError
>> >
>> > On Sun, 21 Aug 2022 at 20:59, matthias rebbe via use-livecode <
>> > use-livecode@lists.runrev.com> wrote:
>> >
>> >> Hi.
>> >>
>> >> From time to time and when time allows i am trying to get used to with
>> >> Livecode Builder.
>> >> For debugging i would like my lcb script to write some debug code to a
>> >> file, but i really do not see how this can be done.
>> >> I found the experimental com.livecode.file module and the operator 'the
>> >> filecontents of file...', but unfortunately no script example.
>> >>
>> >> Does anyone know, if and how i can write some data to an external file
>> on
>> >> hard disk in LCB?
>> >>
>> >>
>> >> Regards,
>> >> Matthias
>> >>
>> >>
>> >> ___
>> >> use-livecode mailing list
>> >> use-livecode@lists.runrev.com
>> >> Please visit this url to subscribe, unsubscribe and manage your
>> >> subscription preferences:
>> >> http://lists.runrev.com/mailman/listinfo/use-livecode
>> >>
>> >
>> >
>> > --
>> > Zryip TheSlug
>> > http://www.aslugontheroad.com
>> > ___
>> > use-livecode mailing list
>> > use-livecode@lists.runrev.com
>> > Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> > http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
>and did a little diving.
> And God said, "This is good."
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: LC converts phone number to scientific notation

2022-09-11 Thread kee nethery via use-livecode
I had the same problem with long integer numbers being imported into a 
spreadsheet. My solution was to append “a” to the numbers before they got 
imported into the spreadsheet.

Kee Nethery


> On Sep 9, 2022, at 3:00 AM, Klaus major-k via use-livecode 
>  wrote:
> 
> Hi friends,
> 
> I have a very strange problem, but also found a workaround for it.
> 
> I first convert an 8 MB CSV file with 6 lines to TAB delimited data, then 
> I parse the file 
> and just extract some columns from the 6 lines to display in a field.
> E.g. the column "number dialled", which contains phone number like 
> -> 447973100123
> 
> The CSV files are definitively correct but I found that in the resulting 
> field some of these numbers 
> appear in scientific notation 
> -> 4.47888E+11
> 
> This does not happen with phone numbers with a leading ZERO: like
> -> 07557162491
> So maybe this a small hint?
> 
> However I do not even touch these items I just use:
> ...
> put item 9 of tLine into item 6 of tNewLine
> ## tLine is the line from the CSV and tNewLine is for the data in the display 
> field.
> ...
> 
> My simple workaround, no idea why, but it obviously works:
> ...
> put item 9 of tLine into ttt
> put ttt into item 6 of tNewLine
> ...
> This avoids the scientific notation, what the hell is going on here?
> Any hints welcome.
> 
> 
> Best
> 
> Klaus
> --
> Klaus Major
> https://www.major-k.de
> https://www.major-k.de/bass
> kl...@major-k.de
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Livecode Builder -how t write to a file?

2022-09-11 Thread Mike Kerner via use-livecode
Try execute script
that throws you over the wall into LCS


On Mon, Aug 22, 2022 at 6:46 PM matthias rebbe via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Thanks Zryip,
>
> i think that is a good workaround. ;)
>
> Thanks.
>
> Regards,
> Matthias
>
>
> > Am 22.08.2022 um 00:38 schrieb zryip theSlug via use-livecode <
> use-livecode@lists.runrev.com>:
> >
> > Dear Matthias,
> >
> > I do not have the answer but a possible workaround.
> >
> > For debugging purposes I'm using the post message.
> >
> > In LCB add this handler:
> > private handler throwWidgetError(in pError as String) returns nothing
> >  post "catchWidgetError" with [pError]
> > end handler
> >
> > Call it by using:
> > throwWidgetError("Something to log")
> >
> > And catch it by adding this handler into the card script where you test
> > your widget:
> >
> > *command* catchWidgetError pTheError
> > *   put* pTheError & cr after msg
> > *end* catchWidgetError
> >
> > This might be verbose as the message box will take the focus, and the
> > widget will refresh, so logging in a file instead of the message box
> would
> > be a possibility.
> >
> > *command* catchWidgetError pTheError
> > *   write *pTheError to file "xxx"
> > *end* catchWidgetError
> >
> > On Sun, 21 Aug 2022 at 20:59, matthias rebbe via use-livecode <
> > use-livecode@lists.runrev.com> wrote:
> >
> >> Hi.
> >>
> >> From time to time and when time allows i am trying to get used to with
> >> Livecode Builder.
> >> For debugging i would like my lcb script to write some debug code to a
> >> file, but i really do not see how this can be done.
> >> I found the experimental com.livecode.file module and the operator 'the
> >> filecontents of file...', but unfortunately no script example.
> >>
> >> Does anyone know, if and how i can write some data to an external file
> on
> >> hard disk in LCB?
> >>
> >>
> >> Regards,
> >> Matthias
> >>
> >>
> >> ___
> >> use-livecode mailing list
> >> use-livecode@lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> >
> >
> > --
> > Zryip TheSlug
> > http://www.aslugontheroad.com
> > ___
> > use-livecode mailing list
> > use-livecode@lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode