Deficiencies in Fl_SVG_Image

48 views
Skip to first unread message

pvr...@btinternet.com

unread,
Oct 4, 2026, 9:31:10 AMOct 4
to fltk.general
I know these are documented, but are they going to be addressed?

I have downloaded flag image files from a couple of github repos (flag-icons and country-flags) and the US flag in both these will not render properly. The are no stars on the Stars and Stripes. The Chinese flag also does not draw properly. I initially thought that it was because I was trying to draw them onto too small a widget (66x50px) but after an afternoon messing about rasterising them into a large image and then copying that onto a small one with hardly any success I saw the documented deficiencies. 

I have implemented a work-round by converting the SVG files to a 300px high PNG files and loading these into my app. But this may look messy if I ever want to blow the images up greater than 300 px high. Also I lose the benefit of scalability that SVG gives.

As an aside the Guam flag in the country-flags is very large (several hundred thousand pixels wide and high as the design is very intricate) and running normalize() on the raw image raised an exception. Maybe there should be some bound checking?

I attach the various SVG files  of concern.

Regards 
Phil Rose,


gu.svg
us.svg
us.svg
cn.svg

Matthias Melcher

unread,
Oct 4, 2026, 10:52:05 AMOct 4
to fltk.general
I am not sure what the other core devs will say. I'll try to give some background.

FLTK uses and links NanoSVG. So the same limits that apply to NanoSVG apply to FLTK's sig support as well. We do update from the original source regularly, and we do minor adaptations for compatibility. We do not plan to add features to NanoSVG. We try to keep FLTK fast and light.

There are three things that come spontaneously to my mind to work around this. The first one, just load a png or inline one, you already tried. If you want to stick with vector file, just link a different SVG interpreter. There are several libraries out there, and you can import the result using RGB. The third one will give mixed results, depending on the resolution of the target machine: use the commands in the SVG file and map them direct;y to FLTK graphics calls. This requires a little bit of coding, but FLTK rendering call include lines, loops and arbitrary filled areas, which is enough to draw any flag that does;t require shading.

pvr...@btinternet.com

unread,
Oct 4, 2026, 11:35:44 AMOct 4
to fltk.general
Thanks Matthias.

I'll stick a note in my to-do list to look at other interpreters. 

Regards Phil.

From: 'Matthias Melcher' via fltk.general <fltkg...@googlegroups.com>
Sent: Sunday, October 4, 2026 3:52 PM
To: fltk.general <fltkg...@googlegroups.com>
Subject: [fltk.general] Re: Deficiencies in Fl_SVG_Image
 
I am not sure what the other core devs will say. I'll try to give some background.

FLTK uses and links NanoSVG. So the same limits that apply to NanoSVG apply to FLTK's sig support as well. We do update from the original source regularly, and we do minor adaptations for compatibility. We do not plan to add features to NanoSVG. We try to keep FLTK fast and light.

There are three things that come spontaneously to my mind to work around this. The first one, just load a png or inline one, you already tried. If you want to stick with vector file, just link a different SVG interpreter. There are several libraries out there, and you can import the result using RGB. The third one will give mixed results, depending on the resolution of the target machine: use the commands in the SVG file and map them direct;y to FLTK graphics calls. This requires a little bit of coding, but FLTK rendering call include lines, loops and arbitrary filled areas, which is enough to draw any flag that does;t require shading.

--
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/uxZlZOlzFHc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/f28eb7aa-fee5-4501-8377-7f612266e54bn%40googlegroups.com.

Greg Ercolano

unread,
Oct 4, 2026, 4:45:54 PMOct 4
to fltkg...@googlegroups.com

On 10/4/26 06:31, 'pvr...@btinternet.com' via fltk.general wrote:

I know these are documented, but are they going to be addressed?
[..]
I attach the various SVG files  of concern.

    As Matthias wrote, FLTK only supports the nanosvg format, a subset of svg, so it only
    supports specific features.

    I asked AI what programs can be used to output SVG files that nanosvg supports;
    see the results, YMMV:

pvr...@btinternet.com

unread,
Oct 5, 2026, 2:56:27 AMOct 5
to fltkg...@googlegroups.com

From: 'Matthias Melcher' via fltk.general <fltkg...@googlegroups.com>
Sent: Sunday, October 4, 2026 3:52 PM
To: fltk.general <fltkg...@googlegroups.com>
Subject: [fltk.general] Re: Deficiencies in Fl_SVG_Image
 

There are three things that come spontaneously to my mind to work around this. The first one, just load a png or inline one, you already tried. If you want to stick with vector file, just link a different SVG interpreter. There are several libraries out there, and you can import the result using RGB. The third one will give mixed results, depending on the resolution of the target machine: use the commands in the SVG file and map them direct;y to FLTK graphics calls. This requires a little bit of coding, but FLTK rendering call include lines, loops and arbitrary filled areas, which is enough to draw any flag that does;t require shading.

I found a library called "lunasvg" and it works a treat. Not well documented but eventually sussed it.

Regards Phil.
Reply all
Reply to author
Forward
0 new messages