adjust workaround for GTK+3 before version 3.22

Adjust a workaround for versions before 3.22 when setting the font for
a control.

GTK+ version 3.22 starts paying attention to whether a font size for a
control is absolute (as opposed to being in points), so the workaround
that was put in place for earlier versions breaks.

In addition, some part of the drawing stack seems to round point sizes
to an integeral size after DPI conversion. Take that rounding into
account when setting the font size in `normal-control-font`.

Closes #1522
This commit is contained in:
Matthew Flatt 2016-12-19 07:17:37 -07:00
parent b7b93e2c1e
commit 5e70534b43
3 changed files with 23 additions and 6 deletions

View File

@ -26,10 +26,14 @@
(when font
(let* ([target-size
(cond
[gtk3?
;; Gtk3 ignores the "size-in-pixels" part of a
;; font spec, so we have to adjust the text size
;; to compensate.
[(and gtk3?
((gtk_get_minor_version) . < . 22))
;; Prior to version 3.22, GTK+3 ignores the
;; "size-in-pixels" part of a font spec, so we have to
;; adjust the text size to compensate.
;; With 3.22 and later, a size in points is effectively
;; rounded to an integer absolute size; the `get-control-font-size`
;; function takes that rounding into account.
(* (send font get-size)
(/ 72.0
(pango_cairo_font_map_get_resolution

View File

@ -116,8 +116,17 @@
(g_free f))))))
default))
(define (get-control-font-size)
(get-control-font (lambda (m) (string->number (cadr m)))
10))
(define s (get-control-font (lambda (m) (string->number (cadr m)))
10))
(cond
[(and gtk3?
((gtk_get_minor_version) . >= . 22))
;; As of version 3.22, a size in points ends up rounded
;; to an integral absolute size for 96 DPI; see also
;; `install-control-font`
(* (round (* s (/ 96.0 72.0))) (/ 72.0 96.0))]
[else s]))
(define (get-control-font-face)
(get-control-font (lambda (m) (car m))
"Sans"))

View File

@ -51,6 +51,8 @@
gdk_screen_get_default
gtk_get_minor_version
;; for declaring derived structures:
_GtkObject
@ -200,6 +202,8 @@
(define-gdk gdk_screen_get_default (_fun -> _GdkScreen))
(define-gtk gtk_get_minor_version (_fun -> _uint))
(define (mnemonic-string orig-s)
(string-join
(for/list ([s (in-list (regexp-split #rx"&&" orig-s))])