question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fonts aren't displayed

See original GitHub issue

I am trying to embed the EmailEditor via React, everything seems to work fine except the fonts section, the dropdown which is supposed to contain the list of fonts, shows nothing and even the font size selection is a bit off:

the_editor_font_problem_1 the_editor_font_problem_2

Is it a bug with the editor itself? or am I doing something wrong:

Code:

import {
  Button,
  Box,
  Container,
  Grid,
  Hidden,
  Typography,
  AppBar,
} from "@material-ui/core";
import clsx from "clsx";
import React, { useRef } from "react";
import EmailEditor from "react-email-editor";
import { useSelector } from "react-redux";
import { useStyles } from "./emailBuilder.css";

import { selectOpen } from "../../redux/utils";
import { TemplatesNav } from "./TemplatesNav";
import Component from "react-email-editor";

export function EmailBuilder() {
  const emailEditorRef = useRef<Component>(null);

  const onLoad = () => {
    // you can load your template here;
    // const templateJson = {};
    // emailEditorRef.current.editor.loadDesign(templateJson);
  };

  const classes = useStyles();

  const drawerOpen = useSelector(selectOpen);

  const [templatesNavOpen, setTemplatesNavOpen] =
    React.useState<boolean>(false);
  const openTemplatesNav =
    () => (event: React.KeyboardEvent | React.MouseEvent) => {
      console.log(templatesNavOpen);
      setTemplatesNavOpen(true);
    };

  const exportHtml = async () => {
    emailEditorRef.current!.exportHtml(
      (data: { design: Object; html: String }) => {
        const { design, html } = data;
        console.log("exportHtml", html);
        console.log("Design JSON", design);
      }
    );
  };

  return (
    <Container maxWidth="xl">
      <Hidden mdDown>
        <AppBar
          position="fixed"
          className={clsx(classes.appBarStyle, {
            [classes.shiftedAppBarStyle]: drawerOpen,
          })}
          elevation={0}
        >
          <Box display="flex" m={1} p={1}>
            <Box p={1} flexGrow={1}>
              <Button
                onClick={openTemplatesNav()}
                color="primary"
                variant="contained"
              >
                Templates
              </Button>
            </Box>
            <Box p={1}>
              <Button color="primary" variant="contained">
                Preview
              </Button>
            </Box>
            <Box p={1}>
              <Button color="primary" variant="contained" onClick={exportHtml}>
                Save
              </Button>
            </Box>
          </Box>
        </AppBar>
        <TemplatesNav
          drawerOpen={templatesNavOpen}
          setDrawerOpen={setTemplatesNavOpen}
        />
        <Grid container className={classes.container}>
          <EmailEditor ref={emailEditorRef} onLoad={onLoad} />
        </Grid>
      </Hidden>
      <Hidden mdUp>
        <Typography variant="h5">
          Shoot !! We do not support designing on mobiles yet
        </Typography>
      </Hidden>
    </Container>
  );
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
fedotxxlcommented, Dec 30, 2021

same issuer on Ubuntu, fixed with showDefaultFonts: false, not sure is it correct solution

1reaction
lf-devscommented, Dec 2, 2021

@amartya-dev here is the solution for fonts

<EmailEditor
                            ref={emailEditorRef}
                            exportHtml={exportHtml}
                            options={{
                                appearance: {
                                    theme: "dark",
                                },
                                features: {
                                    textEditor: {
                                        fontSizes: ["70px", "60px", "50px"],
                                    },
                                },
                                fonts: {
                                    showDefaultFonts: false,
                                    customFonts: [
                                        {
                                            label: "Comic Sans",
                                            value: "'Comic Sans MS', cursive, sans-serif",
                                        },
                                        {
                                            label: "DotGothic16",
                                            value: "'DotGothic16',cursive",
                                            url: "https://fonts.googleapis.com/css?family=DotGothic16",
                                        },
                                    ],
                                },
                            }}
                            onLoad={onLoad}
                            onReady={onReady} />
                            ```
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Installed" fonts not showing up in Windows Fonts folder
Click Start, point to Settings, and then click Control Panel. · Double-click Fonts. · On the File menu, click Fonts to place a...
Read more >
Fix Installed fonts not showing up in font folder on Windows 10 ...
Fix 2 – Install Font from Control Panel · 1. Search control panel in windows 10 search. · 2. Click on the search...
Read more >
How to fix installed fonts not showing on Windows 10
Installed fonts not showing on Windows 10 [FIX] · 1. Restart app · 2. Check other apps · 3. Reinstall font · 4....
Read more >
Troubleshooting Installed Fonts That Won't Work - Lifewire
Easiest fix: Download and reinstall the correct version of the file, making sure the font is compatible with your operating system.
Read more >
What to do when Windows won't allow some fonts to install.
Having said this, also be sure you are dragging actual font files with extensions like .ttf or .otf into the Windows fonts folder...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found