|
69 | 69 | function styles(el, options, cssLoadedCallback) { |
70 | 70 | var selectorRemap = options.selectorRemap; |
71 | 71 | var modifyStyle = options.modifyStyle; |
| 72 | + var modifyCss = options.modifyCss || function(selector, properties) { |
| 73 | + var selector = selectorRemap ? selectorRemap(selector) : selector; |
| 74 | + var cssText = modifyStyle ? modifyStyle(properties) : properties; |
| 75 | + return selector + " { " + cssText + " }\n"; |
| 76 | + }; |
72 | 77 | var css = ""; |
73 | | - // each font that has extranl link is saved into queue, and processed |
74 | | - // asynchronously |
| 78 | + |
| 79 | + // Each font that has an external link is saved into queue, and processed asynchronously. |
75 | 80 | var fontsQueue = []; |
76 | 81 | var sheets = document.styleSheets; |
77 | 82 | for (var i = 0; i < sheets.length; i++) { |
|
103 | 108 | } |
104 | 109 |
|
105 | 110 | if (match) { |
106 | | - var selector = selectorRemap ? selectorRemap(rule.selectorText) : rule.selectorText; |
107 | | - var cssText = modifyStyle ? modifyStyle(rule.style.cssText) : rule.style.cssText; |
108 | | - css += selector + " { " + cssText + " }\n"; |
| 111 | + css += modifyCss(rule.selectorText, rule.style.cssText); |
109 | 112 | } else if(rule.cssText.match(/^@font-face/)) { |
110 | 113 | // below we are trying to find matches to external link. E.g. |
111 | 114 | // @font-face { |
|
373 | 376 |
|
374 | 377 | var pixelRatio = window.devicePixelRatio || 1; |
375 | 378 |
|
376 | | - canvas.style.width = canvas.width +'px'; |
377 | | - canvas.style.height = canvas.height +'px'; |
| 379 | + canvas.style.width = canvas.width+'px'; |
| 380 | + canvas.style.height = canvas.height+'px'; |
378 | 381 | canvas.width *= pixelRatio; |
379 | 382 | canvas.height *= pixelRatio; |
380 | 383 |
|
381 | 384 | context.setTransform(pixelRatio,0,0,pixelRatio,0,0); |
382 | | - |
| 385 | + |
383 | 386 | if(options.canvg) { |
384 | 387 | options.canvg(canvas, src); |
385 | 388 | } else { |
|
0 commit comments