On iOS, can I access the system-provided font's TTF file - uikit

I'm trying out FTGLES to dynamically display text in arbitrary fonts on OpenGL-ES on iOS (cf. my SO question here). That library seems to require direct access to the TTF file to use the font. Using kosher methods, can one directly access -- by path -- the system font files on iOS? I've RTFM'd and couldn't find anything.
Barring that, does anyone know if it is Apple-approved to copy the system fonts into your app (before submission).

My solution was inspired by skia.
Though cannot access system built-in font files directly, we still have an indirect way:
Create a CGFont with your wanted font name, all contents of SFNT table of this CGFont can be accessed by simply calling CGFontCopyTableTags() and CGFontCopyTableForTag().
A ttf/otf font data can then be constructed by using these tables, save the new created font to disk, you can use it in FTGL ES later.

No, you can't access the system installed TTF files on iOS devices. So you'll have to embed the typefaces you'd like to use.
Disclaimer: I'm not a lawyer, and the acceptability of using Apple supplied system fonts in an iOS app is a legal question about interpreting software licenses, so you may want to seek professional advice.
You wish to embed an Apple supplied font in your app. The definition of "embed" is a bit nebulous, so adding the font to an iOS app may or may not fit within the copyright holder's definition of "embed". Some type houses define "embed" to mean just viewing predetermined content in the included font; other mean viewing and editing content in that font. Displaying content that changes during the running of your app is somewhere between these two cases.
According to the Mac OS X Lion 10.7.2 ELUA:
F. Fonts. Subject to the terms and conditions of this License, you may
use the fonts included with the Apple Software to display and print
content while running the Apple Software; however, you may only embed
fonts in content if that is permitted by the embedding restrictions
accompanying the font in question. These embedding restrictions can be
found in the Font Book/Preview/Show Font Info panel.
If using the fonts in an iOS app is indeed "embedding", you just need to check the particular fonts you wish to use in Font Book.
In this situation I would find a font or set of fonts where I had explicit permission to include the fonts in the iOS app. I would start by shopping around the various type houses for a licensing scheme that explicitly allowed this use. This may get expensive, so another tack would be to seek out open source typefaces with a license that would allow this use. Or, for a very limited set of characters (e.g. only numbers) I would even consider drawing my own typeface.

