@ -134,16 +134,15 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
return 0 ;
return 0 ;
}
}
function compileGlyf ( code , j s, font ) {
function compileGlyf ( code , cmd s, font ) {
function moveTo ( x , y ) {
function moveTo ( x , y ) {
js . push ( 'c.moveTo(' + x + ',' + y + ');' ) ;
cmds . push ( { cmd : 'moveTo' , args : [ x , y ] } ) ;
}
}
function lineTo ( x , y ) {
function lineTo ( x , y ) {
js . push ( 'c.lineTo(' + x + ',' + y + ');' ) ;
cmds . push ( { cmd : 'lineTo' , args : [ x , y ] } ) ;
}
}
function quadraticCurveTo ( xa , ya , x , y ) {
function quadraticCurveTo ( xa , ya , x , y ) {
js . push ( 'c.quadraticCurveTo(' + xa + ',' + ya + ',' +
cmds . push ( { cmd : 'quadraticCurveTo' , args : [ xa , ya , x , y ] } ) ;
x + ',' + y + ');' ) ;
}
}
var i = 0 ;
var i = 0 ;
@ -189,11 +188,11 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
}
var subglyph = font . glyphs [ glyphIndex ] ;
var subglyph = font . glyphs [ glyphIndex ] ;
if ( subglyph ) {
if ( subglyph ) {
j s. push ( 'c. save(); ') ;
cmd s. push ( { cmd : 'save'} ) ;
js . push ( 'c.transform(' + scaleX + ',' + scale01 + ',' +
cmds . push ( { cmd : 'transform' ,
scale10 + ',' + scaleY + ',' + x + ',' + y + ');' ) ;
args : [ scaleX , scale01 , scale10 , scaleY , x , y ] } ) ;
compileGlyf ( subglyph , j s, font ) ;
compileGlyf ( subglyph , cmd s, font ) ;
j s. push ( 'c. restore(); ') ;
cmd s. push ( { cmd : 'restore'} ) ;
}
}
} while ( ( flags & 0x20 ) ) ;
} while ( ( flags & 0x20 ) ) ;
} else {
} else {
@ -289,20 +288,19 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
}
}
}
function compileCharString ( code , j s, font ) {
function compileCharString ( code , cmd s, font ) {
var stack = [ ] ;
var stack = [ ] ;
var x = 0 , y = 0 ;
var x = 0 , y = 0 ;
var stems = 0 ;
var stems = 0 ;
function moveTo ( x , y ) {
function moveTo ( x , y ) {
js . push ( 'c.moveTo(' + x + ',' + y + ');' ) ;
cmds . push ( { cmd : 'moveTo' , args : [ x , y ] } ) ;
}
}
function lineTo ( x , y ) {
function lineTo ( x , y ) {
js . push ( 'c.lineTo(' + x + ',' + y + ');' ) ;
cmds . push ( { cmd : 'lineTo' , args : [ x , y ] } ) ;
}
}
function bezierCurveTo ( x1 , y1 , x2 , y2 , x , y ) {
function bezierCurveTo ( x1 , y1 , x2 , y2 , x , y ) {
js . push ( 'c.bezierCurveTo(' + x1 + ',' + y1 + ',' + x2 + ',' + y2 + ',' +
cmds . push ( { cmd : 'bezierCurveTo' , args : [ x1 , y1 , x2 , y2 , x , y ] } ) ;
x + ',' + y + ');' ) ;
}
}
function parse ( code ) {
function parse ( code ) {
@ -431,16 +429,16 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
var bchar = stack . pop ( ) ;
var bchar = stack . pop ( ) ;
y = stack . pop ( ) ;
y = stack . pop ( ) ;
x = stack . pop ( ) ;
x = stack . pop ( ) ;
j s. push ( 'c. save(); ') ;
cmd s. push ( { cmd : 'save'} ) ;
js . push ( 'c.translate(' + x + ',' + y + ');' ) ;
cmds . push ( { cmd : 'translate' , args : [ x , y ] } ) ;
var gid = lookupCmap ( font . cmap , String . fromCharCode (
var gid = lookupCmap ( font . cmap , String . fromCharCode (
font . glyphNameMap [ Encodings . StandardEncoding [ achar ] ] ) ) ;
font . glyphNameMap [ Encodings . StandardEncoding [ achar ] ] ) ) ;
compileCharString ( font . glyphs [ gid ] , j s, font ) ;
compileCharString ( font . glyphs [ gid ] , cmd s, font ) ;
j s. push ( 'c. restore(); ') ;
cmd s. push ( { cmd : 'restore'} ) ;
gid = lookupCmap ( font . cmap , String . fromCharCode (
gid = lookupCmap ( font . cmap , String . fromCharCode (
font . glyphNameMap [ Encodings . StandardEncoding [ bchar ] ] ) ) ;
font . glyphNameMap [ Encodings . StandardEncoding [ bchar ] ] ) ) ;
compileCharString ( font . glyphs [ gid ] , j s, font ) ;
compileCharString ( font . glyphs [ gid ] , cmd s, font ) ;
}
}
return ;
return ;
case 18 : // hstemhm
case 18 : // hstemhm
@ -609,16 +607,16 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
return noop ;
return noop ;
}
}
var j s = [ ] ;
var cmd s = [ ] ;
j s. push ( 'c. save(); ') ;
cmd s. push ( { cmd : 'save'} ) ;
js . push ( 'c.transform(' + this . fontMatrix . join ( ',' ) + ');' ) ;
cmds . push ( { cmd : 'transform' , args : this . fontMatrix . slice ( ) } ) ;
js . push ( 'c.scale(size, -size);' ) ;
cmds . push ( { cmd : 'scale' , args : [ 'size' , '-size' ] } ) ;
this . compileGlyphImpl ( code , j s) ;
this . compileGlyphImpl ( code , cmd s) ;
j s. push ( 'c. restore(); ') ;
cmd s. push ( { cmd : 'restore'} ) ;
return js . join ( '\n' ) ;
return cmds ;
} ,
} ,
compileGlyphImpl : function ( ) {
compileGlyphImpl : function ( ) {
@ -642,8 +640,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
}
Util . inherit ( TrueTypeCompiled , CompiledFont , {
Util . inherit ( TrueTypeCompiled , CompiledFont , {
compileGlyphImpl : function ( code , j s) {
compileGlyphImpl : function ( code , cmd s) {
compileGlyf ( code , j s, this ) ;
compileGlyf ( code , cmd s, this ) ;
}
}
} ) ;
} ) ;
@ -664,8 +662,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
}
Util . inherit ( Type2Compiled , CompiledFont , {
Util . inherit ( Type2Compiled , CompiledFont , {
compileGlyphImpl : function ( code , j s) {
compileGlyphImpl : function ( code , cmd s) {
compileCharString ( code , j s, this ) ;
compileCharString ( code , cmd s, this ) ;
}
}
} ) ;
} ) ;