mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Get rid of CSS transform on each annotation in the annotation layer
- each annotation has its coordinates/dimensions expressed in percentage, hence it's correctly positioned whatever the scale factor is; - the font sizes are expressed in percentage too and the main font size is scaled thanks a css var (--scale-factor); - the rotation is now applied on the div annotationLayer; - this patch improve the rendering of some strings where the glyph spacing was not correct (it's a Firefox bug); - it helps to simplify the code and it should slightly improve the update of page (on zoom or rotation).
This commit is contained in:
parent
6dc8d1f532
commit
e2db9bacef
17 changed files with 154 additions and 155 deletions
|
@ -432,6 +432,7 @@ class Annotation {
|
|||
this.setAppearance(dict);
|
||||
this.setBorderAndBackgroundColors(dict.get("MK"));
|
||||
|
||||
this._hasOwnCanvas = false;
|
||||
this._streams = [];
|
||||
if (this.appearance) {
|
||||
this._streams.push(this.appearance);
|
||||
|
@ -450,7 +451,6 @@ class Annotation {
|
|||
modificationDate: this.modificationDate,
|
||||
rect: this.rectangle,
|
||||
subtype: params.subtype,
|
||||
hasOwnCanvas: false,
|
||||
};
|
||||
|
||||
if (params.collectFields) {
|
||||
|
@ -849,7 +849,7 @@ class Annotation {
|
|||
const data = this.data;
|
||||
let appearance = this.appearance;
|
||||
const isUsingOwnCanvas =
|
||||
data.hasOwnCanvas && intent & RenderingIntentFlag.DISPLAY;
|
||||
this._hasOwnCanvas && intent & RenderingIntentFlag.DISPLAY;
|
||||
if (!appearance) {
|
||||
if (!isUsingOwnCanvas) {
|
||||
return Promise.resolve(new OperatorList());
|
||||
|
@ -2163,7 +2163,7 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
|
|||
} else if (this.data.radioButton) {
|
||||
this._processRadioButton(params);
|
||||
} else if (this.data.pushButton) {
|
||||
this.data.hasOwnCanvas = true;
|
||||
this._hasOwnCanvas = true;
|
||||
this._processPushButton(params);
|
||||
} else {
|
||||
warn("Invalid field flags for button widget annotation");
|
||||
|
|
|
@ -1425,7 +1425,7 @@ class ChoiceList extends XFAObject {
|
|||
const field = ui[$getParent]();
|
||||
const fontSize = (field.font && field.font.size) || 10;
|
||||
const optionStyle = {
|
||||
fontSize: `calc(${fontSize}px * var(--zoom-factor))`,
|
||||
fontSize: `calc(${fontSize}px * var(--scale-factor))`,
|
||||
};
|
||||
const children = [];
|
||||
|
||||
|
|
|
@ -182,6 +182,10 @@ function mapStyle(styleStr, node, richText) {
|
|||
);
|
||||
}
|
||||
|
||||
if (richText && style.fontSize) {
|
||||
style.fontSize = `calc(${style.fontSize} * var(--scale-factor))`;
|
||||
}
|
||||
|
||||
fixTextIndent(style);
|
||||
return style;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue