git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] gitk: match ttk fonts to gitk fonts

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
Dec 6, 2015, 12:25 UTC
Message-ID
<1449404723-27177-2-git-send-email-giuseppe.bilotta@gmail.com>
In-Reply-To
<1449404723-27177-1-git-send-email-giuseppe.bilotta@gmail.com>

The fonts set in setoptions aren't consistently picked up by ttk, who 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.
---
 gitk | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff --git a/gitk b/gitk
index fcc606e..e04264b 100755
--- a/gitk
+++ b/gitk
@@ -1943,6 +1943,8 @@ proc confirm_popup {msg {owner .}} {
 }
 
 proc setoptions {} {
+    global use_ttk
+
     if {[tk windowingsystem] ne "win32"} {
         option add *Panedwindow.showHandle 1 startupFile
         option add *Panedwindow.sashRelief raised startupFile
@@ -1965,6 +1967,18 @@ proc setoptions {} {
     option add *Listbox.font mainfont startupFile
 }
 
+proc setttkstyle {} {
+    eval font configure TkDefaultFont [fontflags mainfont]
+    eval font configure TkTextFont [fontflags textfont]
+    eval font configure TkHeadingFont [fontflags mainfont]
+    eval font configure TkCaptionFont [fontflags mainfont] -weight bold
+    eval font configure TkTooltipFont [fontflags uifont]
+    eval font configure TkFixedFont   [fontflags textfont]
+    eval font configure TkIconFont    [fontflags uifont]
+    eval font configure TkMenuFont    [fontflags uifont]
+    eval font configure TkSmallCaptionFont [fontflags uifont]
+}
+
 # Make a menu and submenus.
 # m is the window name for the menu, items is the list of menu items to add.
 # Each item is a list {mc label type description options...}
@@ -12356,6 +12370,10 @@ if {![info exists have_ttk]} {
 set use_ttk [expr {$have_ttk && $want_ttk}]
 set NS [expr {$use_ttk ? "ttk" : ""}]
 
+if {$use_ttk} {
+    setttkstyle
+}
+
 regexp {^git version ([\d.]*\d)} [exec git version] _ git_version
 
 set show_notes {}
-- 
2.6.3.659.gfdd8f28
Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 2 of 8 in “gitk spacing/sizing tuning for HiDPI”
  1. 0/2 gitk spacing/sizing tuning for HiDPIGiuseppe Bilotta, Dec 6, 2015
  2. 1/2 gitk: match ttk fonts to gitk fontsGiuseppe Bilotta, Dec 6, 2015
  3. 2/2 gitk: let .bleft.mid widgets 'breathe'Giuseppe Bilotta, Dec 6, 2015
  4. Eric SunshineDec 7, 2015
  5. 1/2 gitk: match ttk fonts to gitk fontsGiuseppe Bilotta, Dec 8, 2015
  6. 2/2 gitk: let .bleft.mid widgets 'breathe'Giuseppe Bilotta, Dec 8, 2015
  7. Paul MackerrasDec 19, 2015
  8. Giuseppe BilottaDec 8, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.