Font-awesome: Cannot select font weight in XCode Storyboards

Created on 17 Jul 2018  Â·  27Comments  Â·  Source: FortAwesome/Font-Awesome

Hello

I cannot select font weight in iOS. I am using the latest version of FontAwesome. In XCode I get only the ability to choose the font type, but all three weights just state "Regular". If I toggle between the 3 regulars I can sometimes get it to select either light or solid, but it's very inconsistent.

I did add the fonts correctly - also to Info.plist - and they do work if I set the font directly in code, but it keeps bugging out in storyboards.

Please see attached screenshots. I can only select either Font Awesome 5 Brands or Font Awesome 5 Pro from the font selector. I am not sure if this is a bug with FA or with XCode, but something indicates that XCode gets confused about the available weights.

Fonts:
https://image.ibb.co/bVG5By/Screen_Shot_2018_07_17_at_01_54_19.png
Weights:
https://image.ibb.co/mc5tyd/Screen_Shot_2018_07_17_at_01_49_07.png
Info.plist
https://image.ibb.co/nNRiyd/Screen_Shot_2018_07_17_at_01_52_24.png

bug

All 27 comments

Hi!

Thanks for being part of the Font Awesome Community.

I think this could be an issue on our side.

Maybe it's the same as #13320

PS: make sure you are using the .otf files on desktop

Hello @tagliala

As you can see from the Info.plist screendump, I am using the .otf files :)

I can fix it by manually editing the XML in Storyboards, but it's kind of tedious.

I've been experiencing the same issue. I look forward to learning of any solutions.

I'm thinking that perhaps the problem is the way the fonts are named.
When I get the names via UIFont.fontNames(forFamilyName: "Font Awesome 5 Pro") I get this:

FontAwesome5ProRegular
FontAwesome5ProSolid
FontAwesome5ProLight

Of all the fonts available to my app in iOS, these are the only fonts I see that do not follow the standard naming convention that includes a dash. For instance:

Helvetica-Oblique
Helvetica-BoldOblique
Helvetica
Helvetica-Light
Helvetica-Bold
Helvetica-LightOblique

@tagliala, could this be the problem? Is there a reason why Font Awesome chose to depart from the standard naming convention?

thanks,
Anton

Hi @antonjazz thanks for the detailed feedback

@tagliala, could this be the problem? Is there a reason why Font Awesome chose to depart from the standard naming convention?

it could be. If #13320 doesn't solve this issue, then we may take a look at the naming convention

@robmadole is there a reason for the font name?

@supercodepoet you've messed with XCode and this. Do you have any ideas?

Any news here? This is very annoying when working with XCode.

I was excited to see the release of 5.3 (and 5.3.1)!
I saw "Correct version identifier in OTF and web font files" in the list of fixes and thought that might refer to this issue. Unfortunately the font naming embedded in the .ttf files remains unchanged and the problem has not been addressed.
Why is that? Can anyone shed any light? @tagliala?

Incidentally, the issue exists with both .ttf and .otf versions. @tagliala, you mentioned to be sure to use .otf. Is there a reason not to use the smaller .ttf files instead?

you mentioned to be sure to use .otf. Is there a reason not to use the smaller .ttf files instead?

ttf is optimized for the web. It should be used only by ancient browsers that don't support woff, woff2, eot

For desktop usage, you are supposed to use the .otf file.

For desktop usage, you are supposed to use the .otf file.

This is not for desktop usage; it's for use in an iOS app. Apple gives the option of ttf or otf in iOS and since I don't need any otf features, I thought using ttf would reduce the app's footprint.

@Anton I think he means that web is optimised for speed where downloading the font on each visit plays a role. It doesn’t on iOS, as the number of bytes you have to download extra when downloading the app from App Store is irrelevant.

On 29 Aug 2018, at 23.04, Anton Schwartz <[email protected]notifications@github.com> wrote:

For desktop usage, you are supposed to use the .otf file.

This is not for desktop usage; it's for use in an iOS app. Apple gives the option of ttf or otf in iOS and since I don't need any otf features, I thought using ttf would reduce the app's footprint.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/FortAwesome/Font-Awesome/issues/13557#issuecomment-417105106, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIBYsu3nNh4PcNZxueg4t4_gvlFscEfhks5uVwHGgaJpZM4VR99B.

I think he means that web is optimised for speed where downloading the font on each visit plays a role.

@nickdnk Yes, that's correct. Does Font Awesome 5.3 fix this issue for you?

since I don't need any otf features

@antonjazz but you need a proper font-name. Apparently, the ttf file doesn't need to have that, and this is fine for us, because it is just a fallback for ancient web browsers.

I personally think that in the future we could provide better font files for iOS applications (maybe .otf without ligatures) but we should not encourage the use of .ttf fonts on the desktop (or, in other words, for anything but the web), because that would be an extra feature to maintain.

