-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
FontAwesome 5 #776
Merged
Merged
FontAwesome 5 #776
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5340877
FontAwesome5 implementation
hampustagerud 8e789bf
Update README.md
hampustagerud 13e644a
Easier way to use FontAwesome5 Pro
hampustagerud c682035
FontAwesome 5 instructions
hampustagerud a698fe1
Automatic build and upgrading, also added to directory and IconExplorer
hampustagerud 5d2dae1
Buttons and TabBarItems should be working on iOS too now
hampustagerud b144027
Updated build flow
hampustagerud 5c1e203
Upgrading FontAwesome is automatic and occurs locally
hampustagerud 0f9b2a5
Create FontAwesome 5 iconSet with factory
hampustagerud f1ef199
Setup FontAwesome 5 automatically
hampustagerud 8a8a1d1
Bug fixes with FontAwesome 5 loading
hampustagerud 569473f
getImageSource() implementation for FontAwesome 5
hampustagerud 47cece2
Export all types in FontAwesome5 iconSets
hampustagerud 6fd8697
Changed name on FA5Type to FA5Style
hampustagerud 50942b8
Update docs to reflect changes to FontAwesome 5
hampustagerud d952755
Some final iOS fixes for FontAwesome 5 PR
hampustagerud f6d6365
Updated scripts
hampustagerud 6bd1e49
Name changes and minor fixes
hampustagerud 8c3189e
ensureNativeModuleAvailable() in its own file
hampustagerud 7eb5d31
Removed add-font-assets from user binaries
hampustagerud 4d1503a
Edited package.json ends with blank line now
hampustagerud 068dc30
Cleaner code
hampustagerud d8763ee
Docs update
hampustagerud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 103 additions & 1 deletion
104
Examples/IconExplorer/ios/IconExplorer.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# FontAwesome 5 | ||
|
||
FontAwesome 5 is split into three different font files which makes it somewhat | ||
harder to use in some cases. The implemented solution should be fairly | ||
straightforward to use after it has been setup. | ||
Android and iOS handles fonts differently which is why it could be | ||
easily implemented without any additional setup. | ||
|
||
### Table of Content | ||
|
||
* [`Usage`](#usage) | ||
* [`Upgrading to Pro`](#upgrading-to-pro) | ||
|
||
# Usage | ||
|
||
Using the standard icons works just like the standard icons in this library. | ||
|
||
```javascript | ||
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5'; | ||
|
||
const icon = (<FontAwesome5 name={'comments'} />); | ||
``` | ||
|
||
Something special about the FontAwesome5 class is that you can also pass props | ||
to change the style of the icon: | ||
|
||
```javascript | ||
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5'; | ||
|
||
const icon = (<FontAwesome5 name={'comments'} solid />); | ||
const icon = (<FontAwesome5 name={'git'} brand />); | ||
``` | ||
|
||
**Valid types** | ||
|
||
| Type | Description | | ||
| --- | --- | | ||
| **brand** | Uses the Brands font | | ||
| **light** | Uses the Light font (pro) or Regular (Free) | | ||
| **solid** | Uses the Solid font | | ||
|
||
No specified type indicates Regular font. | ||
|
||
Button, TabBarItem etc. works the same way: | ||
|
||
```javascript | ||
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5'; | ||
|
||
const regular_icon_btn = (<FontAwesome5.Button name={'comments'} />); | ||
const solid_icon_btn = (<FontAwesome5.Button name={'comments'} solid />); | ||
``` | ||
|
||
## getImageSource | ||
|
||
```getImageSource``` works a little different due to its native backend and how | ||
the font is separated into different files. Therefore, the enum FA5Style is | ||
defined to help setting the style of the font: | ||
|
||
```javascript | ||
const FA5Style = { | ||
regular: 0, | ||
light: 1, | ||
solid: 2, | ||
brand: 3, | ||
}; | ||
``` | ||
|
||
Use this to select which style the generated image should have: | ||
|
||
```javascript | ||
import FontAwesome5, { FA5Style } from 'react-native-vector-icons/FontAwesome5'; | ||
|
||
FontAwesome5.getImageSource("comments", 30, '#000', FA5Style.solid).then(source => this.setState({ image: source })); | ||
``` | ||
|
||
Not passing a style will result in Regular style. | ||
|
||
# Upgrading to Pro | ||
|
||
You need your FontAwesome npm token which can be obtained by logging into your | ||
account and then access the ```Services``` tab. | ||
|
||
Run ```./node_modules/.bin/fa5-upgrade``` and enter the token when asked to in order to | ||
upgrade to the Pro version. | ||
|
||
## Manually | ||
|
||
If the shell script does not work you can install the Pro version manually. | ||
All you really need to do is adding the Pro fonts to your project, there is | ||
instructions on how to do this in main README.md. | ||
|
||
## Using the Pro version | ||
|
||
Just as easy as using the Free icons, just include the icon set like this: | ||
```javascript | ||
import FontAwesome5Pro from 'react-native-vector-icons/FontAwesome5Pro'; | ||
|
||
const icon = (<FontAwesome5Pro name={'comments'} light/>); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think you should separate this out to its own file just for the factory function. |
||
* FontAwesome5 icon set component. | ||
* Usage: <FontAwesome5 name="icon-name" size={20} color="#4F8EF7" /> | ||
*/ | ||
|
||
import { createFA5iconSet } from './lib/create-icon-set-from-fontawesome5'; | ||
|
||
import glyphMap from './glyphmaps/FontAwesome5Free.json'; | ||
|
||
export { FA5Style } from './lib/create-icon-set-from-fontawesome5'; | ||
|
||
const iconSet = createFA5iconSet(glyphMap, false); | ||
|
||
export default iconSet; | ||
|
||
export const Button = iconSet.Button; | ||
export const TabBarItem = iconSet.TabBarItem; | ||
export const TabBarItemIOS = iconSet.TabBarItemIOS; | ||
export const ToolbarAndroid = iconSet.ToolbarAndroid; | ||
export const getImageSource = iconSet.getImageSource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* FontAwesome5Pro icon set component. | ||
* Usage: <FontAwesome5Pro name="icon-name" size={20} color="#4F8EF7" /> | ||
*/ | ||
|
||
import { createFA5iconSet } from './lib/create-icon-set-from-fontawesome5'; | ||
|
||
import glyphMap from './glyphmaps/FontAwesome5Pro.json'; | ||
|
||
export { FA5Style } from './lib/create-icon-set-from-fontawesome5'; | ||
|
||
const iconSet = createFA5iconSet(glyphMap, true); | ||
|
||
export default iconSet; | ||
|
||
export const Button = iconSet.Button; | ||
export const TabBarItem = iconSet.TabBarItem; | ||
export const TabBarItemIOS = iconSet.TabBarItemIOS; | ||
export const ToolbarAndroid = iconSet.ToolbarAndroid; | ||
export const getImageSource = iconSet.getImageSource; |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think you forgot to also add the font and integrate the library on iOS.