Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 3290ab3

Browse files
authored
Merge pull request #1586 from NativeScript/niliev/fonts
docs: Update IcoMoon example + improve FontAwesome example
2 parents 1c7c70b + 41192c4 commit 3290ab3

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

docs/ui/icon-fonts.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,25 @@ In the above example, the `fa-brands-400.ttf` (as downloaded from the FontAwesom
3737
3838
|file name | font name |
3939
|-----------|---------------|
40-
|**fa-solid-900** | Font Awesome 5 Free
41-
|**fa-regular-400** | Font Awesome 5 Free
40+
|**fa-solid-900.ttf** | Font Awesome 5 Free
41+
|**fa-regular-400.ttf** | Font Awesome 5 Free
4242

4343
Notice that in the above example the **file** names are different, but the registered **font** name is the same (use the **Font Book** application on Mac or the **Control Panel Fonts** section on Windows to see the actual font name). While this is no issue on Android, it renders the second font unusable on iOS. To handle similar cases additional CSS font properties, such as for example `font-weight`, must be added.
4444

4545
```CSS
46+
/*
47+
File name: fa-regular-400.ttf
48+
Font name: Font Awesome 5 Free
49+
*/
4650
.far {
4751
font-family: "Font Awesome 5 Free", "fa-regular-400";
4852
font-weight: 400;
4953
}
5054

55+
/*
56+
File name: fa-solid-900.ttf
57+
Font name: Font Awesome 5 Free
58+
*/
5159
.fas {
5260
font-family: "Font Awesome 5 Free", "fa-solid-900";
5361
font-weight: 900;
@@ -62,8 +70,9 @@ Notice that in the above example the **file** names are different, but the regis
6270
<Label text="&#xf108;" class="fa"></Label>
6371
```
6472
```CSS
65-
.fa {
73+
.far {
6674
font-family: "Font Awesome 5 Free", "fa-regular-400";
75+
font-weight: 400;
6776
}
6877
```
6978
{% endnativescript %}
@@ -76,23 +85,28 @@ Notice that in the above example the **file** names are different, but the regis
7685
<Label text="&#xf108;" class="fa"></Label>
7786
```
7887
```CSS
79-
.fa {
88+
.far {
8089
font-family: "Font Awesome 5 Free", "fa-regular-400";
90+
font-weight: 400;
8191
}
8292
```
8393
{% endangular %}
8494

8595
## Icon Fonts via Code-Behind
8696
{% nativescript %}
8797
``` CSS
88-
.icon {
89-
font-family: 'icomoon';
98+
/*
99+
File name: IcoMoon-Free.ttf
100+
Font name: IcoMoon-Free
101+
*/
102+
.ico {
103+
font-family: 'IcoMoon-Free';
90104
font-size: 48;
91105
}
92106

93-
/* only for reference, is NOT working in this example (wrong codes)
107+
/* only for reference, is NOT working in this example (due to wrong glyph codes)
94108
.fa {
95-
font-family: 'FontAwesome', 'fontawesome-webfont';
109+
font-family: "Font Awesome 5 Free", "fa-regular-400";
96110
font-size: 48;
97111
}
98112
*/
@@ -102,7 +116,7 @@ Notice that in the above example the **file** names are different, but the regis
102116
<ListView items="{%raw%}{{ glyphs }}{%endraw%}">
103117
<ListView.itemTemplate>
104118
<StackLayout orientation="horizontal">
105-
<Label text="{%raw%}{{ icon }}{%endraw%}" class="icon"/>
119+
<Label text="{%raw%}{{ icon }}{%endraw%}" class="ico"/>
106120
<Label text="{%raw%}{{ code }}{%endraw%}" />
107121
</StackLayout>
108122
</ListView.itemTemplate>

0 commit comments

Comments
 (0)