shaping is right but mutation is wrong

main
Matthew Butterick 8 years ago
parent cf9ec85868
commit f0ef666b42

@ -53,8 +53,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/layout/LayoutEngine.js
;; Substitute and position the glyphs
(set! glyphs (send this substitute glyphs features script language))
(report/file 'end-sub)
#;(error 'stop)
(report*/file 'end-sub glyphs)
(error 'stop)
(report/file 'ready-position)
(define positions (send this position glyphs features script language))
(report/file 'fired-position)

@ -37,11 +37,12 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTLayoutEngine.js
(define/public (substitute glyphs . _)
(cond
[(· this GSUBProcessor)
(send (· this plan) process (· this GSUBProcessor) (· this glyphInfos))
;; Map glyph infos back to normal Glyph objects
(for/list ([glyphInfo (in-list (· this glyphInfos))])
(send (· this font) getGlyph (· glyphInfo id) (· glyphInfo codePoints)))]
#;(report/file (· this glyphInfos))
(send (· this plan) process (· this GSUBProcessor) (· this glyphInfos))
#;(report/file (· this glyphInfos))
;; Map glyph infos back to normal Glyph objects
(for/list ([glyphInfo (in-list (· this glyphInfos))])
(send (· this font) getGlyph (· glyphInfo id) (· glyphInfo codePoints)))]
[else glyphs]))
(define/public (position glyphs positions . _)

@ -91,15 +91,17 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTProcessor.js
#;(report/file 'ot-proc:applyFeatures-part1)
(define lookups (send this lookupsForFeatures userFeatures))
#;(report/file 'ot-proc:applyFeatures-part2)
(report (length lookups))
(send this applyLookups lookups glyphs advances))
(report/file (length glyphs))
(send this applyLookups lookups glyphs advances)
(report*/file (length glyphs) (length (· this glyphs)))
(· this glyphs))
(define/public (applyLookups lookups glyphs positions)
(set-field! glyphs this glyphs)
(set-field! positions this positions)
#;(report/file 'ot-proc:applyLookups)
(report (for/list ([g glyphs]) (· g id)))
(report (for/list ([g (· this glyphs)]) (· g id)) 'glyph-ids)
(set-field! glyphIterator this (+GlyphIterator glyphs))
(for* ([lookup-entry (in-list lookups)])
@ -109,18 +111,18 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTProcessor.js
(send (· this glyphIterator) reset (· lookup flags))
(while (< (or (· this glyphIterator index) 0) (length (· this glyphs)))
(report 'start-while++++++++++++++++++)
(report/file 'start-while++++++++++++++++++)
(report (length (· this glyphs)) 'glyphs-length-top)
(report (for/list ([g (· this glyphs)]) (· g id)) 'gids-top)
(report (· this glyphIterator index) giterator-idx-top)
(report* feature (· this glyphIterator cur id) (· this glyphIterator cur features))
(report* feature (dict-keys (· this glyphIterator cur features)))
(report (dict-has-key? (· this glyphIterator cur features) feature))
(cond
[(not (dict-has-key? (· this glyphIterator cur features) feature))
(send (· this glyphIterator) next)]
[else
(report/file 'start-lookup-branch=================)
(report* (for/list ([g (· this glyphs)]) (· g id)) (for/list ([g (· this glyphIterator glyphs)]) (· g id)) (for/list ([g glyphs]) (· g id)) (· this glyphIterator index) (· this glyphIterator cur id) (· this glyphIterator peekIndex))
(report 'start-lookup-branch=================)
(report* (for/list ([g glyphs]) (· g id)) (for/list ([g (· this glyphs)]) (· g id)) (for/list ([g (· this glyphIterator glyphs)]) (· g id)) (· this glyphIterator index) (· this glyphIterator cur id) (· this glyphIterator peekIndex))
(for/or ([table (in-list (· lookup subTables))])
(send this applyLookup (· lookup lookupType) table))
(report 'incrementing-iterator-at-bottom)
@ -146,7 +148,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTProcessor.js
(define pos (· this glyphIterator index))
(define glyph (send (· this glyphIterator) increment sequenceIndex))
(define idx 0)
(report*/file (and (pair? sequence) (list-ref sequence idx)) glyph (and glyph (· glyph id)))
#;(report*/file (and (pair? sequence) (list-ref sequence idx)) glyph (and glyph (· glyph id)))
(while (and (< idx (length sequence)) glyph (fn (list-ref sequence idx) (· glyph id)))
(report* 'in-match-loop idx (· glyph id))
@ -164,7 +166,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTProcessor.js
(send this match sequenceIndex sequence (λ (component glyph) (= component glyph)) empty))
(define/public (coverageSequenceMatches sequenceIndex sequence)
(report 'in-coverageSequenceMatches)
#;(report 'in-coverageSequenceMatches)
(send this match sequenceIndex sequence (λ (coverage glyph) (>= (send this coverageIndex coverage glyph) 0))))
(define/public (getClassID glyph classDef)
@ -207,10 +209,10 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTProcessor.js
[else #f]))
(define/public (applyChainingContext table)
(report/file 'otproc:applyChainingContext)
#;(report/file 'otproc:applyChainingContext)
(case (· table version)
[(1)
(report 'case-1)
#;(report 'case-1)
(define index (send this coverageIndex (· table coverage)))
(cond
[(= index -1) #f]
@ -221,7 +223,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTProcessor.js
(send this sequenceMatches (add1 (length (· rule input))) (· rule lookahead))))
(send this applyLookupList (· rule lookupRecords)))])]
[(2)
(report 'case-2)
#;(report 'case-2)
(cond
[(= -1 (send this coverageIndex (· table coverage))) #f]
[else (define index (send this getClassID (· this glyphIterator cur id) (· table inputClassDef)))
@ -234,11 +236,11 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTProcessor.js
(send this classSequenceMatches (add1 (length (· rule input))) (· rule lookahead) (· table lookaheadClassDef))))
(send this applyLookupList (· rule lookupRecords)))])])]
[(3)
(report 'case-3)
#;(report 'case-3)
(and
(report (send this coverageSequenceMatches (- (· table backtrackGlyphCount)) (· table backtrackCoverage)) 'a)
(report (send this coverageSequenceMatches 0 (· table inputCoverage)) 'b)
(report (send this coverageSequenceMatches (· table inputGlyphCount) (· table lookaheadCoverage)) 'c)
(send this coverageSequenceMatches (- (· table backtrackGlyphCount)) (· table backtrackCoverage))
(send this coverageSequenceMatches 0 (· table inputCoverage))
(send this coverageSequenceMatches (· table inputGlyphCount) (· table lookaheadCoverage))
(send this applyLookupList (· table lookupRecords)))]
[else #f]))

@ -9199,6 +9199,8 @@ var LayoutEngine = function () {
// Substitute and position the glyphs
glyphs = this.substitute(glyphs, features, script, language);
console.log("DONE WITH SUBS");
throw new Error("fark");
var positions = this.position(glyphs, features, script, language);
// Let the layout engine clean up any state it might have

@ -0,0 +1,206 @@
'glyph-ids = '(450 480)
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 0
feature = 'numr
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 1
feature = 'numr
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 0
feature = 'dnom
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 1
feature = 'dnom
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 0
feature = 'frac
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 1
feature = 'frac
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 0
feature = 'frac
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 1
feature = 'frac
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 0
feature = 'frac
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 1
feature = 'frac
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #f
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 2
'gids-top = '(450 480)
giterator-idx-top = 0
feature = 'liga
(dict-keys (· this glyphIterator cur features)) = '(clig mark liga curs rclt ccmp locl ltrm kern calt rlig ltra mkmk rvrn)
(dict-has-key? (· this glyphIterator cur features) feature) = #t
'start-lookup-branch================= = 'start-lookup-branch=================
(for/list ((g glyphs)) (· g id)) = '(450 480)
(for/list ((g (· this glyphs))) (· g id)) = '(450 480)
(for/list ((g (· this glyphIterator glyphs))) (· g id)) = '(450 480)
(· this glyphIterator index) = 0
(· this glyphIterator cur id) = 450
(· this glyphIterator peekIndex) = 1
'GSUBProcessor:applyLookup = 4
'--------------------------- = '---------------------------
'ligature-substitution = 'ligature-substitution
lookupType = 4
(· table coverage glyphs) = '(450)
'forker = 0
'starting-index = 0
(send (· table ligatureSets) get (report index 'starting-index)) = '(((compCount . 2) (components 480) (glyph . 731)) ((compCount . 2) (components 514) (glyph . 732)))
(· ligature components) = '(480)
'in-match-loop = 'in-match-loop
idx = 0
(· glyph id) = 480
matched = '(1)
index = 1
characters = '(102 105)
(· ligatureGlyph id) = 731
(for/list ((g (· this glyphs))) (· g id)) = '(450 480)
(· this glyphIterator index) = 0
(for/list ((g (· this glyphs))) (· g id)) = '(731)
(· this glyphIterator index) = 0
'incrementing-iterator-at-bottom = 'incrementing-iterator-at-bottom
(· this glyphIterator cur) = #f
(· this glyphIterator index) = 1
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 1
'gids-top = '(731)
giterator-idx-top = 0
feature = 'calt
(dict-keys (· this glyphIterator cur features)) = '(clig mark rlig curs rvrn rclt ccmp locl ltrm kern calt liga ltra mkmk)
(dict-has-key? (· this glyphIterator cur features) feature) = #t
'start-lookup-branch================= = 'start-lookup-branch=================
(for/list ((g glyphs)) (· g id)) = '(450 480)
(for/list ((g (· this glyphs))) (· g id)) = '(731)
(for/list ((g (· this glyphIterator glyphs))) (· g id)) = '(731)
(· this glyphIterator index) = 0
(· this glyphIterator cur id) = 731
(· this glyphIterator peekIndex) = 1
'GSUBProcessor:applyLookup = 4
'--------------------------- = '---------------------------
'ligature-substitution = 'ligature-substitution
lookupType = 4
(· table coverage glyphs) = '(373 393 450 532 538 598 609 616 625 640 718 2127)
'forker = -1
'incrementing-iterator-at-bottom = 'incrementing-iterator-at-bottom
(· this glyphIterator cur) = #f
(· this glyphIterator index) = 1
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 1
'gids-top = '(731)
giterator-idx-top = 0
feature = 'calt
(dict-keys (· this glyphIterator cur features)) = '(clig mark rlig curs rvrn rclt ccmp locl ltrm kern calt liga ltra mkmk)
(dict-has-key? (· this glyphIterator cur features) feature) = #t
'start-lookup-branch================= = 'start-lookup-branch=================
(for/list ((g glyphs)) (· g id)) = '(450 480)
(for/list ((g (· this glyphs))) (· g id)) = '(731)
(for/list ((g (· this glyphIterator glyphs))) (· g id)) = '(731)
(· this glyphIterator index) = 0
(· this glyphIterator cur id) = 731
(· this glyphIterator peekIndex) = 1
'GSUBProcessor:applyLookup = 6
'GSUBProcessor:applyLookup = 6
'GSUBProcessor:applyLookup = 6
'GSUBProcessor:applyLookup = 6
'incrementing-iterator-at-bottom = 'incrementing-iterator-at-bottom
(· this glyphIterator cur) = #f
(· this glyphIterator index) = 1
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 1
'gids-top = '(731)
giterator-idx-top = 0
feature = 'calt
(dict-keys (· this glyphIterator cur features)) = '(clig mark rlig curs rvrn rclt ccmp locl ltrm kern calt liga ltra mkmk)
(dict-has-key? (· this glyphIterator cur features) feature) = #t
'start-lookup-branch================= = 'start-lookup-branch=================
(for/list ((g glyphs)) (· g id)) = '(450 480)
(for/list ((g (· this glyphs))) (· g id)) = '(731)
(for/list ((g (· this glyphIterator glyphs))) (· g id)) = '(731)
(· this glyphIterator index) = 0
(· this glyphIterator cur id) = 731
(· this glyphIterator peekIndex) = 1
'GSUBProcessor:applyLookup = 6
'GSUBProcessor:applyLookup = 6
'GSUBProcessor:applyLookup = 6
'GSUBProcessor:applyLookup = 6
'incrementing-iterator-at-bottom = 'incrementing-iterator-at-bottom
(· this glyphIterator cur) = #f
(· this glyphIterator index) = 1
'resetting-iterator = 'resetting-iterator
'start-while++++++++++++++++++ = 'start-while++++++++++++++++++ on line 113 in "/Users/MB/git/pitfall/fontkit/ot-processor.rkt"
'glyphs-length-top = 1
'gids-top = '(731)
giterator-idx-top = 0
feature = 'calt
(dict-keys (· this glyphIterator cur features)) = '(clig mark rlig curs rvrn rclt ccmp locl ltrm kern calt liga ltra mkmk)
(dict-has-key? (· this glyphIterator cur features) feature) = #t
'start-lookup-branch================= = 'start-lookup-branch=================
(for/list ((g glyphs)) (· g id)) = '(450 480)
(for/list ((g (· this glyphs))) (· g id)) = '(731)
(for/list ((g (· this glyphIterator glyphs))) (· g id)) = '(731)
(· this glyphIterator index) = 0
(· this glyphIterator cur id) = 731
(· this glyphIterator peekIndex) = 1
'GSUBProcessor:applyLookup = 6
'GSUBProcessor:applyLookup = 6
'incrementing-iterator-at-bottom = 'incrementing-iterator-at-bottom
(· this glyphIterator cur) = #f
(· this glyphIterator index) = 1
'end-sub = 'end-sub on line 56 in "/Users/MB/git/pitfall/fontkit/layout-engine.rkt"
glyphs = (list (object:TTFGlyph ...) (object:TTFGlyph ...)) on line 56 in "/Users/MB/git/pitfall/fontkit/layout-engine.rkt"
. error: stop
>

File diff suppressed because it is too large Load Diff

Binary file not shown.
Loading…
Cancel
Save