mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Simulate Arial Black and Arial Narrow
This commit is contained in:
parent
81e1485e14
commit
00d2366d1d
2 changed files with 27 additions and 8 deletions
21
pdf.js
21
pdf.js
|
@ -4417,9 +4417,7 @@ var PartialEvaluator = (function() {
|
|||
}
|
||||
|
||||
var descriptor = xref.fetch(fd);
|
||||
var fontName = fontDict.get('Name');
|
||||
if (!fontName)
|
||||
fontName = xref.fetchIfRef(descriptor.get('FontName'));
|
||||
var fontName = xref.fetchIfRef(descriptor.get('FontName'));
|
||||
assertWellFormed(IsName(fontName), 'invalid font name');
|
||||
fontName = fontName.name.replace(/[\+,\-]/g, '_');
|
||||
|
||||
|
@ -4805,7 +4803,9 @@ var CanvasGraphics = (function() {
|
|||
|
||||
size = (size <= kRasterizerMin) ? size * kScalePrecision : size;
|
||||
|
||||
var bold = fontObj.bold ? 'bold' : 'normal';
|
||||
var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold')
|
||||
: (fontObj.bold ? 'bold' : 'normal');
|
||||
|
||||
var italic = fontObj.italic ? 'italic' : 'normal';
|
||||
var rule = italic + ' ' + bold + ' ' + size + 'px "' + name + '"';
|
||||
this.ctx.font = rule;
|
||||
|
@ -4841,8 +4841,6 @@ var CanvasGraphics = (function() {
|
|||
this.moveText(0, this.current.leading);
|
||||
},
|
||||
showText: function(text) {
|
||||
// TODO: apply charSpacing, wordSpacing, textHScale
|
||||
|
||||
var ctx = this.ctx;
|
||||
var current = this.current;
|
||||
|
||||
|
@ -4853,9 +4851,9 @@ var CanvasGraphics = (function() {
|
|||
ctx.translate(current.x, -1 * current.y);
|
||||
|
||||
var scaleFactorX = 1, scaleFactorY = 1;
|
||||
var font = this.current.font;
|
||||
var font = current.font;
|
||||
if (font) {
|
||||
if (this.current.fontSize <= kRasterizerMin) {
|
||||
if (current.fontSize <= kRasterizerMin) {
|
||||
scaleFactorX = scaleFactorY = kScalePrecision;
|
||||
ctx.scale(1 / scaleFactorX, 1 / scaleFactorY);
|
||||
}
|
||||
|
@ -4867,6 +4865,13 @@ var CanvasGraphics = (function() {
|
|||
var wordSpacing = current.wordSpacing;
|
||||
var textHScale = current.textHScale;
|
||||
|
||||
// This is a poor simulation for Arial Narrow while font-stretch
|
||||
// is not implemented (bug 3512)
|
||||
if (current.font.narrow) {
|
||||
textHScale += 0.2;
|
||||
charSpacing -= (0.09 * current.fontSize);
|
||||
}
|
||||
|
||||
if (charSpacing != 0 || wordSpacing != 0 || textHScale != 1) {
|
||||
scaleFactorX *= textHScale;
|
||||
ctx.scale(1 / textHScale, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue