Custom Fonts in SVG #452
Replies: 5 comments
-
@exetico any ideas? |
Beta Was this translation helpful? Give feedback.
-
Interesting. Please make a bare minimum example I can use, to speed things up. I will check it hereafter. With that said; I've not checked if there's anything flaky with SVG's and custom fonts, just to point that out. |
Beta Was this translation helpful? Give feedback.
-
Hi @exetico I downloaded the font from: https://www.dafont.com/7segments.font With this I understand that it should work from what I was reading in the different forums. After writing the original post I found a somewhat dirty solution but it worked for me in all browsers except the Android app. I'll add it in the following message CSS File
SVG File
|
Beta Was this translation helpful? Give feedback.
-
The next solution I don't remember where I saw it on a German blog if I remember correctly. It is to add a font_styles.css and loadfonts.js file as a resource that loads the fonts. /local/fonts/loadfonts.js
/local/fonts/font_styles.css
Even so, it still didn't load the fonts. added /local/fonts/loadfonts.js
With this code it works and loads the fonts in the browsers. The only place where the font doesn't load is in the android app of ha. In the browser console I get some warnings. I don't know if this is the correct way to do it or is there a cleaner way to do it? |
Beta Was this translation helpful? Give feedback.
-
Thanks to this link https://stackoverflow.com/questions/41852594/dynamically-load-fonts I have discovered a javaScript function to load the font dynamically and with this method it works in the mobile app too. /local/fonts/loadfonts.js
The warnings came to me because of the .eot, .otf .svg files, which I think should not be compatible. I don't know who uses them either? And if they are necessary I don't know if you can think of a more correct way to do it? I know it's not your problem but it wouldn't be bad if you could load the fonts in an easier way. Thanks for your work, |
Beta Was this translation helpful? Give feedback.
-
Hello, I have a basic knowledge of CSS and SVG and so far I have been able to overcome the problems I have encountered thanks to your forum and the tutorials I have found.
But now I am stuck on a part that seems like it should be simple but I can't get it to work.
I have an SVG with a text with a 7 Segment font.
In the browser I have installed the font is displayed correctly.
But as expected on the rest of the devices that do not have the font it is not displayed correctly.
I have tried adding it in 1001 ways that I found on the internet but none of them seem to work.
or
I've put it in the CSS in the style inside the SVG and even converted the font to base64.
But I can't get it to work
Am I missing something?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions