fontsize & baseline

main
Matthew Butterick 7 years ago
parent 1b361f1f68
commit 87c921550e

@ -32,7 +32,8 @@
(unitsPerEm (openSync p)))
(define (fontsize q)
(hash-ref (attrs q) 'fontsize 0))
(define val (hash-ref (attrs q) 'fontsize 0))
((if (number? val) values string->number) val))
(define/contract (anchor->point q anchor)

@ -1,3 +1,3 @@
#lang quad/typewriter
◊quad[#:link "http://beautfifulracket.com"]{An expression that} is not a value can ◊quad[#:fontsize "22"]{always} ◊quad[#:fontsize "7"]{be partitioned} into two parts: a redex, which is the part that changed in a single-step simplification (highlighted), and the continuation, which is the evaluation context surrounding an expression. In (- 4 (+ 1 1)), the redex is (+ 1 1), and the continuation is (- 4 []), where [] takes the place of the redex. That is, the continuation says how to "continue" after the redex is reduced to a value."
◊quad[#:link "http://beautfifulracket.com"]{An expression that} is not a value can ◊quad[#:fontsize "22"]{always} certainly ◊quad[#:fontsize "7"]{be partitioned} into two parts

@ -1,8 +1,12 @@
#lang debug br/quicklang
(require racket/promise racket/list sugar/list sugar/debug "quad.rkt" "atomize.rkt" "break.rkt" "qexpr.rkt" "generic.rkt" "position.rkt")
(require pitfall/document)
(require hyphenate racket/runtime-path pollen/unstable/typography pollen/tag)
(provide (rename-out [mb #%module-begin]) (except-out (all-from-out br/quicklang) #%module-begin))
(define-runtime-path fira "fira.ttf")
(define soft-break? (λ (q) (and (quad? q) (memv (car (elems q)) '(#\space #\- #\u00AD)))))
(struct $shim $quad () #:transparent)
(struct $char $quad () #:transparent)
@ -10,12 +14,13 @@
(define char-sizes (make-hasheqv))
(define (charify q)
($char (hash-set* (attrs q)
'in 'bi
'out 'bo
'in 'nw
'out 'ne
'font fira
'size (hash-ref! char-sizes (car (elems q))
(λ ()
(send util-doc fontSize (string->number (hash-ref (attrs q) 'fontsize "12")))
(send util-doc font "Courier")
(send util-doc font fira)
(list
(send util-doc widthOfString (apply string (elems q)))
(send util-doc currentLineHeight))))
@ -102,12 +107,9 @@
(position ($doc (hasheq 'origin '(36 36)) (page-wrap (line-wrap (map charify (atomize qarg)) line-width) lines-per-page))))
(require hyphenate racket/runtime-path pollen/unstable/typography pollen/tag)
(provide quad)
(define quad (default-tag-function 'quad))
(define-runtime-path fira "fira.ttf")
(define-macro (mb . ARGS)
(with-pattern ([PS (syntax-property #'ARGS 'ps)])
#'(#%module-begin
@ -120,7 +122,7 @@
(send* doc
[pipe (open-output-file PS #:exists 'replace)]
[registerFont "Fira" (path->string fira)]
[font "Courier"]
[font "Fira"]
[fontSize 12])
(draw q doc)
(send doc end))

Loading…
Cancel
Save