No. Your app cannot access files outside the sandbox of your app. Period (well, unless it's jailbroken ;). But you can indeed bundle the font file. Now, I see no reason why Apple would reject your app, as it's using a file already available on the device, and you're just including your local file to it. In terms of copyright, Apple already has that permission to use it on their device, so your inclusion of it should be no problem.
I say should because I haven't needed this capability and haven't tested it with a submission of my own, but based on legal instinct and font copyright issues I've seen in the past, I'd expect that it wouldn't be a problem.

Related

In Firefox, from a WebExtension, can I enumerate fonts, and if so, how?

Use-case, in a Firefox (or soon, other browsers) WebExtension, I want to present the user with a way to customize the font used in parts of the interface. I want to use fonts that the browser is already aware of, be they installed on 1) the system, or 2) in browser "font cache" (if such a thing exists - e.g. when using CSS #font-face, local( 'Font Name' ) looks for a local cached copy of font, or on system or something).
In Firefox -> Options -> Content -> Fonts & Colors, there is a drop-down selection of fonts that Firefox found on my system. How can I get this list (and the meta-info about whether it is a serif, sans or mono or other family) for use in a WebExtension? This seems to be a list of fonts installed on the system.
How might I also get the web-fonts stored in cache somewhere (i.e. web fonts previously downloaded by other pages, the way Google Fonts API does it)?
I'd like to use the meta-info to filter the font list, whitelisting mono or serif fonts that are legible.
Before anyone says, "just include all the font files and serve them up with CSS", I'd just like to say that while technically possible and trivial, it isn't legally possible, as most system fonts are mired in intellectual-property usage-restrictions.
And before someone responds, "well, just use only open fonts then", I'd also like to say that while I may make some open fonts available, most open fonts are ugly, illegible, or otherwise unsuitable. And many copyrighted patented trademarked closed-source system fonts are already on the system and look better and also vary by system. So I'd rather serve up options of fonts to people on specific platforms that they will be familiar and comfortable with. This may even include foreign language fonts, which open fonts are severely lacking at the moment.
And before anyone suggests, "well go make your own multi-lingual open font!!", I'd like to say I already have FontForge, and it's no trivial task to create a font for one language let alone all of them (even if I knew all languages and what constituted an attractive font in each language), though I have hacked a few icon fonts so I technically know how to do it, kind of.

How to change the font in Squib

I want to change the font in Squib.
How do I do this.
There is a font folder and also I can see where I set the font in the layout, do I need to set it anywhere else.
I'm wanting to use FiraSans-Regular.otf and FiraSans-Heavy.otf
At this point in time, Squib doesn't support loading fonts locally. You'll have to install the font on your system, and then do something like text font: 'FiraSans'. I generally keep my font files in my git repo just for portability.
Loading local fonts has been discussed by the Pango team (what Squib uses for text), and they are making the process less painful as I understand it. http://mces.blogspot.com/2015/05/how-to-use-custom-application-fonts.html. It will be a while until that translates to Ruby, as well, since cross-platform compatibility is hard when it comes to fonts.
I've created a GitHub issue to track on this if you want to follow it:
https://github.com/andymeneely/squib/issues/105

Sane localization workflow using Xcode 6, iOS 8, Storyboards and xliff?

This is ideally what I'd like to do:
Set up a project in Xcode using a base localization of English. Ultimately I want English and let's say Dutch versions of my Localizable.strings and Storyboards
Externalise strings in code with NSLocalizedString, using keys of the form fooViewController.barLabel, being diligent and adding proper context comments with every key
Add a Dutch localization to my Storyboard files
Mark particular labels in the Storyboard as placeholders that will be set at runtime and do not require translations
Add comments for labels in the Storyboard which do require translation
Export the "development language" xliff file (Click on Project, Editor/Export For Localization..., choose "Development Language Only")
Open the English xliff file in a tool like Counterparts or Xliffie or even something web based
Add actual English translations alongside the fooViewController.barLabel keys, and re-save the en.xliff
Create an nl.xliff file from the original en.xliff and add Dutch translations
Import both xliff files into Xcode and have it create the appropriate .strings files for both Dutch and English, for both the keys defined in code and those in the Storyboard; commit the new .strings files into my source repository
At some future point after keys have been added, removed and changed in my source and Storyboards, export the "Development language" en.xliff again as the source of truth
Update the en.xliff and nl.xliff files with current translations, having a tool highlight which keys had been added or removed
Import those xliff files back into Xcode which updates the .strings files I can then check back in to my source repository
Does this make sense? Is this a reasonable thing to want to do? I think so, but it doesn't work.
Here are the problems I ran into:
Xcode does not support step 4—the xliff format can mark a key as translate=no, but there is no way to annotate that in Xcode (ideally, Xcode wouldn't export keys marked as placeholders at all.)
Xcode does not support step 5—there is no way to set a translator comment for a label. There's not even a way to set the key independent of the placeholder text you put in the label on the Storyboard, which is a massive pain if you find filling labels with Lorem Ipsum useful when laying out your views.
When you get to step 10, Xcode complains there is no target language specified in the en.xliff file. There is a way to change the target language (or, at least, create a new file with the target language set to EN) in Counterparts but I couldn't find any way to do this with Xliffie.
Upon attempting to re-export the en.xliff file with updated keys, Xcode told me "Localization failed reading "[...]/Supporting Files/en.lproj/Localizable.strings, Please address the issue at file location 782" at which character location I found... an apostrophe. Xcode can't export an xliff file if the source .strings file contains an apostrophe. What in the actual F...?!
Step 12 and 13 got weird, and I just don't understand what was happening. Both Counterparts and Xliffie had replaced my original fooViewController.barLabel keys with the English translations and looked like they were trying to tell me I had no English translations. Upon attempting to import the en.xliff back into Xcode it told me I had no translations for all but the new keys and when I went ahead, it wiped the existing translations from the en.lproj/Localization.strings file.
This is a mess.
Translating labels in Storyboards without being able to manually set their keys, add translator comments or mark particular labels as placeholders not-for-translation just doesn't work. We've resorted to connecting every label to an #IBOutlet and setting its translation in viewDidLoad() with NSLocalizedString.
Xcode choking when it attempts to export a .strings file containing an apostrophe beggars belief.
It also seems there's an underlying assumption that if the "development language" in Xcode is English, then the developers are in charge of the English translation. I can imagine no context outside that of a single-person indie developer shop where this is true.
Finally, it also seems I'm missing something about how the tools I've attempted to use structure their workflows. If anyone could enlighten me I'd be quite grateful.
Has anyone managed to construct a workable localization workflow where the developers aren't charged with ultimate editing control over the "development language" and the .strings files checked into the repository are the source of truth?
We've resorted to connecting every label to an #IBOutlet and setting its translation in viewDidLoad() with NSLocalizedString.
You are doing that right. Seriously. Wrap your development process around it and you'll get way better off than trying to adopt the mess that the Storyboard localization evolved into.
It solves pt.4 - you decide what you put in the Localizable.strings
It solves pt.5 - comments are there by default, for everything that you decide to be localizable. Now to be honest, XCode7 has added a possibility to add notes to resources. Don't use it. For some reason only known to Apple, it is not available for all types of resources. You can't annotate e.g. table headers and footers. More on that later.
I recommend making your own NSBundle.localizedStringForKey wrapper (macro) which provides the value. NSLocalizedString sets value to empty string, essentially forcing key to be used as the fallback translation content. Of all the already existing questionable macros, NSLocalizedStringWithDefaultValue takes the value but also all other 4 required parameters - not something you would like to use often.
Step 10 is caused by you trying to import a Base localization - the fact that it's english does not make any difference. If you want to "translate english" (i.e. professional correcture), you must add english as another standalone localization on top of Base. Technically it boils down to the Base xliff missing <file target-language> and <target xml:lang> properties. Due to some strange xliff mess similar to yours, i had to add those once manually. You don't want to do that :)
Re apostrophe glitch: iOS localization is an unreal garden of wonders, but i'm prety sure it's not THAT unreal :) Try opening the file in some hexcode displaying editor - what XCode renders may be quite different from what the file really contains.
... even something web based
That's Crowdin for us and it nicely shows everything wrong with Apple's idea of Storyboard localization. Translators need 3 things to do their work professionally: context, context and context. Apple seems to think that translators will gladly install the app, play with it and ask questions to get the context. Because, by default, there is no human context in xliff export. Now with Xcode7, you can add notes, but weirdly not everywhere. Even where you can, your note is appended at the end of already long <note> string with machine context - understandably needed for storyboard import matching, but useless and obstructive for the translator. Furthermore, in reality, the translator is a pro agency, or a language enthusiast. Even if you had a luck with properly equipped enthusiast, or you paid the agency premium for getting an extra customer care, you enter The Hostile Desert Of Beta Distribution Options. Apple's funny Testflight reincarnation will either need the translator to register as an Apple developer, or waiting for Apple's beta review - depending on how early in the app life you need the translation.
BTW i like your blog. Sometimes i feel like dumping my sourness and misfeature fatigue too, but never got as far as you :)

