Repository: excalidraw/excalidraw
File: src/data/restore.ts (TypeScript)

Code before:
const restoreElement = (
  element: Exclude<ExcalidrawElement, ExcalidrawSelectionElement>,
  refreshDimensions = false,
): typeof element | null => {
  switch (element.type) {
    case "text":
      let fontSize = element.fontSize;
      let fontFamily = element.fontFamily;
      if ("font" in element) {
        const [fontPx, _fontFamily]: [string, string] = (
          element as any
        ).font.split(" ");
        fontSize = parseFloat(fontPx);
        fontFamily = getFontFamilyByName(_fontFamily);
      }
      const text = element.text ?? "";

      element = restoreElementWithProperties(element, {
        fontSize,
        fontFamily,
        text,
        textAlign: element.textAlign || DEFAULT_TEXT_ALIGN,
        verticalAlign: element.verticalAlign || DEFAULT_VERTICAL_ALIGN,
        containerId: element.containerId ?? null,
        originalText: element.originalText || text,
        // line-height might not specified either when creating elements
        // programmatically, or when importing old diagrams.
        // For the latter we want to detect the original line height which
        // will likely differ from our per-font fixed line height we now use,
        // to maintain backward compatibility.
        lineHeight:
          element.lineHeight ||
          (element.height
            ? // detect line-height from current element height and font-size
              detectLineHeight(element)
            : // no element height likely means programmatic use, so default
              // to a fixed line height
              getDefaultLineHeight(element.fontFamily)),
      });

      if (refreshDimensions) {
        element = { ...element, ...refreshTextDimensions(element) };
      }
      return element;
    case "freedraw": {
      return restoreElementWithProperties(element, {
        points: element.points,
        lastCommittedPoint: null,
        simulatePressure: element.simulatePressure,
        pressures: element.pressures,
      });

Review comment (suggestion):
```suggestion
        // line-height might not be specified either when creating elements
```

Code after:
const restoreElement = (
  element: Exclude<ExcalidrawElement, ExcalidrawSelectionElement>,
  refreshDimensions = false,
): typeof element | null => {
  switch (element.type) {
    case "text":
      let fontSize = element.fontSize;
      let fontFamily = element.fontFamily;
      if ("font" in element) {
        const [fontPx, _fontFamily]: [string, string] = (
          element as any
        ).font.split(" ");
        fontSize = parseFloat(fontPx);
        fontFamily = getFontFamilyByName(_fontFamily);
      }
      const text = element.text ?? "";

      element = restoreElementWithProperties(element, {
        fontSize,
        fontFamily,
        text,
        textAlign: element.textAlign || DEFAULT_TEXT_ALIGN,
        verticalAlign: element.verticalAlign || DEFAULT_VERTICAL_ALIGN,
        containerId: element.containerId ?? null,
        originalText: element.originalText || text,
        // line-height might not be specified either when creating elements
        // programmatically, or when importing old diagrams.
        // For the latter we want to detect the original line height which
        // will likely differ from our per-font fixed line height we now use,
        // to maintain backward compatibility.
        lineHeight:
          element.lineHeight ||
          (element.height
            ? // detect line-height from current element height and font-size
              detectLineHeight(element)
            : // no element height likely means programmatic use, so default
              // to a fixed line height
              getDefaultLineHeight(element.fontFamily)),
      });

      if (refreshDimensions) {
        element = { ...element, ...refreshTextDimensions(element) };
      }
      return element;
    case "freedraw": {
      return restoreElementWithProperties(element, {
        points: element.points,
        lastCommittedPoint: null,
        simulatePressure: element.simulatePressure,
        pressures: element.pressures,
      });