* http://cgit.freedesktop.org/poppler/poppler/tree/poppler/GfxFont.cc#n65
*/
- var Fonts = (function Fonts() {
+ var FontMeasure = (function FontMeasure() {
- var kScalePrecision = 40;
-
+ var kScalePrecision = 50;
- var fonts = [];
-
- if (!isWorker) {
- var ctx = document.createElement('canvas').getContext('2d');
- ctx.scale(1 / kScalePrecision, 1);
- }
-
- var fontCount = 0;
-
- function FontInfo(name, data, properties) {
- this.name = name;
- this.data = data;
- this.properties = properties;
- this.id = fontCount++;
- this.loading = true;
- this.sizes = [];
- }
+ var ctx = document.createElement('canvas').getContext('2d');
+ ctx.scale(1 / kScalePrecision, 1);
var current;
var measureCache;
* var type1Font = new Font("MyFontName", binaryFile, propertiesObject);
* type1Font.bind();
*/
-var Font = (function() {
+var Font = (function Font() {
var constructor = function font_constructor(name, file, properties) {
this.name = name;
- this.textMatrix = properties.textMatrix || IDENTITY_MATRIX;
this.encoding = properties.encoding;
+ this.sizes = [];
// If the font is to be ignored, register it like an already loaded font
// to avoid the cost of waiting for it be be loaded by the platform.
break;
}
this.data = data;
+ this.textMatrix = properties.textMatrix || IDENTITY_MATRIX;
this.type = properties.type;
- this.id = Fonts.registerFont(name, data, properties);
- this.loadedName = 'pdfFont' + this.id;
+ this.loadedName = getUniqueName();
this.compositeFont = properties.compositeFont;
};
if (this.ctx.$setFont) {
this.ctx.$setFont(fontName, size);
} else {
- Fonts.setActive(fontName, fontObj, size);
- this.ctx.font = size + 'px "' + fontName + '"';
+ FontMeasure.setActive(fontObj, size);
+
+ size = (size <= kRasterizerMin) ? size * kScalePrecision : size;
+ this.ctx.font = size + 'px "' + fontName + '"';
}
},
setTextRenderingMode: function(mode) {