Opentype font not being used in Silverlight Windows Phone 7 app on deploy

Is there a way to use an OpenType font on Windows Phone 7 Silverlight application? I want to use Lobster which is only available AFAIK in OpenType format. It renders in Blend but not when I deploy to the emulator.
I have included the .otf file in my project and set the Properties to 'Content' and 'Copy If Newer'.
This website found a solution for .ttf fonts, but the technique specified does not work for OpenType. Is OpenType not supported by Windows Phone? I find this hard to believe given that MS part invented the format!
Windows Phone requires your fonts to be TrueType (.ttf). OpenType (.otf) is not supported.
There may be some confusion on the term "OpenType". OpenType is a broad description of the format which actually includes 2 "flavors" for describing the font's outlines: TrueType and CFF (A form of Adobe PostScript).
A font with a .otf extension is most definitely an OpenType font, and usually means that it includes CFF outlines.
But a TrueType font is, in most cases, generally considered an OpenType font as well, since the OpenType format is actually a superset of both TrueType and CFF flavors.
Regarding Lobster in particular: as a test, I added that font to my Google Webfonts collection, and clicked "Download Collection". The resulting file was a .ttf, and as such, should be usable in Windows Phone as Den Delimarsky's answer points out. How are you getting a .otf version of this file? And is it truly a CFF file, or just a TrueType file with a .otf extension?
Also note that you may be able to obtain the TrueType/.TTF directly from the Google Font Directory though doing so through a browser currently seems to be a bit wonky.
you need to add it to the project, set build action to content and enter a uri that links to it in the FontFamily property with the hash tag:
Example of FontFamily:
FontFamily="fonts/Lobster.ttf#Lobster"

How to Integrate non supported fonts in WP7

I am creating a English to Mangolean Dictionary app; So i need to display mangolean word corresponding to my english word; i read from a blog that wp7 only supports limited language set. So how can i over come my issue. Please help me to solve this issue.
There's a tutorial on embedding fonts in Silverlight here: http://paulyanez.com/interactive/index.php/2009/12/embedding-fonts-in-silverlight/ The implementation for Windows Phone is exactly the same. The tutorial uses Expression Blend (which is part of the developer tools download and also free for Windows Phone), which is the simplest, quickest, and easiest way to embed fonts for Silverlight.
Apart from the supported Fonts you can add your on fonts to you project. For example create a folder named Fonts in you project and add you *.TTF files(Font Files). By referring this font files you can resolve your issues.

Resources