vendredi 3 mai 2019

Dynamically load front from web to Angular : is it possible?

I need to be able to load fonts from a back-end server to style my text in Angular. I have, stored in variable, the web url of my font (ex: 'website.com/myfont.ttf') and the name (in this case: 'myfont').

I also have a component with a which has to be stylized with this custom font. Notice that my fonts come from a back-end, it has to be perfectly dynamic. After spending hours looking for a solution and testing everything I found (FontFace, WebFontLoader, add-font, ...), I start thinking it may not be possible :(.

To summarize: my Angular app gets a list of fonts from my back-end's API as a JSON. It gets the fonts url on the server and their name. I want to use the font choosen by the user and apply it to some elements (label, div, etc) dynamically.

Thanks !




Aucun commentaire:

Enregistrer un commentaire