public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Serhii Tereshchenko <serg.partizan@gmail.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Fix default font scaling
Date: Sun, 16 Jun 2024 15:37:02 +0300	[thread overview]
Message-ID: <Q1B6FS.FVKOG950Y3UN@gmail.com> (raw)
In-Reply-To: <5dd4de8a-255a-4f03-b4d8-fc160b3178e1@kdbg.org>



On Sun, Jun 16 2024 at 12:30:51 +02:00:00, Johannes Sixt <j6t@kdbg.org> 
wrote:
> Am 15.06.24 um 10:53 schrieb Serhii Tereshchenko:
>>  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.
> 
>>  ---
>>   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/
> 
Thanks!

>>  +# 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.
> 

No, I haven't seen this, but suggested preferable solution doesn't work.

`font configure $font -size` returns negative numbers for me.

According to this
https://tkdocs.com/shipman/fonts.html

it means "size in pixels". And size in pixels does not scale. So, if we 
want fonts to scale with DPI, we should use "points" - and that's what 
`font actual ...` returns (i just hope it returns points, because it 
works for me and scales like points).

I'm also no expert in Tcl/Tk, this just my second time writing patches 
for git-gui :)

Probably, after all this we should change comment to:

# Default Tk fonts are defined in pixels, and they
# does not scale with DPI, here we're converting them
# into points, allowing them to scale just like
# explicitly defined fonts.


>>  +
>>   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.
> 

You can test it, by changing DPI in `~/.Xresources`

`xrdb -query` to see your current DPI, then increase it a little.

```
Xft.dpi: 154
```

`xrdb -merge ~/.Xresources` to apply new scaling.


> 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
> 



  reply	other threads:[~2024-06-16 12:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-15  8:53 [PATCH] Fix default font scaling Serhii Tereshchenko
2024-06-15 16:32 ` Eric Sunshine
2024-06-16 10:30 ` Johannes Sixt
2024-06-16 12:37   ` Serhii Tereshchenko [this message]
2024-06-20 17:24     ` Johannes Sixt
2024-06-20 18:11       ` Serhii Tereshchenko
2024-06-20 22:04         ` Johannes Sixt
2024-06-21  7:18           ` Serhii Tereshchenko
2024-06-23  9:13             ` Johannes Sixt
2024-06-23 10:11               ` serg.partizan
2024-06-23 14:00                 ` serg.partizan
2024-06-23 15:50                   ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Q1B6FS.FVKOG950Y3UN@gmail.com \
    --to=serg.partizan@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox