I am currently in the process of developing an app using Ionic 2 and I want to incorporate a custom font called Quicksand.
Here is how my folder structure looks:
src
|
|-app
| |
| -app
| | |
| | -app.scss
| |
| -pages
| |
| -assets
| | |
| | -img
| | |
| | -fonts
| | | |
| | | -Quicksand-Bold.ttf
Within my app.scss
file, I have included the following code to ensure the font is accessible across all pages:
@font-face {
font-family: 'Quicksand-Bold';
font-style: normal;
font-weight: 300;
src: local('Quicksand-Bold'), local('Quicksand-Bold'), url("../assets/fonts/Quicksand-Bold.ttf") format('woff2');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Quicksand-Bold';
font-style: normal;
font-weight: 300;
src: local('Quicksand-Bold'), local('Quicksand-Bold'), url("../assets/fonts/Quicksand-Bold.ttf") format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
By referencing it as font-family: Quicksand-Bold
, I can use the font throughout the app.
This setup works without any issues on Android and on browsers, but there seems to be a problem with iOS.
Prior to this, I encountered a similar issue with:
background: url('../assets/img/background.jpg')
This specific URL caused my iOS app to crash. To work around this, I had to create a div
element with the image designated as the background and position it accordingly.
It appears that the same issue may be occurring here when specifying the path for
url("../assets/fonts/Quicksand-Bold.ttf")
where iOS is unable to locate the specified path for some reason.