Prevent #\uFFFF and #\uFFFE from being passed through to Pango

Closes PR 11904
This commit is contained in:
Matthew Flatt 2011-05-08 16:57:07 -06:00
parent 27aa3f7556
commit 02c2c173f2

View File

@ -1198,6 +1198,13 @@
(substring s offset))] (substring s offset))]
[blank? (string=? s "")] [blank? (string=? s "")]
[s (if (and (not draw?) blank?) " " s)] [s (if (and (not draw?) blank?) " " s)]
[s (if (for/or ([c (in-string s)])
(or (eqv? c #\uFFFE) (eqv? c #\uFFFF)))
;; Since \uFFFE and \uFFFF are not supposed to be in any
;; interchange, we must replace them away before passing a
;; string to Pango:
(regexp-replace* #rx"[\uFFFE\uFFFF]" s "\uFFFD")
s)]
[rotate? (and draw? (not (zero? angle)))] [rotate? (and draw? (not (zero? angle)))]
[smoothing-index (case (dc-adjust-smoothing (send font get-smoothing)) [smoothing-index (case (dc-adjust-smoothing (send font get-smoothing))
[(default) 0] [(default) 0]
@ -1725,6 +1732,9 @@
tmp-bm)) tmp-bm))
(def/public (glyph-exists? [char? c]) (def/public (glyph-exists? [char? c])
(and
(not (eqv? c #\uFFFF))
(not (eqv? c #\uFFFE))
(with-cr (with-cr
#f #f
cr cr
@ -1742,7 +1752,7 @@
(and substitute-fonts? (and substitute-fonts?
(install-alternate-face c layout font desc attrs context) (install-alternate-face c layout font desc attrs context)
(zero? (pango_layout_get_unknown_glyphs_count layout)))) (zero? (pango_layout_get_unknown_glyphs_count layout))))
(g_object_unref layout)))))) (g_object_unref layout)))))))
(def/public (get-char-width) (def/public (get-char-width)
(or (with-cr (or (with-cr