added white-bracket-sizing

svn: r11243
This commit is contained in:
Robby Findler 2008-08-14 17:55:58 +00:00
parent fcabbbf576
commit cb23506ca1
3 changed files with 77 additions and 12 deletions

View File

@ -1,4 +1,10 @@
PLT v4.1 v4.2
- added white-bracket-sizing to control how the brackets
are typeset when rendering a metafunction.
v4.1 (this is the first version that was included in the PLT
distribution. Before this, Redex was in PLaneT).
EXTENSIONS: EXTENSIONS:

View File

@ -674,14 +674,41 @@
(define (open-white-square-bracket) (white-bracket "[")) (define (open-white-square-bracket) (white-bracket "["))
(define (close-white-square-bracket) (white-bracket "]")) (define (close-white-square-bracket) (white-bracket "]"))
#;"\u301a\u301b" ;; white square brackets
;; white-bracket : string -> pict
;; puts two of `str' next to each other to make
;; a `white' version of the bracket.
(define (white-bracket str) (define (white-bracket str)
(let ([inset-amt (let-values ([(left-inset-amt right-inset-amt left-space right-space)
(case (default-font-size) ((white-bracket-sizing) str
[(9 10 11 12) -2] (default-font-size))])
(let ([main-bracket (basic-text str (default-style))])
(inset (refocus (cbl-superimpose main-bracket
(hbl-append (blank left-inset-amt)
(basic-text str (default-style))
(blank right-inset-amt)))
main-bracket)
left-space
0
right-space
0))))
(define white-bracket-sizing
(make-parameter
(λ (str size)
(let ([inset-amt (floor (max 4 (* size 2/5)))])
(cond
[(equal? str "[")
(values inset-amt
0
0
2)]
[else [else
(- (floor (max 2 (* 2 (/ (default-font-size) 10)))))])]) (values 0
(hbl-append (basic-text str (default-style)) inset-amt
(inset (basic-text str (default-style)) inset-amt 0 0 0)))) 2
0)])))))
(define (pink-background p) (define (pink-background p)
(refocus (refocus

View File

@ -1368,6 +1368,38 @@ it. The thunk may be invoked multiple times when rendering a
single reduction relation. single reduction relation.
} }
@defparam[white-bracket-sizing proc (-> string? number? (values number? number? number? number?))]{
This parameter is used when typesetting metafunctions to
determine how to create the @"\u301a\u301b"
characters. Rather than using those characters directory
(since glyphs tend not to be available in PostScript
fonts), they are created by combining two [ characters
or two ] characters together.
The procedure accepts a string that is either @scheme["["]
or @scheme["]"], and returns four numbers. The first two
numbers determine the offset (from the left and from the
right respectively) for the second square bracket, and the
second two two numbers determine the extra space added (to
the left and to the right respectively).
The default value of the parameter is: @schemeblock[
(λ (str size)
(let ([inset-amt (floor (max 4 (* size 2/5)))])
(cond
[(equal? str "[")
(values inset-amt
0
0
2)]
[else
(values 0
inset-amt
2
0)])))]
}
@deftech{Removing the pink background from PLT Redex rendered picts and ps files} @deftech{Removing the pink background from PLT Redex rendered picts and ps files}
When reduction rules, a metafunction, or a grammar contains When reduction rules, a metafunction, or a grammar contains