How do I discover the font?

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
chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

How do I discover the font?

Post by chris25 » Thu Nov 14, 2013 3:44 pm

In 20 years of using a million pieces of software I have never ever ever had to ask or even look up in some instructions about where to find what font I am looking at or high-lighting? Please don't annoy me by asking me whether I have looked in the 'obvious' places in livecode. :D You know...those places where one would have expected! to have seen it, with a tick, or with a grey overlay, you know? ...like all those other pieces of software even the ones that don't work, I have even found it on a French product and I don't know french at all. :) And while we are at it, which FontType is "owners font" please? Well...this is fun isn't it? :roll:

Kind regards
chris

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

Re: How do I discover the font?

Post by FourthWorld » Thu Nov 14, 2013 4:33 pm

chris25 wrote:In 20 years of using a million pieces of software I have never ever ever had to ask or even look up in some instructions about where to find what font I am looking at or high-lighting?
The property that governs the font used by text in LiveCode is called textFont, and can be obtained for an object or a chunk of text, e.g.:

set the textFont of btn 1 to "Helvetica"
get the textFont of selectedChunk

The textFont property in inherited, so that if the object or chunk doesn't have it explicitly set it will inherit the textFont of its owner. To account for cases where the textFont isn't set directly on the element you're querying, you can use the "effective" keyword:

get the effective textFont of word 3 of fld 1

The "effective" keyword can also be used for other inherited properties, like textSize, textHeight, backgroundColor, etc.
Please don't annoy me by asking me whether I have looked in the 'obvious' places in livecode. :D
Many of us ask for that information for two reasons:


1. To provide a more complete learning experience.

In those cases where we can help folks understand where learning materials are found and how they're laid out, many times this can be very liberating for users to know, as they can more readily anticipate where they might look for answers to other questions down the road, and find those answers more quickly and easily.

It's the old "teach a man to fish" thang, and it's been helpful for much of human learning for centuries, no less so when learning a programming language.

In this case, for example, using the search box in the Dictionary filtering for "font" shows 12 entries, most of which are fairly obviously not what you're looking for, and "textFont" is among them. While it would require skimming a few entries to discover the one you need, using that approach will not only help you find what you're looking for in a few seconds, but also introduce other font-related tokens which may be useful later on.

The Dictionary currently suffers from the classic problem in most API reference info (see #2 below), but it's often a good starting point for exploring the LiveCode language.


2. To improve the documentation

The LiveCode Dictionary contains most of the information one needs to use the language well, but like most API references it sometimes requires the user to be able to anticipate specific terms to find what's needed.

One way to alleviate that would be for the Dictionary to include synonyms or other additional tags in its index, so that when filtering for a term that's not literally part of the token needed, conceptually-related terms could still yield useful results.

The challenge with adding such tags to the index is that those of us in a position to do so, who have sufficient interest and experience to contribute to the development of the IDE, know the language too well to be able to anticipate the range of terms people might use when searching for a particular item. This "too much familiarity" is the classic problem which describes why programmers can't adequately test their own code and why usability studies are critical for good design, and it applies equally to the task of anticipating how new users conceptualize their search terms.

Since indexing is a keen personal interest of mine, and since much of my work involves teaching LiveCode, I frequently ask folks who are looking for information to please assist this process by describing the steps they took on their own before bringing their question to the forum.

My hope is that I'll be able to gather enough information to propose a sort of synonym lookup table, similar to ones I've implemented in embedded search engines I've written for other products in LiveCode.

But of course, to be able to do that will require a bit of crowdsourcing, some assistance from newcomers who've noted that they've had difficulty finding what they're looking for.


I hope this background helps mitigate some of the annoyance with the questions you'll see here from myself and others. We're really only trying to help.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How do I discover the font?

Post by Klaus » Thu Nov 14, 2013 4:34 pm

Hi Chris,

...
put the EFFECTIVE textfont of fld XYZ into tFieldTextFont
## or whatever...
...


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: How do I discover the font?

Post by dunbarx » Thu Nov 14, 2013 4:42 pm

Hello Chris,

By default, text in a newly created field inherits the text properties of the system. You might call this the "default owner" of those properties. These can be changed afterwards as you wish. But if you ask for the textFont of such a newly created field, you will get empty. similarly for the textSize, and likely other similar properties.

You can put this in a button, for example, and click it after you hilite some text in a field:

answer the textFont of the selection
answer the textFont of the hilitedText

And that sort of thing. Does this give you enough power and flexibility to do what you seem to need? Or lack?

Craig

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: How do I discover the font?

Post by chris25 » Thu Nov 14, 2013 4:53 pm

I had to laugh. I read Fourthworld's answer and then Klaus. Guys, I really appreciate both of your contributions, thankyou Richard your speech is interesting, and I hope that you believe me that when I said: ..please don't annoy me... that there was humour here in that I felt embarrassed by simply asking "where do I find the font name" when I am sure you realize that this seemed a kind of basic of all basic questions to ask when only old age pensioners and 5 year olds would ask this at the beginning of their computer experience. I have to remember that I can use the message box and type in a function or keyword, this is something that I am not yet fully accustomed to doing. So thankyou Richard and Klaus.

On a separate issue, I seem to be having an issue with the following: I have a link to a website within text and a link to an email address. Now the latter works perfectly. But I suddenly noticed that the web link only works when I have already accessed the website directly via my browser and then closed it down. What is happening is that the link from my stack will not access the website if I have cleared my cache, for obvious reasons, I understand this bit. But this means that in actuality the link is truly not working because I get a "server down" message in Google. So that means that the user will not be able to get to the website either.

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: How do I discover the font?

Post by chris25 » Thu Nov 14, 2013 5:29 pm

Richard and Klaus, thankyou for elaborating about the effective keyword, I would not have known to have looked this up.

Craig, yes it's nice, but rather a bit interfering when I have so many buttons and text fields on one card (that is with many horizontal tabs) so adding an extra button in this instance...well that's me. But I do see it as certainly very useful to know. (all comments are recorded in my workbook).

Kind regards
Chris

Edit Do you mean type in the effective keyword into the message box, because I did - but got nothing but errors?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: How do I discover the font?

Post by dunbarx » Thu Nov 14, 2013 6:30 pm

In the message box:

answer the effective textFont of word 2 of line 3 of fld "yourField"

Gives what it ought to. What error are you seeing?

Craig
Last edited by dunbarx on Thu Nov 14, 2013 8:42 pm, edited 1 time in total.

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: How do I discover the font?

Post by chris25 » Thu Nov 14, 2013 7:12 pm

I was using the put and then the get with the effective textfont. But I used now the : answer the effective textFont of word 2 of line 3 of fld "yourField" and it worked.

Post Reply