fallback if TextMeasure.actualBoundingBox* unavailable
This commit is contained in:
parent
2d6cf7f0f9
commit
2feedbdbb7
@ -1335,15 +1335,17 @@ class App extends React.Component<{}, AppState> {
|
|||||||
if (text === null) {
|
if (text === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const fontSize = 20;
|
||||||
element.text = text;
|
element.text = text;
|
||||||
element.font = "20px Virgil";
|
element.font = `${fontSize}px Virgil`;
|
||||||
const font = context.font;
|
const font = context.font;
|
||||||
context.font = element.font;
|
context.font = element.font;
|
||||||
const {
|
const textMeasure = context.measureText(element.text);
|
||||||
actualBoundingBoxAscent,
|
const width = textMeasure.width;
|
||||||
actualBoundingBoxDescent,
|
const actualBoundingBoxAscent =
|
||||||
width
|
textMeasure.actualBoundingBoxAscent || fontSize;
|
||||||
} = context.measureText(element.text);
|
const actualBoundingBoxDescent =
|
||||||
|
textMeasure.actualBoundingBoxDescent || 0;
|
||||||
element.actualBoundingBoxAscent = actualBoundingBoxAscent;
|
element.actualBoundingBoxAscent = actualBoundingBoxAscent;
|
||||||
context.font = font;
|
context.font = font;
|
||||||
const height = actualBoundingBoxAscent + actualBoundingBoxDescent;
|
const height = actualBoundingBoxAscent + actualBoundingBoxDescent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user