Tk Source Code

View Ticket
Login
Ticket UUID: 8277e1a9063136d26e31053d643a95622e5e76c4
Title: tk fontchooser out of sync with dynamically loaded fonts - Linux only
Type: Bug Version: 8.6.5
Submitter: anonymous Created on: 2017-08-31 22:32:19
Subsystem: 99. Other Assigned To: fvogel
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2017-09-24 14:51:07
Resolution: Fixed Closed By: fvogel
    Closed on: 2017-09-24 14:51:07
Description:
On Linux, [tk fontchooser] loads the list of fonts only the first time it is called.
If we dynamically add fonts (see wiki.tcl.tk/extrafonts), these new fonts won't be listed by fontchooser.
(fonts added *before* the first invocation of fontchooser, will be listed).

Note that the [font families] command correctly lists the added fonts.
This bug is not present on Windows.
Given that on Linux fontchooser is implemented as a pure tcl megawidget, I simply patched it by adding a 'refresh'
        set S(fonts) [lsort -dictionary [font families]]
within proc ::tk::fontchooser::Show
This is not very efficient (about 0.4 secs ... more if you have a lot of fonts) but it's still accettable. An alternative solution could be to provide a "tk fontchooser refresh" command.
User Comments: fvogel added on 2017-09-24 14:51:07:
Merged to core-8-6-branch and trunk.

fvogel added on 2017-09-13 21:09:00:

I have tested the proposed patch on Linux with package 'extrafont'.

I have found an issue in the patch and fixed it, see [f54b8cfc].


fvogel added on 2017-09-03 18:24:06:

I have committed a fix proposal following your suggestion, see branch bug-8277e1a906.

I didn't notice any measurable performance penalty (Linux Debian 8, with [llength [font families]] returning 63 on my system).

I didn't use the -unique flag because the original setup of the fontchooser does not do so neither.


bll added on 2017-09-01 11:46:02:
I'm using a modified version, and I also have -nocase -unique as sort options.
The -nocase is probably not necessary.

% package require Tk
8.6.7
% set x [llength [lsort [font families]]]
143
% set y [llength [lsort -unique [font families]]]
132