mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 01:28:06 +02:00
Merge pull request #226 from andreasgal/staging
simplify font measurement code, bug is now fixed in nightlies, no need to
This commit is contained in:
commit
fb9b8b6417
2 changed files with 16 additions and 46 deletions
30
pdf.js
30
pdf.js
|
@ -3972,7 +3972,6 @@ var CanvasGraphics = (function() {
|
|||
this.ctx.$setFont(fontName, size);
|
||||
} else {
|
||||
this.ctx.font = size + 'px "' + fontName + '"';
|
||||
Fonts.setActive(fontName, fontObj, size);
|
||||
}
|
||||
},
|
||||
setTextRenderingMode: function(mode) {
|
||||
|
@ -4010,24 +4009,25 @@ var CanvasGraphics = (function() {
|
|||
var ctx = this.ctx;
|
||||
var current = this.current;
|
||||
|
||||
ctx.save();
|
||||
ctx.transform.apply(ctx, current.textMatrix);
|
||||
ctx.scale(1, -1);
|
||||
|
||||
if (this.ctx.$showText) {
|
||||
ctx.$showText(current.y, text);
|
||||
} else {
|
||||
ctx.translate(current.x, -1 * current.y);
|
||||
var font = this.current.font;
|
||||
if (font) {
|
||||
ctx.transform.apply(ctx, font.textMatrix);
|
||||
text = font.charsToUnicode(text);
|
||||
}
|
||||
ctx.fillText(text, 0, 0);
|
||||
current.x += Fonts.measureText(text);
|
||||
}
|
||||
ctx.save();
|
||||
|
||||
this.ctx.restore();
|
||||
ctx.transform.apply(ctx, current.textMatrix);
|
||||
ctx.scale(1, -1);
|
||||
ctx.translate(current.x, -current.y);
|
||||
|
||||
var font = current.font;
|
||||
ctx.transform.apply(ctx, font.textMatrix);
|
||||
|
||||
text = font.charsToUnicode(text);
|
||||
|
||||
ctx.fillText(text, 0, 0);
|
||||
current.x += ctx.measureText(text).width;
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
},
|
||||
showSpacedText: function(arr) {
|
||||
for (var i = 0; i < arr.length; ++i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue