mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Annotation & XFA: Scale the font size in choicelist using zoom factor (bug 1715996)
- this is an accessibility issue which could be painful for some people with visual disabilities.
This commit is contained in:
parent
52ef63f1fe
commit
71a100a4d0
4 changed files with 21 additions and 0 deletions
|
@ -1293,6 +1293,10 @@ class ChoiceList extends XFAObject {
|
|||
const style = toStyle(this, "border", "margin");
|
||||
const ui = this[$getParent]();
|
||||
const field = ui[$getParent]();
|
||||
const fontSize = (field.font && field.font.size) || 10;
|
||||
const optionStyle = {
|
||||
fontSize: `calc(${fontSize}px * var(--zoom-factor))`,
|
||||
};
|
||||
const children = [];
|
||||
|
||||
if (field.items.children.length > 0) {
|
||||
|
@ -1313,6 +1317,7 @@ class ChoiceList extends XFAObject {
|
|||
name: "option",
|
||||
attributes: {
|
||||
value: values[i] || displayed[i],
|
||||
style: optionStyle,
|
||||
},
|
||||
value: displayed[i],
|
||||
};
|
||||
|
|
|
@ -1138,11 +1138,19 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||
this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : undefined,
|
||||
});
|
||||
|
||||
let { fontSize } = this.data.defaultAppearanceData;
|
||||
if (!fontSize) {
|
||||
fontSize = 9;
|
||||
}
|
||||
const fontSizeStyle = `calc(${fontSize}px * var(--zoom-factor))`;
|
||||
|
||||
const selectElement = document.createElement("select");
|
||||
selectElement.disabled = this.data.readOnly;
|
||||
selectElement.name = this.data.fieldName;
|
||||
selectElement.setAttribute("id", id);
|
||||
|
||||
selectElement.style.fontSize = `${fontSize}px`;
|
||||
|
||||
if (!this.data.combo) {
|
||||
// List boxes have a size and (optionally) multiple selection.
|
||||
selectElement.size = this.data.options.length;
|
||||
|
@ -1156,6 +1164,9 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||
const optionElement = document.createElement("option");
|
||||
optionElement.textContent = option.displayValue;
|
||||
optionElement.value = option.exportValue;
|
||||
if (this.data.combo) {
|
||||
optionElement.style.fontSize = fontSizeStyle;
|
||||
}
|
||||
if (this.data.fieldValue.includes(option.exportValue)) {
|
||||
optionElement.setAttribute("selected", true);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue