@@ -334,59 +334,36 @@ somewhere around "pdfEscape" call.
334334*/
335335
336336API . events . push ( [
337- 'addFonts'
338- , function ( fontManagementObjects ) {
339- // fontManagementObjects is {
340- // 'fonts':font_ID-keyed hash of font objects
341- // , 'dictionary': lookup object, linking ["FontFamily"]['Style'] to font ID
342- //}
343- var font
344- , fontID
345- , metrics
337+ 'addFont'
338+ , function ( font ) {
339+ var metrics
346340 , unicode_section
347341 , encoding = 'Unicode'
348- , encodingBlock
349-
350- for ( fontID in fontManagementObjects . fonts ) {
351- if ( fontManagementObjects . fonts . hasOwnProperty ( fontID ) ) {
352- font = fontManagementObjects . fonts [ fontID ]
353-
354- // // we only ship 'Unicode' mappings and metrics. No need for loop.
355- // // still, leaving this for the future.
356-
357- // for (encoding in fontMetrics){
358- // if (fontMetrics.hasOwnProperty(encoding)) {
359-
360- metrics = fontMetrics [ encoding ] [ font . PostScriptName ]
361- if ( metrics ) {
362- if ( font . metadata [ encoding ] ) {
363- unicode_section = font . metadata [ encoding ]
364- } else {
365- unicode_section = font . metadata [ encoding ] = { }
366- }
367-
368- unicode_section . widths = metrics . widths
369- unicode_section . kerning = metrics . kerning
370- }
371- // }
372- // }
373- // for (encoding in encodings){
374- // if (encodings.hasOwnProperty(encoding)) {
375- encodingBlock = encodings [ encoding ] [ font . PostScriptName ]
376- if ( encodingBlock ) {
377- if ( font . metadata [ encoding ] ) {
378- unicode_section = font . metadata [ encoding ]
379- } else {
380- unicode_section = font . metadata [ encoding ] = { }
381- }
382-
383- unicode_section . encoding = encodingBlock
384- if ( encodingBlock . codePages && encodingBlock . codePages . length ) {
385- font . encoding = encodingBlock . codePages [ 0 ]
386- }
387- }
388- // }
389- // }
342+ , encodingBlock ;
343+
344+ metrics = fontMetrics [ encoding ] [ font . PostScriptName ] ;
345+ if ( metrics ) {
346+ if ( font . metadata [ encoding ] ) {
347+ unicode_section = font . metadata [ encoding ] ;
348+ } else {
349+ unicode_section = font . metadata [ encoding ] = { } ;
350+ }
351+
352+ unicode_section . widths = metrics . widths ;
353+ unicode_section . kerning = metrics . kerning ;
354+ }
355+
356+ encodingBlock = encodings [ encoding ] [ font . PostScriptName ] ;
357+ if ( encodingBlock ) {
358+ if ( font . metadata [ encoding ] ) {
359+ unicode_section = font . metadata [ encoding ] ;
360+ } else {
361+ unicode_section = font . metadata [ encoding ] = { } ;
362+ }
363+
364+ unicode_section . encoding = encodingBlock ;
365+ if ( encodingBlock . codePages && encodingBlock . codePages . length ) {
366+ font . encoding = encodingBlock . codePages [ 0 ] ;
390367 }
391368 }
392369 }
0 commit comments