Skip to content

Commit

Permalink
Merge pull request #19 from attakei/feture/google-fonts
Browse files Browse the repository at this point in the history
Enable google-fonts
  • Loading branch information
attakei committed Nov 10, 2019
2 parents 9950cf7 + d738d9a commit f52b596
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions sphinx_revealjs/directives.py
Expand Up @@ -68,6 +68,7 @@ def run(self): # noqa: D102
class RevealjsSlide(Directive): # noqa: D101
option_spec = {
'theme': directives.unchanged,
'google_font': directives.unchanged,
'config': raw_json,
}

Expand Down
9 changes: 9 additions & 0 deletions sphinx_revealjs/themes/sphinx_revealjs/page.html
Expand Up @@ -20,6 +20,15 @@
{% else %}
<link rel="stylesheet" href="{{ pathto('_static/revealjs/css/theme/'+ theme_revealjs_theme + '.css', 1) }}" />
{% endif %}
{# Google Fonts #}
{% if revealjs_slide and revealjs_slide.google_font %}
<link href="https://fonts.googleapis.com/css?family={{ revealjs_slide.google_font|replace(' ', '+') }}&display=swap" rel="stylesheet" >
<style>
body {
font-family: '{{ revealjs_slide.google_font }}', sans-serif;
}
</style>
{% endif %}
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( "link" );
Expand Down
11 changes: 11 additions & 0 deletions tests/test_docs.py
Expand Up @@ -63,3 +63,14 @@ def test_theme_by_directive(self, app, status, warning):
assert '<h1>Test for selecatable theme</h1>' in html
theme_url_path = f'_static/solarized.css'
assert theme_url_path in html


class SlideFontTesting(unittest.TestCase):
"""Test case for Reveal.js webfont settings"""
@with_app(**gen_testdoc_conf())
def test_theme_by_directive(self, app, status, warning):
app.build()
html = (app.outdir / 'webfont_set.html').read_text()
assert '<h1>Test for selecatable theme</h1>' in html
assert 'Noto Sans JP' in html
assert 'Noto+Sans+JP' in html
8 changes: 8 additions & 0 deletions tests/testdocs/default/webfont_set.rst
@@ -0,0 +1,8 @@
Test for selecatable theme
==========================

.. revealjs_slide::
:google_font: Noto Sans JP
:theme: solarized

Hello

0 comments on commit f52b596

Please sign in to comment.