Sorting out the fontnames

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Sorting out the fontnames

Post by trevordevore » Fri Jun 28, 2013 4:16 pm

I'm working through an issue on OS X and realizing that LiveCode needs better ways of listing available fonts. Take, for example, the situation where you want to display a list of fonts for the user to choose from. If you call 'the fontnames' on OS X it lists all of the font files installed rather than the family of fonts. For example, if you have Lato installed (http://www.latofonts.com) and you get 'the fontNames' on OS X then you get the following list for Lato:

Lato Black
Lato Black Italic
Lato Bold
Lato Bold Italic
Lato Hairline
Lato Hairline Italic
Lato Italic
Lato Light
Lato Light Italic
Lato Regular

A program like Microsoft Word or Pages will just list Lato and then you can choose if you want to specifically use Bold, Bold Italic, Italic, etc. If you just select Lato for a run of text and you make a word in that run of text italic then the Lato italic font is used to render the text. With the list that LiveCode provides there is no entry for "Lato" so the user has to select "Lato Regular". It seems that the fontnames should return the font family and then you would use the fontStyles to get the various versions of the font that are available for the font family.

Now for the fun part - if you assign "Lato Regular" as the textfont of some text in LiveCode and then make that textstyle italic then the Lato Italic font is used to render the text. If you assign "Lato" to the textfont then lato is used but the size and kerning is not right. If you make the textstyle italic then the text becomes italicized but the Lato Italic font is not used. Rather the text is just slanted.

If, however, I use the font name "Lato Regular" in an HTML webpage then the opposite occurs. Lato is used for textStyle = empty text but italicized text is just slanted (the Lato Italic font IS NOT used). If I use "Lato" in an HTML page then italicized text looks as it should (the Lato Italic font IS used).

So it seems that the way LiveCode deals with fonts (at least on OS X, Windows behavior is different) is outdated. The font APIs that LiveCode uses were deprecated in 10.4. I believe I have heard @runrevmark discuss this font issue (or at least making a passing remark about it) in the past. Has any thought been given to what needs to happen to bring fonts up to date in LiveCode?
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Sorting out the fontnames

Post by shaosean » Sat Jun 29, 2013 8:21 am

This could be an issue due to the engine being Carbon rather than Cocoa.. Under Carbon you can use italicized fonts even if there is no italicized version in the family, whereas Cocoa will not.. Perhaps writing an external to get the font families instead of the font files could be used until the engine is updated..

Locked

Return to “Engine Contributors”