racket/draw: fix font metrics versus transformations
For a font with 'aligned hinting, the font map caches metric information that depends on the destination transformation, at least on Windows. Make the font-map cache sensitive to the destination's current transformation. This bug was exposed by support for DPI-aware GUIs on Windows, but the problem was more general. original commit: 9ee2bd9b6086c696c2be8f01a07db754e4406312
This commit is contained in:
parent
e9b6c166a9
commit
dd3dfc6617
|
@ -183,8 +183,13 @@
|
|||
|
||||
(define/override (init-cr-matrix cr)
|
||||
(unless (= backing-scale 1.0)
|
||||
(cairo_scale cr backing-scale backing-scale))
|
||||
(cairo_scale cr backing-scale backing-scale))
|
||||
(super init-cr-matrix cr))
|
||||
|
||||
(define/override (init-effective-matrix mx)
|
||||
(unless (= backing-scale 1.0)
|
||||
(cairo_matrix_scale mx backing-scale backing-scale))
|
||||
(super init-effective-matrix mx))
|
||||
|
||||
(define/override (reset-config s)
|
||||
(set! backing-scale s)
|
||||
|
|
37
pkgs/gui-pkgs/gui-test/tests/gracket/font-maps.rkt
Normal file
37
pkgs/gui-pkgs/gui-test/tests/gracket/font-maps.rkt
Normal file
|
@ -0,0 +1,37 @@
|
|||
#lang racket
|
||||
(require racket/draw)
|
||||
|
||||
;; Check for pollution of font metrics from differently
|
||||
;; scaled contexts.
|
||||
|
||||
(define font (make-font #:face "Times"))
|
||||
|
||||
;; Running `go` might affect the result of `go2`
|
||||
(define (go)
|
||||
(define bm (make-bitmap 1 1))
|
||||
(send (send bm make-dc) get-text-extent
|
||||
"Extra regexp"
|
||||
font
|
||||
#t))
|
||||
|
||||
;; `go2` is like `go`, but for a different scale
|
||||
(define (go2)
|
||||
(define bm2 (make-platform-bitmap 1 1))
|
||||
(define dc (send bm2 make-dc))
|
||||
(send dc scale 1.25 1.25)
|
||||
(send dc get-text-extent
|
||||
"Extra regexp"
|
||||
font
|
||||
#t))
|
||||
|
||||
;; Running `go2` again in a separate place might produce
|
||||
;; results unaffected by `go`:
|
||||
(define (go2/p)
|
||||
(place pch (place-channel-put pch (call-with-values go2 list))))
|
||||
|
||||
(module+ test
|
||||
(call-with-values go void)
|
||||
(define l1 (call-with-values go2 list))
|
||||
(define l2 (sync (go2/p)))
|
||||
(unless (equal? l1 l2)
|
||||
(error 'different "~s ~s" l1 l2)))
|
Loading…
Reference in New Issue
Block a user