@robmadole any thoughts?

I think he means that web is optimised for speed where downloading the font on each visit plays a role.

Thanks. I just like the ttf files because together they're less than a third the size of the otf fonts. I always like to make my app small - quick to download/update and respectful of the user's memory. Not a big deal either way; I just won't use .otf unless there's a reason for me to.

but you need a proper font-name. Apparently, the ttf file doesn't need to have that, and this is fine for us, because it is just a fallback for ancient web browsers.

For me, in 5.3 both .ttf and .otf versions show up in iOS named the same way, unchanged from 5.2:

FontAwesome5ProRegular
FontAwesome5ProSolid
FontAwesome5ProLight

whereas standard iOS convention would have them named like other fonts:

FontAwesome5Pro
FontAwesome5Pro-Solid
FontAwesome5Pro-Light

It would seem that the reason Xcode continues to name all three fonts "Regular" is that it considers any font name without a hyphen to be the Regular face. This is borne out by all the other iOS fonts I see listed. If Xcode sees a hyphen in the name, it uses the text following the hyphen in place of "Regular".

@tagliala What feedback are you waiting for here (noticing the label)? It seems the obvious solution is to rename the font files. It's not fixed in the newest version because the font names remain the same. I just tested 5.6.

@nickdnk "waiting for feedback" is a generic label, I'm using it also when we are waiting for internal feedback.

Anyway, this should be fixed in the upcoming 5.7.0 release.

Could you please a look at https://github.com/FortAwesome/Font-Awesome/issues/13900#issuecomment-451515322 ?

Fantastic, @tagliala - looking forward!

@tagliala Great :)

@nickdnk do you think that change will solve this issue?

@tagliala If only the .ttf files (which I don't use for desktop) are modified, then no. I can't really decipher from the other thread if that's the case. I'm not expert on this, so I can't really say for sure.

@nickdnk let's wait for 5.7.0 release and see what happens

@nickdnk Font Awesome 5.7.0 has been just released. Could you please take a look?

@tagliala

It has been fixed with regards to selecting the correct font. It now gives the option between Light, Regular and Solid instead of 3x Regular.

However, it's not a drop-in replacement. As we know, the fonts used to be called:

FontAwesome5ProLight

but are now instead called

FontAwesome5Pro-Light

So now your storyboards and .xib files reference the wrong font. This was somewhat expected, but causes more trouble than I had anticipated. Obviously every icon now has a question mark instead of the icon, and if you try to manually salvage the situation, your XML files will go from this:

<array key="Font Awesome 5 Pro-Light-300.otf">
            <string>FontAwesome5ProLight</string>
</array>

to this:

<array key="Font Awesome 5 Pro-Light-300.otf">
            <string>FontAwesome5Pro-Light</string>
            <string>FontAwesome5ProLight</string>
</array>

Which does not look promising. XCode crashed several times for me when I tried to fix this, so what I ended up doing was a git revert so every file was unchanged, then I replaced the font files (the file names have not changed, so no trouble there with Info.plist or anything) and did a search/replace in the root of my project for

FontAwesome5ProLight -> FontAwesome5Pro-Light (and the 3 other fonts)

Which finds this string in a lot of places. After I opened XCode I still had question marks, but when running the app everything looked good. I did a clean/build and restarted XCode again, and now I have my icons back - and I can select the weight correctly now.

So, procedure:

  1. Don't open XCode.
  2. Replace the font files.
  3. Search/replace all old incorrect strings. I just did a replace all because I'm pretty confident the string won't match anything it shouldn't. I used PHPStorm for this but I suppose any editor will do as we're just editing XML files.
  4. Start XCode; clean build (perhaps clear derived data) and restart XCode.

And obviously you'll also replace any reference to the fonts used in code with the above search/replace, as you should.

@nickdnk thanks for the feedback and for the step-by-step guide to fix this

Closing here, but feel free to comment if the original issue has not been fixed and I will reopen

@tagliala Sure, but you should probably include this explanation in your 5.7.0 release notes and warn people that they cannot seamlessly upgrade if using the icons in XCode. I suppose Android Studio will suffer from similar problems.

Your changelog states that it's been fixed for TTF files, but this change affects OTF files as well.

but you should probably include this explanation in your 5.7.0 release notes and warn people that they cannot seamlessly upgrade if using the icons in XCode

Sure, we did that

https://github.com/FortAwesome/Font-Awesome/blob/master/UPGRADING.md#otf-and-ttf-files

@tagliala Okay great :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marceloverdijk picture marceloverdijk  Â·  163Comments

roysbailey picture roysbailey  Â·  170Comments

joefusaro picture joefusaro  Â·  170Comments

QuincyLarson picture QuincyLarson  Â·  308Comments

open2 picture open2  Â·  178Comments