Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for static ttf fonts files . #1601

Closed
miky2k opened this issue Feb 8, 2016 · 1 comment
Closed

Add support for static ttf fonts files . #1601

miky2k opened this issue Feb 8, 2016 · 1 comment

Comments

@miky2k
Copy link

miky2k commented Feb 8, 2016

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!

@hallard
Copy link
Contributor

hallard commented Feb 10, 2016

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");

@igrr igrr added this to the 2.2.0 milestone Feb 29, 2016
Links2004 added a commit that referenced this issue Mar 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants