v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
685 stars 57 forks source link

YAD font selection output for some fonts is confusing #272

Open Sadi58 opened 4 months ago

Sadi58 commented 4 months ago

I use a YAD form in a ZSH shell script which includes --field="Font Name:":FN among others. This outputs the font name and size selected, and works mostly as expected. However, there are some exceptions where YAD seems to get the font name wrong (or at least “incompatible”). For instance, when the user selects “DejaVu Sans Condensed Bold Oblique” from the list displayed by YAD, its output is “DejaVu Sans Bold Oblique Semi-Condensed”. This creates problems in the rest of the script where a CSS style, including “font-family”, “font-stretch”, “font-weight” and “font-style”, is created using this output. The method used for this purpose is based on ImageMagick, in particular the command identify -list font | grep -E '^\s*Font: .*$' | sed -e 's/^\s*Font: \s*//g' -e 's/-Regular//g' | sort -u which lists all available fonts with such properties. For instance, the section for this font is the following:

  Font: DejaVu-Sans-Condensed-Bold-Oblique
    family: DejaVu Sans
    style: Oblique
    stretch: SemiCondensed
    weight: 700
    glyphs: /usr/share/fonts/truetype/dejavu/DejaVuSansCondensed-BoldOblique.ttf

Replacing spaces with hyphens in YAD font name output, and searching it in this list easily gives the values for the CSS style, but some exceptions to the rule as in this example create problems.
Perhaps a workaround can be found by adding some extra commands for such exceptional deviations, but it will require going through a very long list of fonts, and getting their names through YAD (How this can be done without selecting each and every one of hundreds of fonts in that list), comparing this list with ImageMagick’s list, and then figuring out a solution to address such deviations. But I think the real solution would be to get YAD output font names as seen in the list displayed by itself.