Skip to content

Add support for static ttf fonts files . #1601

Closed
@miky2k

Description

@miky2k

I supose it's only nedded to add a line here:

static String getContentType(const String& path) {
if (path.endsWith(".html")) return "text/html";
else if (path.endsWith(".htm")) return "text/html";
else if (path.endsWith(".css")) return "text/css";
else if (path.endsWith(".txt")) return "text/plain";
else if (path.endsWith(".js")) return "application/javascript";
else if (path.endsWith(".png")) return "image/png";
else if (path.endsWith(".gif")) return "image/gif";
else if (path.endsWith(".jpg")) return "image/jpeg";
else if (path.endsWith(".ico")) return "image/x-icon";
else if (path.endsWith(".svg")) return "image/svg+xml";
else if (path.endsWith(".xml")) return "text/xml";
else if (path.endsWith(".pdf")) return "application/pdf";
else if (path.endsWith(".zip")) return "application/zip";
else if (path.endsWith(".ttf")) return "font/ttf";
else if(path.endsWith(".gz")) return "application/x-gzip";
return "application/octet-stream";
}

The line added worksforme!

Activity

hallard

hallard commented on Feb 10, 2016

@hallard
Contributor

correct it's there ;)
I added font/woff and font/woff2 for bootstrap in my code also

I strongly recommend activate browser caching for SPIFFS to avoid requesting font each time
server.serveStatic("/", SPIFFS, "/", "max-age=86400");

added this to the 2.2.0 milestone on Feb 29, 2016
added a commit that references this issue on Mar 5, 2016

Merge pull request #1724 from marvinroger/patch-1

c78c37b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @hallard@igrr@miky2k

        Issue actions

          Add support for static ttf fonts files . · Issue #1601 · esp8266/Arduino