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

Re: [PATCH] Fix default font scaling

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 16, 2024, 10:30 UTC
Message-ID
<5dd4de8a-255a-4f03-b4d8-fc160b3178e1@kdbg.org>
In-Reply-To
<20240615085345.47278-1-serg.partizan@gmail.com>
Am 15.06.24 um 10:53 schrieb Serhii Tereshchenko:
Show 10 quoted lines
> This fixes font scaling for default fonts, where we don't set font
> sizes explicitly.
> 
> Without this, on 4k monitor with text-scaling-factor configured in Gnome,
> labels, buttons and settings are using very small font sizes. (Probably,
> not just Gnome but anything that sets custom DPI).
> 
> Screenshots here: https://twiukraine.com/@partizan/112619567918546426
> 
> Signed-off-by: Serhii Tereshchenko <serg.partizan@gmail.com>
Thank you. I have adjusted the title to read
  git-gui: fix scaled default fonts
to follow the convention.
Show 17 quoted lines
> ---
>  git-gui.sh | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/git-gui.sh b/git-gui.sh
> index 8bc8892..23dd82d 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -810,6 +810,16 @@ if {[is_Windows]} {
>  ## config defaults
>  
>  set cursor_ptr arrow
> +
> +# For whatever reason, Tk does not apply font scaling to default fonts,
> +# but applies font scaling when setting size explicitly.
> +# Default -size 10 is still 10, when you look at it with `font actual ...`,
> +# but explicitl -size 10 becomes 10 * scale factor.
I fixed this typo: s/explicitl/explict/
> +# So, we need to configure fonts to use their default font sizes, but scaled.
> +foreach font_name [font names] {
> +	font configure $font_name -size [font actual $font_name -size]
> +}

Have you seen https://wiki.tcl-lang.org/page/font+scaling where [font configure ...] instead of [font actual ...] is suggested as a preferable solution? I am not so much into Tcl/Tk that I can judge what is best.

> +
>  font create font_ui
>  if {[lsearch -exact [font names] TkDefaultFont] != -1} {
>  	eval [linsert [font actual TkDefaultFont] 0 font configure font_ui]

My setup does not have a 4k monitor, I run KDE and I do not know if I have changed a DPI setting. For the test, I have removed the [gui] sections from my configurations to ensure that the defaults are used.

Under these conditions, this change does not make a difference in how Git GUI appears. I assume this is the expected outcome, so I take it as a good sign.

The patch is available as
https://github.com/j6t/git-gui.git st/font-scaling-fix
for others to test. I'd appreciate your feedback.
-- Hannes
Previous: Eric SunshineNext: Serhii Tereshchenko
Message 3 of 12 in “Fix default font scaling”
  1. Fix default font scalingSerhii Tereshchenko, Jun 15, 2024
  2. Eric SunshineJun 15, 2024
  3. Johannes SixtJun 16, 2024
  4. Serhii TereshchenkoJun 16, 2024
  5. Johannes SixtJun 20, 2024
  6. Serhii TereshchenkoJun 20, 2024
  7. Johannes SixtJun 20, 2024
  8. Serhii TereshchenkoJun 21, 2024
  9. Johannes SixtJun 23, 2024
  10. serg.partizan@gmail.comJun 23, 2024
  11. serg.partizan@gmail.comJun 23, 2024
  12. Johannes SixtJun 23, 2024

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.