Skip to content

Commit

Permalink
Merge pull request alexdrone#53 from potsky/master
Browse files Browse the repository at this point in the history
Fix wrong substring value
  • Loading branch information
alexdrone committed Oct 26, 2015
2 parents 1d5645e + 34ea848 commit 3ef4db5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
45 changes: 45 additions & 0 deletions README.md
Expand Up @@ -42,6 +42,51 @@ It is possible to use one the font-awesome icon as a default placeholder for an
imageView.image = nil;
[imageView setDefaultIconIdentifier:@"fa-github"];


Troubleshooting
--------------------

### Some icons are not available on some devices

Keep in mind that if you have installed the FontAwesome font in your iOS system (with [InstaFont](https://itunes.apple.com/us/app/instafont-install-any-new/id1020299046) for example), the embedded font in your App will not be used! So if your system FontAwesome font is v4.2, you will never be able to display icons from v4.3 and v4.4 for example from the embedded font.

Two solutions :

1. Remove the font profile from your iOS device
2. Rename the Postscript name of file `FontAwesome.ttf` with a tool like [ttx](https://github.com/behdad/fonttools/) for example and use the new name in `NSString+FontAwesome.h`

Here is the step by step for second solution :

- Install fonttools
```
git clone https://github.com/behdad/fonttools.git ;
cd fonttools/
sudo python setup.py install
```

- Convert the `FontAwesome.ttf` file to `ttx` format
```
cd your_app/Pods/FontAwesome+iOS/Resources/
ttx FontAwesome.ttf
```

- Replace all occurence of `FontAwesome` with `FontAwesome440` for example in `ttx` file and save

- Convert back `ttx` font to `ttf`
```
ttx FontAwesome.ttx
mv FontAwesome.ttf FontAwesome.ttf.orig
mv FontAwesome#1.ttf FontAwesome.ttf
```

- In file `NSString+FontAwesome.h`, change font Postscript name :
```
static NSString *const kFontAwesomeFamilyName = @"FontAwesome440";
```

- Build, run and dance


License
-------------------

Expand Down
4 changes: 2 additions & 2 deletions UIImage+FontAwesome.m
Expand Up @@ -57,7 +57,7 @@ +(UIImage*)imageWithIcon:(NSString*)identifier backgroundColor:(UIColor*)bgColor

//// Abstracted Attributes
NSString* textContent = identifier;
if (identifier.length > 3 && [[identifier substringToIndex:2] isEqualToString:@"fa-"]) {
if (identifier.length > 3 && [[identifier substringToIndex:3] isEqualToString:@"fa-"]) {
textContent = [NSString fontAwesomeIconStringForIconIdentifier:identifier];
}

Expand Down Expand Up @@ -106,7 +106,7 @@ +(UIImage*)imageWithIcon:(NSString*)identifier backgroundColor:(UIColor*)bgColor

//// Abstracted Attributes
NSString* textContent = identifier;
if (identifier.length > 3 && [[identifier substringToIndex:2] isEqualToString:@"fa-"]) {
if (identifier.length > 3 && [[identifier substringToIndex:3] isEqualToString:@"fa-"]) {
textContent = [NSString fontAwesomeIconStringForIconIdentifier:identifier];
}

Expand Down

0 comments on commit 3ef4db5

Please sign in to comment.