mirror of
https://github.com/sdiehl/wiwinwlh.git
synced 2024-10-05 16:08:22 +03:00
Fixing missing unicode characters in rendered PDF (#177)
* Tweaking fonts to support unicode characters + making it pretty * Adding unicode mapping to math symbols for missing characters * Trying older ghc to fix the CI build issues
This commit is contained in:
parent
9ef11984e0
commit
d429c2e21b
10
Makefile
10
Makefile
@ -3,6 +3,7 @@ IFORMAT = markdown
|
||||
TEMPLATE = resources/page.tmpl
|
||||
LTEMPLATE = resources/page.latex
|
||||
ETEMPLATE = resources/page.epubt
|
||||
UNICODE_MAP = resources/unicodemapping.tex
|
||||
FLAGS = --standalone \
|
||||
--toc \
|
||||
--toc-depth=2 \
|
||||
@ -12,10 +13,11 @@ FLAGS = --standalone \
|
||||
GHC=ghc
|
||||
|
||||
HTML = tutorial.html
|
||||
PDF = tutorial.pdf
|
||||
|
||||
# Check if sandbox exists. If it does, then use it instead.
|
||||
|
||||
all: $(HTML)
|
||||
all: $(HTML) $(PDF)
|
||||
|
||||
includes: includes.hs
|
||||
$(GHC) --make $< ; \
|
||||
@ -30,14 +32,14 @@ includes: includes.hs
|
||||
| $(PANDOC) -f $(IFORMAT) -t epub $(FLAGS) -o $@
|
||||
|
||||
%.pdf: %.md includes
|
||||
./includes < $< | $(PANDOC) -c -s -f $(IFORMAT) --template $(LTEMPLATE) --latex-engine=xelatex $(FLAGS) -o $@
|
||||
./includes < $< | $(PANDOC) -c -s -f $(IFORMAT) --template $(LTEMPLATE) --include-in-header $(UNICODE_MAP) --pdf-engine=xelatex $(FLAGS) -o $@
|
||||
|
||||
clean:
|
||||
-rm $(CHAPTERS) $(HTML)
|
||||
-rm $(CHAPTERS) $(HTML) $(PDF)
|
||||
|
||||
# pandoc executable 'includes' is rather large
|
||||
clean-all:
|
||||
rm -rf $(CHAPTERS) $(HTML) includes
|
||||
rm -rf $(CHAPTERS) $(HTML) $(PDF) includes
|
||||
|
||||
# NIX BUILD
|
||||
# Enter nix shell with 'make run-shell' first (then 'make all')
|
||||
|
@ -11,7 +11,6 @@ $if(linestretch)$
|
||||
$endif$
|
||||
\usepackage{amssymb,amsmath}
|
||||
\usepackage{ifxetex,ifluatex}
|
||||
\usepackage{fixltx2e} % provides \textsubscript
|
||||
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
|
||||
\usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
@ -25,6 +24,7 @@ $endif$
|
||||
\usepackage{fontspec}
|
||||
\fi
|
||||
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
|
||||
\setmonofont{DejaVu Sans Mono}
|
||||
$if(euro)$
|
||||
\newcommand{\euro}{€}
|
||||
$endif$
|
||||
|
14
resources/unicodemapping.tex
Normal file
14
resources/unicodemapping.tex
Normal file
@ -0,0 +1,14 @@
|
||||
\newcommand{\sbullet}{%
|
||||
\texorpdfstring{\textsbullet}{\textbullet}%
|
||||
}
|
||||
\DeclareRobustCommand{\textsbullet}{%
|
||||
\unskip~\,\begin{picture}(1,1)(0,-3)\circle*{3}\end{picture}\ %
|
||||
}
|
||||
\usepackage{newunicodechar}
|
||||
\newunicodechar{⊥}{\ensuremath{\bot}}
|
||||
\newunicodechar{⊤}{\ensuremath{\top}}
|
||||
\newunicodechar{∨}{\ensuremath{\vee}}
|
||||
\newunicodechar{∧}{\ensuremath{\wedge}}
|
||||
\newunicodechar{⇒}{\ensuremath{\Rightarrow}}
|
||||
\newunicodechar{•}{\ensuremath{\sbullet}}
|
||||
\newunicodechar{λ}{\ensuremath{\lambda}}
|
@ -1,18 +1,22 @@
|
||||
{ nixpkgs ? <nixpkgs>, compiler ? "ghc843" }:
|
||||
{ pkgs ? import <nixpkgs> {}, compiler ? "ghc843" }: with pkgs;
|
||||
let
|
||||
pkgs = import nixpkgs { };
|
||||
ghcWithDeps = pkgs.haskell.packages.${compiler}.ghcWithPackages
|
||||
( ps: with ps; [ base pandoc containers ] );
|
||||
tex = with pkgs; texlive.combine {
|
||||
inherit (texlive)
|
||||
scheme-small
|
||||
xetex
|
||||
newunicodechar
|
||||
;
|
||||
};
|
||||
fontsConf = makeFontsConf {
|
||||
fontDirectories = [ dejavu_fonts ];
|
||||
};
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "wiwinwlh-env";
|
||||
buildInputs = [ ghcWithDeps tex ];
|
||||
FONTCONFIG_FILE = fontsConf;
|
||||
shellHook = ''
|
||||
export LANG=en_US.UTF-8
|
||||
eval $(egrep ^export ${ghcWithDeps}/bin/ghc)
|
||||
|
Loading…
Reference in New Issue
Block a user