I’m trying to use a custom font in a single Component.
I have .eot, .woff, .otf files etc but I don’t know where in which folder I should put them,
and how to setup css/scss so that the component template has access to the font.
Preferable I would like to put font and related css in the component folder (not application-wide)
so that it would be easily reusable.
I found some information about custom fonts but that was mostly ionic 1 and/or application-wide.
Concrete: suppose I have MyFont.eot, MyFont.woff etc. that I want to use in MyComponent.
Thanks for the link, I got it working!
(actually by copying and amending the style roboto.scss with the font-face src on one line…)
But
I find it counterintuitive to add something in the ‘build’ folder manually. I would expect this folder to be populated automatically based on (re)sources in app, and even possibly be erased by a clean target.
The proposed solution is still application-wide. I was looking for a way to “embed” the font in a single component, making it easy to reuse that in another project. Don’t know if that’s possible.
Hello nilton_felicio, you are brazilian? Your video is very good, thank you for sharing. When I run the ionic serves, the source appears good, but when I put in the device, it does not appear. Would you help me? Thanks in advance.
Everything here sounds more complicated than it needs to be. Maybe this is a new way to do it, but here’s how I change the font globally from the default Helvetica Neue.
All of this in my variables.scss. Place the ttf in src/assets/...
@font-face {
font-family: Source Sans Pro;
src: url("../assets/fonts/Source_Sans_Pro/SourceSansPro-Regular.ttf");
}
$font-family-ios-base: 'Source Sans Pro';
$font-family-md-base: 'Source Sans Pro';
$font-family-wp-base: 'Source Sans Pro';
Works when I do ionic build, and send to Ionic View.