Skip to content

Commit 6cb73c8

Browse files
Oblomovpaulusmack
authored andcommitted
gitk: Match ttk fonts to gitk fonts
The fonts set in setoptions aren't consistently picked up by ttk, which uses its own predefined fonts. This is noticeable when switching between using and not using ttk with custom fonts or in HiDPI settings (where the default TTK fonts do _not_ respect tk sclaing). Fix by mapping the ttk fontset to the one used by gitk internally. Signed-off-by: Giuseppe Bilotta <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent d70c034 commit 6cb73c8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

gitk

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,8 @@ proc confirm_popup {msg {owner .}} {
19431943
}
19441944

19451945
proc setoptions {} {
1946+
global use_ttk
1947+
19461948
if {[tk windowingsystem] ne "win32"} {
19471949
option add *Panedwindow.showHandle 1 startupFile
19481950
option add *Panedwindow.sashRelief raised startupFile
@@ -1965,6 +1967,18 @@ proc setoptions {} {
19651967
option add *Listbox.font mainfont startupFile
19661968
}
19671969

1970+
proc setttkstyle {} {
1971+
eval font configure TkDefaultFont [fontflags mainfont]
1972+
eval font configure TkTextFont [fontflags textfont]
1973+
eval font configure TkHeadingFont [fontflags mainfont]
1974+
eval font configure TkCaptionFont [fontflags mainfont] -weight bold
1975+
eval font configure TkTooltipFont [fontflags uifont]
1976+
eval font configure TkFixedFont [fontflags textfont]
1977+
eval font configure TkIconFont [fontflags uifont]
1978+
eval font configure TkMenuFont [fontflags uifont]
1979+
eval font configure TkSmallCaptionFont [fontflags uifont]
1980+
}
1981+
19681982
# Make a menu and submenus.
19691983
# m is the window name for the menu, items is the list of menu items to add.
19701984
# Each item is a list {mc label type description options...}
@@ -12356,6 +12370,10 @@ if {![info exists have_ttk]} {
1235612370
set use_ttk [expr {$have_ttk && $want_ttk}]
1235712371
set NS [expr {$use_ttk ? "ttk" : ""}]
1235812372

12373+
if {$use_ttk} {
12374+
setttkstyle
12375+
}
12376+
1235912377
regexp {^git version ([\d.]*\d)} [exec git version] _ git_version
1236012378

1236112379
set show_notes {}

0 commit comments

Comments
 (0)