1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 01:28:06 +02:00

Do not rasterize below 14px

This commit is contained in:
Vivien Nicolas 2011-07-19 14:22:51 +02:00
parent 9b45870d9a
commit c6c72291d9
2 changed files with 10 additions and 2 deletions

9
pdf.js
View file

@ -3898,6 +3898,9 @@ function ScratchCanvas(width, height) {
}
var CanvasGraphics = (function() {
var kScalePrecision = 50;
var kRasterizerMin = 14;
function constructor(canvasCtx, imageCanvas) {
this.ctx = canvasCtx;
this.current = new CanvasExtraState();
@ -4113,8 +4116,10 @@ var CanvasGraphics = (function() {
if (this.ctx.$setFont) {
this.ctx.$setFont(fontName, size);
} else {
this.ctx.font = size + 'px "' + fontName + '"';
Fonts.setActive(fontName, fontObj, size);
size = (size <= kRasterizerMin) ? size * kScalePrecision : size;
this.ctx.font = size + 'px "' + fontName + '"';
}
},
setTextRenderingMode: function(mode) {
@ -4162,6 +4167,8 @@ var CanvasGraphics = (function() {
ctx.translate(current.x, -1 * current.y);
var font = this.current.font;
if (font) {
if (this.current.fontSize < kRasterizerMin)
ctx.transform(1 / kScalePrecision, 0, 0, 1 / kScalePrecision, 0, 0);
ctx.transform.apply(ctx, font.textMatrix);
text = font.charsToUnicode(text);
}