Propagate the translated font name to TextContentItems.
This allows font data for system fonts to be looked up in the PDFObjects.
This commit is contained in:
parent
eda51d1dcc
commit
36fb5c1e2b
@ -2430,8 +2430,7 @@ class PartialEvaluator {
|
|||||||
if (textContentItem.initialized) {
|
if (textContentItem.initialized) {
|
||||||
return textContentItem;
|
return textContentItem;
|
||||||
}
|
}
|
||||||
const font = textState.font,
|
const { font, loadedName } = textState;
|
||||||
loadedName = font.loadedName;
|
|
||||||
if (!seenStyles.has(loadedName)) {
|
if (!seenStyles.has(loadedName)) {
|
||||||
seenStyles.add(loadedName);
|
seenStyles.add(loadedName);
|
||||||
|
|
||||||
@ -2544,6 +2543,7 @@ class PartialEvaluator {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(function (translated) {
|
.then(function (translated) {
|
||||||
|
textState.loadedName = translated.loadedName;
|
||||||
textState.font = translated.font;
|
textState.font = translated.font;
|
||||||
textState.fontMatrix =
|
textState.fontMatrix =
|
||||||
translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
|
translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
|
||||||
@ -2877,7 +2877,7 @@ class PartialEvaluator {
|
|||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
transform: getCurrentTextTransform(),
|
transform: getCurrentTextTransform(),
|
||||||
fontName: textState.font.loadedName,
|
fontName: textState.loadedName,
|
||||||
hasEOL: true,
|
hasEOL: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4607,6 +4607,7 @@ class TextState {
|
|||||||
this.ctm = new Float32Array(IDENTITY_MATRIX);
|
this.ctm = new Float32Array(IDENTITY_MATRIX);
|
||||||
this.fontName = null;
|
this.fontName = null;
|
||||||
this.fontSize = 0;
|
this.fontSize = 0;
|
||||||
|
this.loadedName = null;
|
||||||
this.font = null;
|
this.font = null;
|
||||||
this.fontMatrix = FONT_IDENTITY_MATRIX;
|
this.fontMatrix = FONT_IDENTITY_MATRIX;
|
||||||
this.textMatrix = IDENTITY_MATRIX.slice();
|
this.textMatrix = IDENTITY_MATRIX.slice();
|
||||||
|
@ -2244,7 +2244,7 @@ page 1 / 3`);
|
|||||||
const pdfPage = await pdfDoc.getPage(1);
|
const pdfPage = await pdfDoc.getPage(1);
|
||||||
const { items, styles } = await pdfPage.getTextContent();
|
const { items, styles } = await pdfPage.getTextContent();
|
||||||
expect(items.length).toEqual(1);
|
expect(items.length).toEqual(1);
|
||||||
// Font name will a random object id.
|
// Font name will be a random object id.
|
||||||
const fontName = items[0].fontName;
|
const fontName = items[0].fontName;
|
||||||
expect(Object.keys(styles)).toEqual([fontName]);
|
expect(Object.keys(styles)).toEqual([fontName]);
|
||||||
|
|
||||||
@ -2266,6 +2266,11 @@ page 1 / 3`);
|
|||||||
vertical: false,
|
vertical: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Wait for font data to be loaded so we can check that the font names
|
||||||
|
// match.
|
||||||
|
await pdfPage.getOperatorList();
|
||||||
|
expect(pdfPage.commonObjs.has(fontName)).toEqual(true);
|
||||||
|
|
||||||
await loadingTask.destroy();
|
await loadingTask.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user