Page 1 of 1

Font details returned from 'start using font'

Posted: Wed Mar 28, 2018 9:34 am
by thatkeith
The 'start using font file' command is superb, and the 'globally' addition is also extremely useful. What would make this even better would be returning (in some way) the system-friendly font name (and styles, differentiated from the font family name?) of the font it activates. That would eliminate the need to do a before/after difference check on the whole list of active fonts.

Currently, 'the result' is empty unless an error happened. Perhaps the activated font name details could be put in there on success and a more explicit "error" plus details could be used on failure (duplicate active font, unable to read font file, etc.)?

The current implementation is great when dealing with a known font, such as one stashed in the app bundle, but when faced with more open-ended use with a user's font library it gets much more clunky.

Re: Font details returned from 'start using font'

Posted: Wed Mar 28, 2018 11:00 am
by richmond62
If the font was loaded successfully, the start using font command puts empty into the result.
That does seem counter intuitive.

I have just tried this:

Code: Select all

put the fontFilesInUse
*** the fonts were loaded using revFontLoad ***

which, annoyingly did NOT return the fonts I had just loaded (see my stack I uploaded earlier),
but, merely, "guff" about fonts inwith the LC 8.1.8 bundle (mac OS):
/Users/richmondmathewson/LiveCode/LiveCode Community 8.1.8.app/Contents/Tools/Toolset/resources/supporting_files/fonts/fontawesome.ttf
/Users/richmondmathewson/LiveCode/LiveCode Community 8.1.8.app/Contents/Tools/Toolset/resources/supporting_files/fonts/lcideicons.ttf
The Dictionary seems a bit misleading:
the fontFilesInUse property will return the fill paths of the loaded font files.
sic

HOWEVER :D :D :D :D

Loading the fonts with 'start using font file' allows

Code: Select all

put the fontFilesInUse
to list the added files ALONG with LiveCode's own internal ones:
/Volumes/STORAGE_2/Free Fonts/Happy Clean/TTF/Happy Party.ttf
/Users/richmondmathewson/LiveCode/LiveCode Community 8.1.8.app/Contents/Tools/Toolset/resources/supporting_files/fonts/fontawesome.ttf
/Users/richmondmathewson/LiveCode/LiveCode Community 8.1.8.app/Contents/Tools/Toolset/resources/supporting_files/fonts/lcideicons.ttf

THIS
is probably what you need.

Re: Font details returned from 'start using font'

Posted: Wed Mar 28, 2018 11:25 am
by thatkeith
richmond62 wrote:
Wed Mar 28, 2018 11:00 am
If the font was loaded successfully, the start using font command puts empty into the result.
That does seem counter intuitive.
Perhaps when it was implemented the result was seen as nothing more than an error trap method? Extending the result in this way would seem to be the perfect way to enhance the command's usefulness and helpfulness. Although it seems (from the Dictionary entry for Result) that the current general concept is for commands to only put something into the result if an error occurs:
LiveCode Dictionary, "Result" wrote:Many commands (such as go and find) set the value of the result function when they finish. In most cases, if the result is empty, the command was successful; if the result is not empty, the command failed and the result contains an error message. See the specific command for information about whether it sets the result function.
Whereas control structures use the result a little more freely:
LiveCode Dictionary, "Result" wrote:Use the result function to check whether the last command executed encountered an error, or get the last value returned with the control structure return.
I hope the fact that 'start using font' is a command doesn't prevent this feature request from being considered.

richmond62 wrote:I have just tried this:

put the fontFilesInUse

which, annoyingly did NOT return the fonts I had just loaded (see my stack I uploaded earlier),
but, merely, "guff" about fonts inwith the LC 8.1.8 bundle (mac OS)
That does seem counter to the Dictionary's description that fontFilesInUse reports the files that have been loaded into memory by the start using font command. Although... did you load the fonts using the older revFontLoad command? The Dictionary description only talks about fonts loaded using the newer 'start using font' command. Perhaps we've found another difference between the two methods? :o

Re: Font details returned from 'start using font'

Posted: Wed Mar 28, 2018 7:04 pm
by richmond62
start using font file and stop using font file do seem superior to revFontLoad and revFontUnload at least in as far as one can find out what's what subsequently.

Re: Font details returned from 'start using font'

Posted: Wed Mar 28, 2018 7:09 pm
by Klaus
start using font file and stop using font file do seem superior to revFontLoad and revFontUnload at least in as far as one can find out what's what subsequently.
"revFontLoad" and "reFontUnload" have been deprecated some versions ago (version 7?) and are not listed in the dictionary anymore, so all of these considerations are "moot" :-)

Re: Font details returned from 'start using font'

Posted: Wed Mar 28, 2018 8:06 pm
by thatkeith
Indeed. So, back to the feature request... :lol:

Re: Font details returned from 'start using font'

Posted: Thu Mar 29, 2018 10:27 am
by richmond62
deprecated some versions ago
Quite possibly, Klaus . . .

BUT on later versions of LiveCode there isn't a splash screen that pops up whenever one tries to use
something 'deprecated' saying "Oy, Mush: that's outdated stuff!"

Re: Font details returned from 'start using font'

Posted: Thu Mar 29, 2018 10:47 am
by thatkeith
Splash screens are so last decade...
Image

Re: Font details returned from 'start using font'

Posted: Thu Mar 29, 2018 10:55 am
by Klaus
richmond62 wrote:
Thu Mar 29, 2018 10:27 am
deprecated some versions ago
Quite possibly, Klaus . . .

BUT on later versions of LiveCode there isn't a splash screen that pops up whenever one tries to use
something 'deprecated' saying "Oy, Mush: that's outdated stuff!"
I knew you would post this! :D
But this will fail silently in one of the next versions, so why not get used to not use it anymore?

Re: Font details returned from 'start using font'

Posted: Thu Mar 29, 2018 5:08 pm
by jacque
thatkeith wrote:
Thu Mar 29, 2018 10:47 am
Splash screens are so last decade...
Image
:) I found this disproportionately amusing.

Re: Font details returned from 'start using font'

Posted: Thu Mar 29, 2018 6:30 pm
by bogs
jacque wrote:
Thu Mar 29, 2018 5:08 pm
I found this disproportionately amusing.
It is a good one, I enjoyed it as well thatkeith :)

Re: Font details returned from 'start using font'

Posted: Thu Mar 29, 2018 6:36 pm
by richmond62
I found this disproportionately amusing.
Utterly hilarious: and it would be even better were it to be implemented 8)

Re: Font details returned from 'start using font'

Posted: Thu Mar 29, 2018 7:20 pm
by FourthWorld
You're right about "the result" being used primarily for errors, Keith. Commands that return data often put that data in "it".

Re: Font details returned from 'start using font'

Posted: Sat Mar 31, 2018 8:07 am
by thatkeith
Ah, of course. It – I meant ‘it’ – would be a very respectable place to put the data.

Re: Font details returned from 'start using font'

Posted: Sat Mar 31, 2018 8:33 am
by richmond62
I wonder when someone is going to set up a website to disambiguate 'it' in LiveCode:

'it' should prove interesting.