Draft article about fonts (#95)

Former-commit-id: 002f55748d12811f0c8bf0d9b3df9a6674274cdd
This commit is contained in:
David Himmelstrup 2020-06-24 22:02:09 +08:00 committed by GitHub
commit c8d9fa6204
4 changed files with 46 additions and 0 deletions

4
docs/fonts.md Normal file
View file

@ -0,0 +1,4 @@
# Fonts and svg text nodes
# Fonts and $\LaTeX$

29
examples/fonts_latex.hs Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env stack
-- stack runghc --package reanimate
{-# LANGUAGE OverloadedStrings #-}
module Main
( main
)
where
import Reanimate
import Reanimate.LaTeX
import Reanimate.Builtin.Documentation
main :: IO ()
main =
reanimate
$ docEnv
$ staticFrame 1
$ withFillColor "black"
$ withFillOpacity 1
$ mkGroup
[ latex "Computer Modern"
, translate 0 (-2)
$ latexWithHeaders ["\\usepackage{calligra}"] "\\calligra\nGalligra"
, translate (-6) (-2)
$ latexWithHeaders ["\\usepackage{noto}"] "\\normalfont\nNoto"
, translate (-6) 0
$ latexWithHeaders ["\\usepackage{helvet}"] "Helvetica"
]

View file

@ -21,5 +21,7 @@ nav:
- Gluing together animations: glue_tut.md
- Morphology (incomplete): morphology.md
- Voice control: voice.md
- How to:
- Use fonts (incomplete): fonts.md
- Showcase:
- Color Theory: showcase_colortheory.md

View file

@ -2,6 +2,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
module Reanimate.LaTeX
( latex
, latexWithHeaders
, latexChunks
, xelatex
, latexAlign
@ -43,6 +44,16 @@ latex tex =
args = []
script = mkTexScript exec args [] tex
latexWithHeaders :: [T.Text] -> T.Text -> Tree
latexWithHeaders _headers tex | pNoExternals = mkText tex
latexWithHeaders headers tex =
(unsafePerformIO . (cacheMem . cacheDiskSvg) (latexToSVG "dvi" exec args))
script
where
exec = "latex"
args = []
script = mkTexScript exec args headers tex
latexChunks :: [T.Text] -> [Tree]
latexChunks chunks | pNoExternals = map mkText chunks
latexChunks chunks = worker (svgGlyphs $ latex $ T.concat chunks) chunks