     tag = (String.fromCharCode Math.random() * 26 + 65 for i in [0...6]).join ''
     name = tag + '+' + @font.postscriptName
     
+    bbox = @font.bbox
     descriptor = @document.ref
       Type: 'FontDescriptor'
       FontName: name
       Flags: flags
-      FontBBox: @font.bbox
+      FontBBox: [bbox.minX * @scale, bbox.minY * @scale, bbox.maxX * @scale, bbox.maxY * @scale]
       ItalicAngle: @font.italicAngle
-      Ascent: @font.ascent
-      Descent: @font.descent
-      CapHeight: @font.capHeight or @font.ascent
-      XHeight: @font.xHeight or 0
+      Ascent: @ascender
+      Descent: @descender
+      CapHeight: (@font.capHeight or @font.ascent) * @scale
+      XHeight: (@font.xHeight or 0) * @scale
       StemV: 0 # not sure how to calculate this
         
     if isCFF

  constructor: (@document, @font, @id) ->
    @subset = @font.createSubset()
    @unicode = [[0]]
    @widths = [@font.widthOfGlyph 0]
    
    @name = @font.postscriptName
    @ascender = @font.ascent
    @decender = @font.descent
    @lineGap = @font.lineGap
    @bbox = @font.bbox
    
  includeGlyph: (gid) ->
    return @subset.includeGlyph gid
  
  encode: (text, features) ->
    glyphs = @font.glyphsForString text, features
    advances = @font.advancesForGlyphs glyphs, features
    
    res = []
    for glyph, i in glyphs
      gid = @includeGlyph glyph.id
      res.push ('0000' + gid.toString(16)).slice(-4)
        
      @widths[gid] ?= @font.widthOfGlyph glyph.id
      @unicode[gid] ?= glyph.codePoints
      advances[i] -= @widths[gid]
      
    return [res, advances]
    
  widthOfString: (string, size, features) ->
    glyphs = @font.glyphsForString '' + string, features
    advances = @font.advancesForGlyphs glyphs, features
    
    width = 0
    for advance in advances
      width += advance
    
    scale = size / 1000  
    return width * scale
        
  embed: ->

      Subtype: if isCFF then 'CIDFontType0' else 'CIDFontType2'
      BaseFont: name
      CIDSystemInfo:
        Registry: new String 'Adobe'
        Ordering: new String 'Identity'
        Supplement: 0
      FontDescriptor: descriptor
      W: [0, @widths]
