Skip to content

Commit aa9a225

Browse files
authored
Merge pull request #147 from NativeScript/niliev/fonts
add section about icon fonts in Image
2 parents 8f5616b + 0445835 commit aa9a225

16 files changed

+47
-9
lines changed

app/ns-ui-category/icon-fonts/basics/article.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/ns-ui-category/icon-fonts/icon-fonts-page.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const ListViewLinksModel = require("../../links-view-model");
22
const link = require("../../link");
33
const navigationLinks = [
4-
new link("Basics", "ns-ui-category/icon-fonts/basics/basics-page"),
5-
new link("Code Behind", "ns-ui-category/icon-fonts/code-behind/code-behind-page")
4+
new link("Usage", "ns-ui-category/icon-fonts/usage/usage-page"),
5+
new link("Tips & Tricks", "ns-ui-category/icon-fonts/tips-and-tricks/tips-and-tricks-page")
66
];
77
const navigationLinksTsc = [
8-
new link("Code Behind", "ns-ui-category/icon-fonts/code-behind/code-behind-ts-page")
8+
new link("Tips & Tricks", "ns-ui-category/icon-fonts/tips-and-tricks/tips-and-tricks-ts-page")
99
];
1010
function onNavigatingTo(args) {
1111
const page = args.object;

app/ns-ui-category/icon-fonts/metadata.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ position: 265
55
slug: icon-fonts
66
previous_url: /icon-fonts
77
---
8+
example-order: usage, tips-and-tricks

app/ns-ui-category/icon-fonts/tips-and-tricks/tips-and-tricksts-page.js

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
The example demonstrates, how to use setup the `font-family` property via CSS and how to define the needed icons via XML.
3+
4+
<snippet id='icon-font-xml-def'/>
5+
<snippet id='icon-font-css-class-def'/>
6+
7+
WIth NativeScript 6 and above, we can use icon fonts with `Image` elements. For that purpose the `font://` prefix is needed to set the icon font code.
8+
9+
<snippet id='icon-font-xml-images'/>
10+
<snippet id='icon-font-css-class-def'/>
11+
12+
>> **Note:** Images have specific stretch options (`none`, `aspectFit`, `aspectFill`). At the same time the icon fonts are having `font-size` which can contorl the size of our font. If you want to set the size of your icon through the `font-size` property then set `stretch` property to `none`. Any other values of the stretch property (including the default one) will cause the icon to be resized by measuring the image (or if there is no sizes set, the parent layout in whcih the image is nested).

app/ns-ui-category/icon-fonts/basics/basics-page.xml renamed to app/ns-ui-category/icon-fonts/usage/usage-page.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525
<!-- << icon-font-xml-def -->
2626

2727
<!-- Using font icons in Images requires the font:// prefix -->
28-
<Image src="font://&#xf019;" class="far"></Image>
28+
<Image src="font://&#xf015;" stretch="none" class="fas"></Image>
29+
30+
<!-- >> icon-font-xml-images -->
31+
<!--
32+
In case, when the stretch property is set to aspectFit or aspectFill
33+
the font-sizde will be disreagarderd and the image will take the vailable space
34+
assigned through width/height or through its parent size
35+
36+
Setting the stretch property to none will allow using the font-size property
37+
-->
38+
<Image src="font://&#xf51e;" stretch="none" class="fas"></Image>
39+
<!-- << icon-font-xml-images -->
2940
</StackLayout>
3041
</Page>

app/ns-ui-widgets-category/tabs/tabs-page.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const ListViewLinksModel = require("../../links-view-model");
22
const link = require("../../link");
3+
34
const navigationLinks = [
45
new link("Usage", "ns-ui-widgets-category/tabs/usage/usage-page"),
56
new link("Theming", "ns-ui-widgets-category/tabs/theming/theming-page"),

0 commit comments

Comments
 (0)