New Way To Deal With Custom Fonts on iOS?

Ken Ray kray at sonsothunder.com
Wed Apr 15 15:13:04 EDT 2015


Scott,

Sorry I’m late to the party, but I ran into this quite a while ago and wrote this post to LiveCodeJournal:

http://livecodejournal.com/forum/viewtopic.php?f=23&t=48 <http://livecodejournal.com/forum/viewtopic.php?f=23&t=48>

I had to create a series of routines that would work off of a font map in a custom property, where the "map" was a tab/CR-delimited chunk of data in three columns: the "FontNames" name, the font weight, and the "FontStyles" name, like:

Academy Engraved LET <tab> Plain <tab> AcademyEngravedLetPlain
American Typewriter <tab> Light <tab> AmericanTypewriter-Light
American Typewriter <tab> Plain <tab> AmericanTypewriter
American Typewriter <tab> Bold <tab> AmericanTypewriter-Bold
American Typewriter <tab> Light Condensed <tab> AmericanTypewriter-CondensedLight
American Typewriter <tab> Condensed <tab> AmericanTypewriter-Condensed
American Typewriter <tab> Bold Condensed <tab> AmericanTypewriter-CondensedBold
(etc.)

I needed this to be able to let someone pick a "font" in iOS and then be able to assign the proper font (from the fontStyles) to the field. If you are interested in getting a copy of these, let me know in case you don’t want to roll your own.


Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com <applewebdata://C49A4349-A6BD-4E58-9142-53689732E5F9/kray@sonsothunder.com>
Web Site: http://www.sonsothunder.com/	 <http://www.sonsothunder.com/>



> On Apr 15, 2015, at 11:23 AM, Scott Rossi <scott at tactilemedia.com> wrote:
> 
> Thanks Chris.  The bug report is mostly about time to load, but yes it
> seems somewhat related.  The main issue is there's some disconnect between
> what the fontNames function reports and what is needed by the system for
> fonts to render properly.  To apply a font name, the basic approach seems
> to be to put the core name of the font into a string, followed by a single
> hyphen and any style/s, and remove spaces from string (shown below).
> 
> There are several exceptions though, such as Arial which is listed as
> "Arial" in the fontNames but is actually "ArialMT" on the device.  There
> are roughly dozen or so of these exceptions, and to further complicate
> matters, there's at least one case where "condensed" is part of the font's
> name, as opposed to being a style.  There is no way to make this
> differentiation programmatically.
> 
> I wrote a font name formatting routine which works about 90% of the time,
> but then realized it's probably easier just to go with an established
> reference, like the one here:
> http://iosfonts.com/
> 
> 
> In any event, the fontNames needs to be fixed, because trying to figure
> out the naming for any custom installed font still requires trial and
> error.
> 
> Regards,
> 
> Scott Rossi
> Creative Director
> Tactile Media, UX/UI Design
> 
> 
> 
> 
> On 4/14/15, 7:18 AM, "Chris Sheffield" <cs_livecode at icloud.com> wrote:
> 
>> Scott,
>> 
>> Could this possibly be related to this issue bug 14116
>> <http://quality.runrev.com/show_bug.cgi?id=14116>?
>> 
>> Mark W. stated in a comment there that the screen loading times may have
>> something to do with a change in the way that fonts were handled between
>> LC 6.6 and LC 6.7. I wonder if the issue you described is related
>> somehow. Maybe it¹s also caused by this change to using CoreText in iOS.
>> Specifically, see his comment from February 27.
>> 
>> Chris
>> 
>> 
>> 
>>> On Apr 14, 2015, at 1:27 AM, Scott Rossi <scott at tactilemedia.com> wrote:
>>> 
>>> Hi All:
>>> 
>>> I just spent two hours with a colleague trying to track down why a
>>> custom
>>> font wasn't rendering correctly on iOS, and apparently it seems that
>>> something changed with either the way LiveCode 7 or iOS 8 handles font
>>> names.
>>> 
>>> It used to be that grabbing the installed name of a font on iOS was all
>>> that was needed to get a custom font to work, but now it seems one has
>>> to
>>> manually combine the font name and any desired style/s into a string
>>> separated by a dash:
>>> 
>>> Installed name = American Typewriter Condensed Bold
>>> becomes -------> AmericanTypewriter-CondensedBold
>>> 
>>> I know about the fontStyles function, but that only appears to return
>>> available styles for font, it doesn't return a properly formatted
>>> fontName.
>>> 
>>> Looking up font related terms/issues in the docs, forums, and mail list
>>> I
>>> haven't seen any reference to this anywhere.  Is this documented, and
>>> even
>>> more importantly, is there a function or script to automate this so we
>>> don't have to maintain a stored list of styles and compare/replace words
>>> in the font name?
>>> 
>>> I'm also worried about what caused this change: is this a LiveCode
>>> change
>>> or an iOS change?  An iOS change would seem to mean that we need to code
>>> around the system version to handle older versions of iOS.
>>> 
>>> Thanks for any info/advice here.
>>> 
>>> Regards,
>>> 
>>> Scott Rossi
>>> Creative Director
>>> Tactile Media, UX/UI Design
>>> 
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at 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 at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list