Skip to content

add icon fonts section for Image and stretch property #397

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

Merged
merged 1 commit into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>