Issue #60 new

Font selection dialogue enhancements

Tomas Pospichal
created an issue

The current font dialogue is trying to filter out the non-fixed-width fonts, which is very nice, since the proportional fonts are far less suitable for use in Vim.

It would be worth considering to go even further with helping people see other relevant information about the fonts on their system right in the dialogue, so that the number of trial-and-error cycles to see how it works in Vim could be reduced.

The list of displayed sizes does not reflect the selected font family. The reason is that the "normal" style goes by many different names. The patch fontdialog_sizes fixes that for many fonts.

Some of the information that would be useful to see when selecting a font family: available styles, or supported scripts (writing systems)

Perhaps also whether the font is scalable (although one can guess from seeing the list of sizes, but that happens only after the font is selected). Maybe the list of families could even be separated into two parts, one having scalable fonts and the other having non-scalable ones.

There is also a problem of fonts with more generic or popular names. Qt reports them in the format "Family [Foundry]", and it seems that Vim will not accept this. I do not know in which form these could be passed to Vim (stripping the "[Foundry]" part is only going to allow to get one of possibly several fonts...).

Sometimes, fonts with glyphs for a certain language are stored as a "style" within a family (especially the generic "fixed" family). It is likely very difficult to select these now. Although the question is how many people actually use these fonts nowadays, and the automatic font substitution mechanism may be dealing with some of these cases.

With 4. and 5., if there is no way around it, maybe GUI could also display those fonts as not really available or problematic or different from the other fonts.

Comments (6)

  1. Tomas Pospichal reporter

    Trying to address 2., it turned out to be more difficult to get a visually satisfactory dialog. Simpler approaches were not pleasing because of resizing that is done to accommodate fonts which support many styles and scripts. The more complicated code is fine from the visual point of view, but uses a few more widgets than I would like.

    The patch fontdialog_info adds a display of information for the selected font family (and contains the first patch), but I have seen some crashes (SEGV or ABRT reported by vim, likely some heap corruption, either just when the font dialog is opening or just when it closed). Since I cannot provoke any aborts with the first patch (which has the same font selection logic already), I am guessing some GUI code is to blame. But I do not see the reason; maybe someone can spot the issue, so I'm posting the code anyway.

  2. equalsraf repo owner

    I've created the tb-issue60 branch for this issue

    • The fontdialog_sizes.patch seems straightforward, and works well on my system.
    • Maybe it is time to start considering using the Qt designer to create the dialog, if it is getting too complex

    Concerning (4), which fonts are you using that cause this? I seem to have none that I can test with.

    If the problem proves too hard. There may be an alternative solution for this issue(4). We currently use the same font names as Vim(for Unix), and lack support for Windows font names(#48). Qt has its own internal string representation for font names, QFont::toString(), that can be used to store font references:

    "Helvetica,12,-1,5,50,0,0,0,0,0"
    

    This is not very user friendly, but it can work to return names from the gui dialog, or for testing purposes. For example:

    :set gfn=qfont:Helvetica,12,-1,5,50,0,0,0,0,0
    
  3. Tomas Pospichal reporter

    Any GUI designer would not help much in obtaining the minimal satisfactory design, which is achieved by that second patch. It is puzzling to me there could be any pointers wandering off, the code is not really manipulating any.

    On my system there are font families Terminal [DEC] and Terminal [Bitstream], as well as Fixed [Misc] and Fixed [Sony]. The "Misc" foundry probably means just no-name/unknown, and has many "styles", including "ja", "ko" and several actual styles.

    In a way, the current font naming (using just spaces as separators) is simple and user friendly. There probably isn't any pressing need for support of Windows names now... but the idea of being able to process several different font-identifying string formats is very good, I would certainly not mind if other Vim implementations tried to do that and spare the user many trials with different combinations of separators, space escapes etc.

    I did not know about the "qfont:..." syntax, that would be a way to request a specific font in situations like 4. or 5. (although rather theoretically, not so much in practice).

  4. Tomas Pospichal reporter

    It seems that I found the reason for the memory corruption causing seg faults (a delete/free mix-up in gui_mch_free_font()), now I no longer have any problems with the dialogue. But I also added comments to the code, removed some overlapping declarations, and made all widgets and layouts class members for now (this could be reduced later when the dialog is closer to final). The new patch fontdialog_info.patch is against tb-issue60 (FontDialog: add styles and scripts info).

  5. equalsraf repo owner

    I've merged the patch an added a few minor fixes of my own.

    This looks almost ready to be merged. What name should I add as the commit author :D?

  6. equalsraf repo owner

    I'm pushing the current dialog into the master branch. Sorry it took me this long, I've been busy for a while here.

    I still have to test against fonts with foundry names.

  7. Log in to comment