Skip to content

Commit

Permalink
use local version of webfonts in preview
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Feb 3, 2013
1 parent 9e17ea1 commit 04063ac
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/cpp/session/modules/presentation/SessionPresentation.cpp
Expand Up @@ -211,6 +211,20 @@ std::string mathjaxLocal(const std::string& mathjax)
"mathjax");
}

void setLocalWebFonts(std::map<std::string,std::string>* pVars)
{
(*pVars)["news_cycle_webfont_url"] = "revealjs/fonts/NewsCycle.css";
(*pVars)["lato_webfont_url"] = "revealjs/fonts/Lato.css";
}

void setRemoteWebFonts(std::map<std::string,std::string>* pVars)
{
(*pVars)["news_cycle_webfont_url"] =
"http://fonts.googleapis.com/css?family=News+Cycle:400,700";
(*pVars)["lato_webfont_url"] =
"http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic";
}

void handleRangeRequest(const FilePath& targetFile,
const http::Request& request,
http::Response* pResponse)
Expand Down Expand Up @@ -453,6 +467,9 @@ void handlePresentationPaneRequest(const http::Request& request,
vars["reveal_head_js"] = revealEmbed("revealjs/lib/js/head.min.js");
vars["reveal_js"] = revealEmbed("revealjs/js/reveal.min.js");

// webfonts w/ remote url
setRemoteWebFonts(&vars);

// mathjax w/ remote url
vars["mathjax"] = mathjaxIfRequired(slides);

Expand Down Expand Up @@ -482,6 +499,9 @@ void handlePresentationPaneRequest(const http::Request& request,
vars["reveal_head_js"] = revealLink("revealjs/lib/js/head.min.js");
vars["reveal_js"] = revealLink("revealjs/js/reveal.js");

// webfonts local
setLocalWebFonts(&vars);

// mathjax local
vars["mathjax"] = mathjaxLocal(vars["mathjax"]);

Expand Down
@@ -1,5 +1,3 @@
@import url(http://fonts.googleapis.com/css?family=News+Cycle:400,700);
@import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic);
/**
* A simple theme for reveal.js presentations, similar
* to the default theme. The accent color is darkblue.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions src/cpp/session/resources/presentation/revealjs/fonts/Lato.css
@@ -0,0 +1,24 @@
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 400;
src: local('Lato Regular'), local('Lato-Regular'), url('Lato-Regular.ttf') format('truetype');
}
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 700;
src: local('Lato Bold'), local('Lato-Bold'), url('Lato-Bold.ttf') format('truetype');
}
@font-face {
font-family: 'Lato';
font-style: italic;
font-weight: 400;
src: local('Lato Italic'), local('Lato-Italic'), url('Lato-Italic.ttf') format('truetype');
}
@font-face {
font-family: 'Lato';
font-style: italic;
font-weight: 700;
src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url('Lato-BoldItalic.ttf') format('truetype');
}
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
@font-face {
font-family: 'News Cycle';
font-style: normal;
font-weight: 400;
src: local('News Cycle Regular'), local('NewsCycle-Regular'), url('NewsCycle-Regular.ttf') format('truetype');
}
@font-face {
font-family: 'News Cycle';
font-style: normal;
font-weight: 700;
src: local('News Cycle Bold'), local('NewsCycle-Bold'), url('NewsCycle-Bold.ttf') format('truetype');
}
6 changes: 6 additions & 0 deletions src/cpp/session/resources/presentation/slides.html
Expand Up @@ -5,6 +5,12 @@
<meta charset="utf-8">
<title>#!title#</title>

<!-- web fonts -->
<style type="text/css">
@import url('#!news_cycle_webfont_url#');
@import url('#!lato_webfont_url#');
</style>

<!-- reveal.js -->
#!reveal_css#
#!reveal_theme_css#
Expand Down

0 comments on commit 04063ac

Please sign in to comment.