-
Notifications
You must be signed in to change notification settings - Fork 2
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
Generate SelfContained Font Kits #4
Comments
The idea would be to create a payload and expand it to a css file using a mustache template (which you can see below. Let me illustrate with an example. The make_dataURI <- function(font){
font$dataURI = base64enc::dataURI(font$file,
mime = sprintf('data:application/x-font-', font$format)
)
return(font)
}
make_fonts <- function(fonts, template, destfile = 'fonts.css'){
fonts <- lapply(fonts, make_dataURI)
css = paste(capture.output(cat(whisker.render(template, list(fonts = fonts)))), collapse = "\n")
cat(css, file = destfile)
return(css)
}
fonts = list(
list(name = 'Open Sans', weight = 400, style = normal, format = 'wott', file = 'Open Sans.wott'),
list(name = 'PT Sans', ...)
)
make_fonts(fonts) Here is the mustache template to use. {{# fonts }}
@font-face {
font-family: '{{{ name }}}';
font-style: {{{ style }}};
font-weight: {{{ weight }}};
src: url({{{ dataURI }}}) format('{{{ format }}}');
}
{{/ fonts }} |
Thanks for the outline! I'll get to work on this. |
I hope to have something viable tomorrow but you can track the progress here: https://github.com/seankross/cosmofont |
This is looking good. A few ideas
|
By using the Google Fonts API and including httr as a dependency I believe I can include functionality where a user can specify the name, weight, and style of a Google Font so that cosmofont can |
Oh that would be brilliant! Nice idea. |
And another note. Make yourself the author and maintainer, since you are doing all the hard work. You can add me as a contributor. |
Will do, but this couldn't have happened without you! |
Let me know if this works for you: https://github.com/seankross/cosmofont You can install cosmofont with:
Any comments or questions about the code, API, documentation, or anything else are welcome! |
Here is a rough sketch of how I think this could work
The text was updated successfully, but these errors were encountered: