RazrFalcon / resvg

An SVG rendering library.
Mozilla Public License 2.0
2.74k stars 220 forks source link

Increase local fonts priority (resvg.exe) #771

Open Dimon-II opened 3 months ago

Dimon-II commented 3 months ago

Local fonts may contain a modified version of a font installed in the system. It makes sense to use local fonts first, without refusing to load system fonts.

main.rs
...
fn load_fonts

Change the call sequence

fontdb.load_system_fonts(); and

    for path in &args.font_dirs {
        fontdb.load_fonts_dir(path);
    ...
RazrFalcon commented 3 months ago

I don't think fontdb cares about fonts order at the moment. Will think about it.

Dimon-II commented 3 months ago

As far as I understand, the first loaded system font of the same name either prevents the local font from loading, or when selecting a font by name, it appears first.

RazrFalcon commented 3 months ago

Technically, having the same font family twice is already a bug. But checking for uniqueness would be expensive, therefore we do not do this.

I will think about a proper solution.

Dimon-II commented 3 months ago

I encountered this situation during testing colored SVG icons font. I wanted to have a local version of the font having game icons aligned with the text. When working with resvg.dll, I changed the font loading order. It seems to me that this is a logical option for an executable file as well.