|
|
@ -35,23 +35,9 @@
|
|
|
|
[path path]))))))
|
|
|
|
[path path]))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (replace-breaks x)
|
|
|
|
(define (handle-hyphenate q)
|
|
|
|
;; replaces Q-expressions representing breaks
|
|
|
|
|
|
|
|
;; with special typed quads representing breaks.
|
|
|
|
|
|
|
|
;; Because typed quads have their own predicates,
|
|
|
|
|
|
|
|
;; it's faster to find them in wrapping operations
|
|
|
|
|
|
|
|
;; (instead of, say, using `equal?`)
|
|
|
|
|
|
|
|
(map-elements (λ (el)
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
|
|
|
[(assoc el all-breaks) => cdr]
|
|
|
|
|
|
|
|
[else el])) x))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (handle-hyphenate qs)
|
|
|
|
|
|
|
|
;; find quads that want hyphenation and split them into smaller pieces
|
|
|
|
;; find quads that want hyphenation and split them into smaller pieces
|
|
|
|
;; do this before ->string-quad so that it can handle the sizing promises
|
|
|
|
;; do this before ->string-quad so that it can handle the sizing promises
|
|
|
|
(apply append
|
|
|
|
|
|
|
|
(for/list ([q (in-list qs)])
|
|
|
|
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
[(and (quad-ref q :hyphenate) (pair? (quad-elems q)) (andmap string? (quad-elems q)))
|
|
|
|
[(and (quad-ref q :hyphenate) (pair? (quad-elems q)) (andmap string? (quad-elems q)))
|
|
|
|
(for*/list ([str (in-list (quad-elems q))]
|
|
|
|
(for*/list ([str (in-list (quad-elems q))]
|
|
|
@ -61,7 +47,7 @@
|
|
|
|
#:min-right-length 3))]
|
|
|
|
#:min-right-length 3))]
|
|
|
|
[substr (in-list (regexp-match* (regexp (string hyphen-char)) hstr #:gap-select? #t))])
|
|
|
|
[substr (in-list (regexp-match* (regexp (string hyphen-char)) hstr #:gap-select? #t))])
|
|
|
|
(quad-copy q [elems (list substr)]))]
|
|
|
|
(quad-copy q [elems (list substr)]))]
|
|
|
|
[else (list q)]))))
|
|
|
|
[else (list q)]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (string->feature-list str)
|
|
|
|
(define (string->feature-list str)
|
|
|
@ -143,20 +129,20 @@
|
|
|
|
;; apply some default styling attributes.
|
|
|
|
;; apply some default styling attributes.
|
|
|
|
;; These will only be used if the underlying q-expression hasn't specified its own values,
|
|
|
|
;; These will only be used if the underlying q-expression hasn't specified its own values,
|
|
|
|
;; which will naturally override these.
|
|
|
|
;; which will naturally override these.
|
|
|
|
(define the-quad
|
|
|
|
(define q
|
|
|
|
(qexpr->quad (list 'q (list->attrs
|
|
|
|
(qexpr->quad (list 'q (list->attrs
|
|
|
|
:font-family default-font-family
|
|
|
|
:font-family default-font-family
|
|
|
|
:font-size (number->string default-font-size)
|
|
|
|
:font-size (number->string default-font-size)
|
|
|
|
:line-height (number->string (floor (* default-line-height-multiplier default-font-size)))) qexpr)))
|
|
|
|
:line-height (number->string (floor (* default-line-height-multiplier default-font-size)))) qexpr)))
|
|
|
|
(setup-font-path-table! base-dir)
|
|
|
|
(setup-font-path-table! base-dir)
|
|
|
|
(let* ([qs (atomize the-quad
|
|
|
|
(let* ([qs (atomize q
|
|
|
|
#:attrs-proc handle-cascading-attrs
|
|
|
|
#:attrs-proc handle-cascading-attrs
|
|
|
|
#:missing-glyph-action 'fallback
|
|
|
|
#:missing-glyph-action 'fallback
|
|
|
|
#:fallback "fallback"
|
|
|
|
#:fallback "fallback"
|
|
|
|
#:emoji "fallback-emoji"
|
|
|
|
#:emoji "fallback-emoji"
|
|
|
|
#:math "fallback-math"
|
|
|
|
#:math "fallback-math"
|
|
|
|
#:font-path-resolver resolve-font-path!)]
|
|
|
|
#:font-path-resolver resolve-font-path!)]
|
|
|
|
[qs (time-log hyphenate (handle-hyphenate qs))]
|
|
|
|
[qs (time-log hyphenate (apply append (map handle-hyphenate qs)))]
|
|
|
|
[qs (map generic->typed-quad qs)]
|
|
|
|
[qs (map generic->typed-quad qs)]
|
|
|
|
[qs (drop-leading-breaks qs)]
|
|
|
|
[qs (drop-leading-breaks qs)]
|
|
|
|
[qs (insert-first-line-indents qs)])
|
|
|
|
[qs (insert-first-line-indents qs)])
|
|
|
|