Add a parser to get font data from the default appearance (#12831)

* Add a parser to get font data from the default appearance
 - pdfium & poppler use a special parser too to get these info.

* Update src/core/default_appearance.js

Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>

Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>
This commit is contained in:
calixteman 2021-01-21 11:15:31 -08:00 committed by GitHub
parent 4142001fc2
commit 1039698697
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 191 additions and 33 deletions

View file

@ -797,12 +797,10 @@ class PartialEvaluator {
fallbackFontDict = null
) {
// TODO(mack): Not needed?
var fontName,
fontSize = 0;
var fontName;
if (fontArgs) {
fontArgs = fontArgs.slice();
fontName = fontArgs[0].name;
fontSize = fontArgs[1];
}
return this.loadFont(fontName, fontRef, resources, fallbackFontDict)
@ -835,8 +833,6 @@ class PartialEvaluator {
})
.then(translated => {
state.font = translated.font;
state.fontSize = fontSize;
state.fontName = fontName;
translated.send(this.handler);
return translated.loadedName;
});
@ -3714,7 +3710,7 @@ class TranslatedFont {
}
class StateManager {
constructor(initialState) {
constructor(initialState = new EvalState()) {
this.state = initialState;
this.stateStack = [];
}
@ -3985,7 +3981,7 @@ class EvaluatorPreprocessor {
return shadow(this, "MAX_INVALID_PATH_OPS", 20);
}
constructor(stream, xref, stateManager) {
constructor(stream, xref, stateManager = new StateManager()) {
// TODO(mduan): pass array of knownCommands rather than this.opMap
// dictionary
this.parser = new Parser({
@ -4126,4 +4122,4 @@ class EvaluatorPreprocessor {
}
}
export { PartialEvaluator };
export { EvaluatorPreprocessor, PartialEvaluator };