Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot select font weight in XCode Storyboards #13557

Closed
nickdnk opened this issue Jul 16, 2018 · 27 comments
Closed

Cannot select font weight in XCode Storyboards #13557

nickdnk opened this issue Jul 16, 2018 · 27 comments
Labels
Milestone

Comments

@nickdnk
Copy link

nickdnk commented Jul 16, 2018

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

@tagliala
Copy link
Member

tagliala commented Jul 17, 2018

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

@nickdnk
Copy link
Author

nickdnk commented Jul 17, 2018

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.

@antonjazz
Copy link

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

@antonjazz
Copy link

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

@tagliala
Copy link
Member

tagliala commented Jul 24, 2018

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?

@robmadole
Copy link
Member

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

@nickdnk
Copy link
Author

nickdnk commented Aug 16, 2018

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

@antonjazz
Copy link

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?

@tagliala
Copy link
Member

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.

@antonjazz
Copy link

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.

@nickdnk
Copy link
Author

nickdnk commented Aug 29, 2018 via email

@tagliala
Copy link
Member

tagliala commented Aug 29, 2018

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?

@antonjazz
Copy link

antonjazz commented Aug 29, 2018

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".

@nickdnk
Copy link
Author

nickdnk commented Jan 22, 2019

@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.

@tagliala
Copy link
Member

@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 #13900 (comment) ?

@antonjazz
Copy link

Fantastic, @tagliala - looking forward!

@nickdnk
Copy link
Author

nickdnk commented Jan 23, 2019

@tagliala Great :)

@tagliala
Copy link
Member

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

@nickdnk
Copy link
Author

nickdnk commented Jan 23, 2019

@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.

@tagliala
Copy link
Member

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

@tagliala
Copy link
Member

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

@tagliala tagliala added this to the 5.7.0 milestone Jan 28, 2019
@nickdnk
Copy link
Author

nickdnk commented Jan 28, 2019

@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.

@tagliala
Copy link
Member

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

@tagliala
Copy link
Member

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

@nickdnk
Copy link
Author

nickdnk commented Jan 29, 2019

@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.

@tagliala
Copy link
Member

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

@nickdnk
Copy link
Author

nickdnk commented Jan 29, 2019

@tagliala Okay great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants