Skip to content

Commit f2b29b3

Browse files
authored
Merge pull request #397 from NativeScript/niliev/fonts
add icon fonts section for Image and stretch property
2 parents e783b48 + a200551 commit f2b29b3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@ The example demonstrates, how to use setup the `font-family` property via CSS a
33

44
<snippet id='icon-font-html-def'/>
55
<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-html-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 control 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 streched by measuring the image (or if there is no sizes set, the parent layout in whcih the image is nested).

app/ng-ui-category/icon-fonts/basics/basic.component.html

+11
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,15 @@
1919
<!-- Using IcoMoon-Free.ttf -->
2020
<Label text="&#xe904;" class="ico"></Label>
2121
<!-- << icon-font-html-def -->
22+
23+
<!-- >> icon-font-html-images -->
24+
<!--
25+
In case, when the stretch property is set to aspectFit or aspectFill
26+
the font-sizde will be disreagarderd and the image will take the vailable space
27+
assigned through width/height or through its parent size
28+
29+
Setting the stretch property to none will allow using the font-size property
30+
-->
31+
<Image src="font://&#xf51e;" stretch="none" class="fas"></Image>
32+
<!-- << icon-font-html-images -->
2233
</StackLayout>

0 commit comments

Comments
 (0)