Search code examples
rustyew

How to render a font using Yew rust


I'm trying to make a website using Yew framework(?). I want to use a special font. I downloaded the font and I imported it into html, but Yew used server-side rendering and it doesn't allow me to just import a .ttf file as easily as a static page. Is it even possible with Yew.

This is what I used

@font-face {
    font-family: "terminal";
    src: url(windows_command_prompt.ttf);
}

Solution

  • To use a custom font or to use a file(ie css or images). You have to use the tag in the index.html file and a the data-trunk attribute to the tag. Then, you have to add the right rel tag. You are trying to use a font, so you will just copy the file on the web. It does depend on what file type you are using and what you are going use for to decide what rel tag you need. Read more about it here.

    <link data-trunk rel="copy-file" href="file/path.ttf">