Code coverage report for fontkit/src/layout/GlyphRun.coffee

Statements: 26.92% (7 / 26)      Branches: 100% (0 / 0)      Functions: 40% (2 / 5)      Lines: 26.92% (7 / 26)      Ignored: none     

All files » fontkit/src/layout/ » GlyphRun.coffee
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 391   1 1     1             1             1                                 1  
BBox = require '../glyph/BBox'
 
class GlyphRun
  get = require('../get')(this)
  constructor: (@glyphs, @positions) ->
    
  get 'advanceWidth', ->
    width = 0
    for position in @positions
      width += position.xAdvance
      
    return width
    
  get 'advanceHeight', ->
    height = 0
    for position in @positions
      height += position.yAdvance
      
    return height
      
  get 'bbox', ->
    bbox = new BBox
    
    x = 0
    y = 0
    for glyph, index in @glyphs
      p = @positions[index]
      b = glyph.bbox
      
      bbox.addPoint b.minX + x + p.xOffset, b.minY + y + p.yOffset
      bbox.addPoint b.maxX + x + p.xOffset, b.maxY + y + p.yOffset
      
      x += p.xAdvance
      y += p.yAdvance
      
    return bbox
    
module.exports = GlyphRun