diff --git a/Makefile b/Makefile index 74b3d06..d09b788 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,27 @@ -pdfs := $(wildcard tmp/*.pdf) +all: pdfs font-list -all: $(pdfs) +pdfs: $(wildcard tmp/*.pdf) %.pdf: %.out @gropdf -d < $^ > $@ -watch:; @watchman -- trigger . _ 'tmp/*.out' -- make all -unwatch:; @watchman -- watch-del . + +font-list := test/fixtures/pdf-fonts +font-list: $(font-list).pdf + +$(font-list).pdf: $(font-list).roff + @ groff -Tpdf -Z $(if $(VERBOSE),-rV1) $< \ + | tee $(font-list).out \ + | gropdf -d > $@ + + +watch = watchman -- trigger . $(1) '$(2)' -- make $(1) + +watch: + @$(call watch,pdfs,tmp/*.out) + @$(call watch,font-list,$(font-list).roff) + +unwatch: + @watchman -- watch-del . .PHONY: watch unwatch diff --git a/lib/postproc/canvas.js b/lib/postproc/canvas.js index 6d3981b..64ad0d6 100644 --- a/lib/postproc/canvas.js +++ b/lib/postproc/canvas.js @@ -45,6 +45,7 @@ class CanvasRenderer extends Postprocessor{ resetFontStyles(){ this.fixKerning = true; + this.fixQuotes = true; this.fontStyles = Object.assign({}, fontStyles); this.fonts = [0, 0, 0, 0, 0, 0, "S", "ZD"]; this.fonts.forEach((font, index) => { @@ -586,6 +587,7 @@ class CanvasRenderer extends Postprocessor{ print(text){ + text = this.remapChars(text); this.context.save(); if(null !== this.tm){ this.context.translate(this.x, this.y); @@ -623,6 +625,13 @@ class CanvasRenderer extends Postprocessor{ } + remapChars(data){ + return this.fixQuotes + ? data.replace(/`/g, "\u{2018}").replace(/'/g, "\u{2019}") + : data; + } + + setColour(data){ this.colour = this.parseColour(data); this.context.fillStyle = this.colour; diff --git a/preview-canvas.html b/preview-canvas.html index bf13e28..916038e 100644 --- a/preview-canvas.html +++ b/preview-canvas.html @@ -4,6 +4,7 @@ + Canvas Preview @@ -27,7 +29,7 @@