Skip to content

Commit

Permalink
Merge pull request #397 from NativeScript/niliev/fonts
Browse files Browse the repository at this point in the history
add icon fonts section for Image and stretch property
  • Loading branch information
tsonevn authored Aug 16, 2019
2 parents e783b48 + a200551 commit f2b29b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/ng-ui-category/icon-fonts/basics/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ The example demonstrates, how to use setup the `font-family` property via CSS a

<snippet id='icon-font-html-def'/>
<snippet id='icon-font-css-class-def'/>

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.

<snippet id='icon-font-html-images'/>
<snippet id='icon-font-css-class-def'/>

>> **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).
11 changes: 11 additions & 0 deletions app/ng-ui-category/icon-fonts/basics/basic.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,15 @@
<!-- Using IcoMoon-Free.ttf -->
<Label text="&#xe904;" class="ico"></Label>
<!-- << icon-font-html-def -->

<!-- >> icon-font-html-images -->
<!--
In case, when the stretch property is set to aspectFit or aspectFill
the font-sizde will be disreagarderd and the image will take the vailable space
assigned through width/height or through its parent size
Setting the stretch property to none will allow using the font-size property
-->
<Image src="font://&#xf51e;" stretch="none" class="fas"></Image>
<!-- << icon-font-html-images -->
</StackLayout>

0 comments on commit f2b29b3

Please sign in to comment.