wader / ansisvg

Convert ANSI to SVG
MIT License
89 stars 9 forks source link

Allow loading of external fonts #4

Closed patrislav1 closed 11 months ago

patrislav1 commented 11 months ago

I currently patch ansisvg's output to fix the rendering of Powerline symbols:

ansisvg -fontname "Ubuntu Mono" -fontsize 16 | sed 's?<style>?<style>@import url("https://cdn.jsdelivr.net/gh/wernight/powerline-web-fonts/PowerlineFonts.css");?g'

(I'm a dilettante at web tech, so not sure if this is the right way - but it works)

Wondering if it makes sense to add some kind of option for external fonts (or external CSS in general) to avoid having to patch the generated files.

wader commented 11 months ago

Hey, yeah that would be nice. Any idea how it could be done? some generic argument to prepend text or something more font specific? thinking it would be nice to make it easy to embed a font to not make the svg depend on external resources?

patrislav1 commented 11 months ago

As I said, I'm more of a trial and error person when it comes to web tech - so probably not in a position to advise anything specific here. Yes, it would be nice if the SVG stays self-contained, but OTOH, if I explicitly reference external resources then I can as well put them in the same folder as the generated SVGs - so it's more of a nice-to-have, I guess.

wader commented 11 months ago

Hmm tricky, looking at https://cdn.jsdelivr.net/gh/wernight/powerline-web-fonts/PowerlineFonts.css it does not look trivial to embed as it depend on other resources (in differens paths) and i think you would have to use data: urls to embed? but i could be wrong

Maybe it should be two differente argument, one to add a font file via filsystem path and one to inject extra css?

patrislav1 commented 11 months ago

Yes, sounds good.