mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[Editor] Draw a line instead of a Bezier curve when an Ink has only one point
Fixes #17418.
This commit is contained in:
parent
2ca20dea43
commit
e9946fa22a
3 changed files with 60 additions and 8 deletions
|
@ -4397,14 +4397,20 @@ class InkAnnotation extends MarkupAnnotation {
|
|||
buffer.push(
|
||||
`${numberToString(bezier[0])} ${numberToString(bezier[1])} m`
|
||||
);
|
||||
for (let i = 2, ii = bezier.length; i < ii; i += 6) {
|
||||
const curve = bezier
|
||||
.slice(i, i + 6)
|
||||
.map(numberToString)
|
||||
.join(" ");
|
||||
buffer.push(`${curve} c`);
|
||||
if (bezier.length === 2) {
|
||||
buffer.push(
|
||||
`${numberToString(bezier[0])} ${numberToString(bezier[1])} l S`
|
||||
);
|
||||
} else {
|
||||
for (let i = 2, ii = bezier.length; i < ii; i += 6) {
|
||||
const curve = bezier
|
||||
.slice(i, i + 6)
|
||||
.map(numberToString)
|
||||
.join(" ");
|
||||
buffer.push(`${curve} c`);
|
||||
}
|
||||
buffer.push("S");
|
||||
}
|
||||
buffer.push("S");
|
||||
appearanceBuffer.push(buffer.join("\n"));
|
||||
}
|
||||
const appearance = appearanceBuffer.join("\n");
|
||||
|
|
|
@ -628,7 +628,7 @@ class InkEditor extends AnnotationEditor {
|
|||
|
||||
this.parent.addInkEditorIfNeeded(/* isCommitting = */ true);
|
||||
|
||||
// When commiting, the position of this editor is changed, hence we must
|
||||
// When committing, the position of this editor is changed, hence we must
|
||||
// move it to the right position in the DOM.
|
||||
this.moveInDOM();
|
||||
this.div.focus({
|
||||
|
@ -994,6 +994,14 @@ class InkEditor extends AnnotationEditor {
|
|||
const points = [];
|
||||
for (let j = 0, jj = bezier.length; j < jj; j++) {
|
||||
const [first, control1, control2, second] = bezier[j];
|
||||
if (first[0] === second[0] && first[1] === second[1] && jj === 1) {
|
||||
// We have only one point.
|
||||
const p0 = s * first[0] + shiftX;
|
||||
const p1 = s * first[1] + shiftY;
|
||||
buffer.push(p0, p1);
|
||||
points.push(p0, p1);
|
||||
break;
|
||||
}
|
||||
const p10 = s * first[0] + shiftX;
|
||||
const p11 = s * first[1] + shiftY;
|
||||
const p20 = s * control1[0] + shiftX;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue