mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
not refer fonts by name, instead use id
This commit is contained in:
parent
65f1058736
commit
8ac2367fa0
2 changed files with 54 additions and 45 deletions
22
pdf.js
22
pdf.js
|
@ -3605,9 +3605,10 @@ var CanvasGraphics = (function() {
|
|||
|
||||
return {
|
||||
name: fontName,
|
||||
file: fontFile,
|
||||
properties: properties
|
||||
};
|
||||
fontDict: fontDict,
|
||||
file: fontFile,
|
||||
properties: properties
|
||||
};
|
||||
},
|
||||
|
||||
beginDrawing: function(mediaBox) {
|
||||
|
@ -3686,6 +3687,7 @@ var CanvasGraphics = (function() {
|
|||
var font = xref.fetchIfRef(fontRes.get(args[0].name));
|
||||
assertWellFormed(IsDict(font));
|
||||
if (!font.translated) {
|
||||
// sbarman marker
|
||||
font.translated = this.translateFont(font, xref, resources);
|
||||
if (fonts && font.translated) {
|
||||
// keep track of each font we translated so the caller can
|
||||
|
@ -3868,25 +3870,23 @@ var CanvasGraphics = (function() {
|
|||
return;
|
||||
|
||||
var fontName = '';
|
||||
var fontDescriptor = font.get('FontDescriptor');
|
||||
if (fontDescriptor && fontDescriptor.num) {
|
||||
var fontDescriptor = this.xref.fetchIfRef(fontDescriptor);
|
||||
fontName = fontDescriptor.get('FontName').name.replace('+', '_');
|
||||
}
|
||||
var fontObj = font.fontObj;
|
||||
if (fontObj)
|
||||
fontName = fontObj.loadedName;
|
||||
|
||||
if (!fontName) {
|
||||
// TODO: fontDescriptor is not available, fallback to default font
|
||||
fontName = 'sans-serif';
|
||||
}
|
||||
|
||||
this.current.fontName = fontName;
|
||||
this.current.font = fontObj;
|
||||
this.current.fontSize = size;
|
||||
|
||||
if (this.ctx.$setFont) {
|
||||
this.ctx.$setFont(fontName, size);
|
||||
} else {
|
||||
this.ctx.font = size + 'px "' + fontName + '"';
|
||||
Fonts.setActive(fontName, size);
|
||||
Fonts.setActive(font, size);
|
||||
}
|
||||
},
|
||||
setTextRenderingMode: function(mode) {
|
||||
|
@ -3931,7 +3931,7 @@ var CanvasGraphics = (function() {
|
|||
text = Fonts.charsToUnicode(text);
|
||||
this.ctx.translate(this.current.x, -1 * this.current.y);
|
||||
|
||||
var font = Fonts.lookup(this.current.fontName);
|
||||
var font = Fonts.lookupById(this.current.font.id);
|
||||
if (font && font.properties.textMatrix)
|
||||
this.ctx.transform.apply(this.ctx, font.properties.textMatrix);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue