Sfoglia il codice sorgente

fix: use `ideographic` textBaseline to improve layout shift when editing text (#6384)

David Luzar 2 anni fa
parent
commit
9e52c30ce8
1 ha cambiato i file con 8 aggiunte e 1 eliminazioni
  1. 8 1
      src/renderer/renderElement.ts

+ 8 - 1
src/renderer/renderElement.ts

@@ -34,6 +34,7 @@ import { AppState, BinaryFiles, Zoom } from "../types";
 import { getDefaultAppState } from "../appState";
 import {
   BOUND_TEXT_PADDING,
+  FONT_FAMILY,
   MAX_DECIMALS_FOR_SVG_EXPORT,
   MIME_TYPES,
   SVG_NS,
@@ -286,7 +287,13 @@ const drawElementOnCanvas = (
             : element.textAlign === "right"
             ? element.width
             : 0;
-        context.textBaseline = "bottom";
+
+        // FIXME temporary hack
+        context.textBaseline =
+          element.fontFamily === FONT_FAMILY.Virgil ||
+          element.fontFamily === FONT_FAMILY.Cascadia
+            ? "ideographic"
+            : "bottom";
 
         const lineHeightPx = getLineHeightInPx(
           element.fontSize,