shaping is right but mutation is wrong

main
Matthew Butterick 7 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 ;; Substitute and position the glyphs
(set! glyphs (send this substitute glyphs features script language)) (set! glyphs (send this substitute glyphs features script language))
(report/file 'end-sub) (report*/file 'end-sub glyphs)
#;(error 'stop) (error 'stop)
(report/file 'ready-position) (report/file 'ready-position)
(define positions (send this position glyphs features script language)) (define positions (send this position glyphs features script language))
(report/file 'fired-position) (report/file 'fired-position)

@ -37,11 +37,12 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTLayoutEngine.js
(define/public (substitute glyphs . _) (define/public (substitute glyphs . _)
(cond (cond
[(· this GSUBProcessor) [(· this GSUBProcessor)
(send (· this plan) process (· this GSUBProcessor) (· this glyphInfos)) #;(report/file (· this glyphInfos))
(send (· this plan) process (· this GSUBProcessor) (· this glyphInfos))
;; Map glyph infos back to normal Glyph objects #;(report/file (· this glyphInfos))
(for/list ([glyphInfo (in-list (· this glyphInfos))]) ;; Map glyph infos back to normal Glyph objects
(send (· this font) getGlyph (· glyphInfo id) (· glyphInfo codePoints)))] (for/list ([glyphInfo (in-list (· this glyphInfos))])
(send (· this font) getGlyph (· glyphInfo id) (· glyphInfo codePoints)))]
[else glyphs])) [else glyphs]))
(define/public (position glyphs positions . _) (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) #;(report/file 'ot-proc:applyFeatures-part1)
(define lookups (send this lookupsForFeatures userFeatures)) (define lookups (send this lookupsForFeatures userFeatures))
#;(report/file 'ot-proc:applyFeatures-part2) #;(report/file 'ot-proc:applyFeatures-part2)
(report (length lookups)) (report/file (length glyphs))
(send this applyLookups lookups glyphs advances)) (send this applyLookups lookups glyphs advances)
(report*/file (length glyphs) (length (· this glyphs)))
(· this glyphs))
(define/public (applyLookups lookups glyphs positions) (define/public (applyLookups lookups glyphs positions)
(set-field! glyphs this glyphs) (set-field! glyphs this glyphs)
(set-field! positions this positions) (set-field! positions this positions)
#;(report/file 'ot-proc:applyLookups) #;(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)) (set-field! glyphIterator this (+GlyphIterator glyphs))
(for* ([lookup-entry (in-list lookups)]) (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)) (send (· this glyphIterator) reset (· lookup flags))
(while (< (or (· this glyphIterator index) 0) (length (· this glyphs))) (while (< (or (· this glyphIterator index) 0) (length (· this glyphs)))
(report 'start-while++++++++++++++++++) (report/file 'start-while++++++++++++++++++)
(report (length (· this glyphs)) 'glyphs-length-top) (report (length (· this glyphs)) 'glyphs-length-top)
(report (for/list ([g (· this glyphs)]) (· g id)) 'gids-top) (report (for/list ([g (· this glyphs)]) (· g id)) 'gids-top)
(report (· this glyphIterator index) giterator-idx-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)) (report (dict-has-key? (· this glyphIterator cur features) feature))
(cond (cond
[(not (dict-has-key? (· this glyphIterator cur features) feature)) [(not (dict-has-key? (· this glyphIterator cur features) feature))
(send (· this glyphIterator) next)] (send (· this glyphIterator) next)]
[else [else
(report/file 'start-lookup-branch=================) (report '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* (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))]) (for/or ([table (in-list (· lookup subTables))])
(send this applyLookup (· lookup lookupType) table)) (send this applyLookup (· lookup lookupType) table))
(report 'incrementing-iterator-at-bottom) (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 pos (· this glyphIterator index))
(define glyph (send (· this glyphIterator) increment sequenceIndex)) (define glyph (send (· this glyphIterator) increment sequenceIndex))
(define idx 0) (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))) (while (and (< idx (length sequence)) glyph (fn (list-ref sequence idx) (· glyph id)))
(report* 'in-match-loop 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)) (send this match sequenceIndex sequence (λ (component glyph) (= component glyph)) empty))
(define/public (coverageSequenceMatches sequenceIndex sequence) (define/public (coverageSequenceMatches sequenceIndex sequence)
(report 'in-coverageSequenceMatches) #;(report 'in-coverageSequenceMatches)
(send this match sequenceIndex sequence (λ (coverage glyph) (>= (send this coverageIndex coverage glyph) 0)))) (send this match sequenceIndex sequence (λ (coverage glyph) (>= (send this coverageIndex coverage glyph) 0))))
(define/public (getClassID glyph classDef) (define/public (getClassID glyph classDef)
@ -207,10 +209,10 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/OTProcessor.js
[else #f])) [else #f]))
(define/public (applyChainingContext table) (define/public (applyChainingContext table)
(report/file 'otproc:applyChainingContext) #;(report/file 'otproc:applyChainingContext)
(case (· table version) (case (· table version)
[(1) [(1)
(report 'case-1) #;(report 'case-1)
(define index (send this coverageIndex (· table coverage))) (define index (send this coverageIndex (· table coverage)))
(cond (cond
[(= index -1) #f] [(= 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 sequenceMatches (add1 (length (· rule input))) (· rule lookahead))))
(send this applyLookupList (· rule lookupRecords)))])] (send this applyLookupList (· rule lookupRecords)))])]
[(2) [(2)
(report 'case-2) #;(report 'case-2)
(cond (cond
[(= -1 (send this coverageIndex (· table coverage))) #f] [(= -1 (send this coverageIndex (· table coverage))) #f]
[else (define index (send this getClassID (· this glyphIterator cur id) (· table inputClassDef))) [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 classSequenceMatches (add1 (length (· rule input))) (· rule lookahead) (· table lookaheadClassDef))))
(send this applyLookupList (· rule lookupRecords)))])])] (send this applyLookupList (· rule lookupRecords)))])])]
[(3) [(3)
(report 'case-3) #;(report 'case-3)
(and (and
(report (send this coverageSequenceMatches (- (· table backtrackGlyphCount)) (· table backtrackCoverage)) 'a) (send this coverageSequenceMatches (- (· table backtrackGlyphCount)) (· table backtrackCoverage))
(report (send this coverageSequenceMatches 0 (· table inputCoverage)) 'b) (send this coverageSequenceMatches 0 (· table inputCoverage))
(report (send this coverageSequenceMatches (· table inputGlyphCount) (· table lookaheadCoverage)) 'c) (send this coverageSequenceMatches (· table inputGlyphCount) (· table lookaheadCoverage))
(send this applyLookupList (· table lookupRecords)))] (send this applyLookupList (· table lookupRecords)))]
[else #f])) [else #f]))

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