[go: up one dir, main page]

SVG output: Don't double names with fontnames=svg

An incredibly minor tweak for something I discovered in the course of updating the fontnames documentation. (See graphviz.gitlab.io!725 (comment 2349658198) for details, or simply read on...)

When a graph is rendered to SVG by the core_svg renderer, having the fontnames attribute set to svg will use the chosen font's svg_font_family alias as the font-family name in the resulting <text ...> tags.

Previously, the code was always following the family name with the svg_font_family name as a fallback, meaning that fontnames=svg always caused doubled font-family= attributes in <text ...> tags. (e.g. <text font-family="sans-Serif,sans-Serif">.)

To avoid that redundancy, only output the second (fallback) font family name if it's not the family name.

Note: This doesn't necessarily eliminate ALL redundancy -- if the user's chosen font is sans-serif, for example, then that font's svg_font_family will likely be sans-Serif... but if they're not using fontnames=svg, that may still be output into the SVG code as font-family="sans-serif,sans-Serif".

This change only prevents the redundancy that is guaranteed to occur when family and svg_font_family hold the same string pointer value, not just an equivalent string of characters. (Which is something that can only happen when fontnames=svg.)

Merge request reports

Loading