STEPMAKE_PATH_PROG(GHOSTSCRIPT, gs, OPTIONAL, 8.60)
-STEPMAKE_PATH_PROG(FONTFORGE, fontforge, REQUIRED, 20050624)
+STEPMAKE_PATH_PROG(FONTFORGE, fontforge, REQUIRED, 20090923)
+# For svg woff fonts to work, version 20100501 is required but
+# the build does not break; leave optional until distros ship it.
+STEPMAKE_PATH_PROG(FONTFORGE, fontforge, OPTIONAL, 20100501)
STEPMAKE_PATH_PROG(T1ASM, t1asm, REQUIRED)
$(BRACES:%=$(outdir)/feta-braces-%.otf-table)
FETA_FONTS = $(FETA_MF_FILES:.mf=)
SVG_FILES = $(OTF_FILES:%.otf=%.svg)
+WOFF_FILES = $(OTF_FILES:%.otf=%.woff)
FC_FIND = $(shell $(FCLIST) --verbose 'Century Schoolbook L:style=$(1)' \
| grep 'file:' \
# 2. are not included with teTeX
#
-$(outdir)/emmentaler-%.otf \
-$(outdir)/emmentaler-%.svg: $(outdir)/emmentaler-%.pe \
+$(outdir)/emmentaler-%.otf\
+ $(outdir)/emmentaler-%.svg\
+ $(outdir)/emmentaler-%.woff: $(outdir)/emmentaler-%.pe \
$(outdir)/feta%.pfb \
$(outdir)/feta-noteheads%.pfb \
$(outdir)/feta-alphabet%.pfb \
$(outdir)/feta%.otf-gtable
cd $(outdir) && $(FONTFORGE) -script $(notdir $(basename ,$@).pe)
-$(outdir)/emmentaler-brace.otf \
-$(outdir)/emmentaler-brace.svg: $(outdir)/emmentaler-brace.pe \
+$(outdir)/emmentaler-brace.otf\
+ $(outdir)/emmentaler-brace.svg\
+ $(outdir)/emmentaler-brace.woff: $(outdir)/emmentaler-brace.pe \
$(foreach s,$(BRACES),$(outdir)/feta-braces-$(s).pfb) \
$(outdir)/emmentaler-brace.otf-table $(outdir)/emmentaler-brace.otf-gtable
cd $(outdir) && $(FONTFORGE) -script emmentaler-brace.pe
$(outdir)/emmentaler-brace.otf-gtable \
$(outdir)/emmentaler-brace.pe
-$(outdir)/emmentaler-brace.otf \
-$(outdir)/emmentaler-brace.svg: $(BRACES:%=$(outdir)/feta-braces-%.pfb)
+$(outdir)/emmentaler-brace.otf\
+ $(outdir)/emmentaler-brace.svg\
+ $(outdir)/emmentaler-brace.woff: $(BRACES:%=$(outdir)/feta-braces-%.pfb)
$(outdir)/emmentaler-brace.fontname:
echo -n 'emmentaler-brace' > $@
$(OTF_TABLES) \
$(NCSB_OTFS) \
$(OTF_FILES) \
- $(SVG_FILES)
+ $(SVG_FILES) \
+ $(WOFF_FILES)
# PRE_INSTALL=$(MAKE) "$(ALL_GEN_FILES)"
$(NCSB_OTFS)
INSTALLATION_OUT_DIR2 = $(local_lilypond_datadir)/fonts/svg
-INSTALLATION_OUT_FILES2 = $(SVG_FILES)
+INSTALLATION_OUT_FILES2 = $(SVG_FILES) $(WOFF_FILES)
export MFINPUTS := .:$(MFINPUTS)
Generate("emmentaler-brace.otf");
Generate("emmentaler-brace.svg");
+Generate("emmentaler-brace.woff");
(define (svg-end)
(ec 'svg))
+(define (woff-header)
+ "TODO:
+ * dynamically add fonts based on usage
+ * add (ly:version) to font name
+ * copy woff font with version alongside svg output
+"
+ (string-append
+ (eo 'defs)
+ (eo 'style '(text . "style/css"))
+ " <![CDATA[
+ @font-face {
+ font-family: 'emmentaler-20';
+ font-weight: normal;
+ font-style: normal;
+ src: url('emmentaler-20.woff');
+ }
+ ]]>
+ "
+ (ec 'style)
+ (ec 'defs)))
+
(define (dump-page paper filename page page-number page-count)
(let* ((outputter (ly:make-paper-outputter (open-file filename "wb") 'svg))
(dump (lambda (str) (display str (ly:outputter-port outputter))))
(dump (svg-begin page-width page-height
0 0 device-width device-height))
+ (if (ly:get-option 'svg-woff)
+ (dump (woff-header)))
(dump (comment (format "Page: ~S/~S" page-number page-count)))
(ly:outputter-output-scheme outputter
`(begin (set! lily-unit-length ,unit-length)
(dump (svg-begin svg-width svg-height
left-x (- top-y) device-width device-height))
+ (if (ly:get-option svg-woff)
+ (dump (woff-header)))
(ly:outputter-output-scheme outputter
`(begin (set! lily-unit-length ,unit-length)
""))
`FILE.graph'.")
(trace-scheme-coverage #f
"Record coverage of Scheme files in `FILE.cov'.")
- (show-available-fonts #f
+ ; `'"
+(show-available-fonts #f
"List available font names.")
+ (svg-woff #f
+"Use woff font files in SVG backend.")
(verbose ,(ly:command-line-verbose?)
"Value of the --verbose flag (read-only).")
(warning-as-error #f
(cache-font font-file scaled-size glyph)
(ly:warning (_ "cannot find SVG font ~S") font-file))))
+(define embedded #f)
+
+(define (woff-font-smob-to-text font expr)
+ (let* ((name-style (font-name-style font))
+ (scaled-size (modified-font-metric-font-scaling font))
+ (font-file (ly:find-file (string-append name-style ".woff")))
+ (charcode (ly:font-glyph-name-to-charcode font expr))
+ (text (format #f "&#~S;" charcode)))
+ (define alist '())
+ (define (set-attribute attr val)
+ (set! alist (assoc-set! alist attr val)))
+ (set-attribute 'font-family name-style)
+ (set-attribute 'font-size scaled-size)
+ (apply entity 'text text (reverse! alist))))
+
+(define font-smob-to-text
+ (if (not (ly:get-option 'svg-woff))
+ font-smob-to-path woff-font-smob-to-text))
(define (fontify font expr)
(if (string? font)
(pango-description-to-text font expr)
- (font-smob-to-path font expr)))
+ (font-smob-to-text font expr)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; stencil outputters
(define (embedded-svg string)
string)
-(define (glyph-string font size cid glyphs)
+(define (embedded-glyph-string font size cid glyphs)
(define path "")
(if (= 1 (length glyphs))
(set! path (music-string-to-path font size (car glyphs)))
(set! next-horiz-adv 0.0)
path)
+(define (woff-glyph-string font size cid glyphs)
+ (named-glyph font glyphs))
+
+(define glyph-string
+ (if (not (ly:get-option 'svg-woff)) embedded-glyph-string woff-glyph-string))
+
(define (grob-cause offset grob)
"")
Generate("%(filename)s-%(design_size)d.otf");
Generate("%(filename)s-%(design_size)d.svg");
+Generate("%(filename)s-%(design_size)d.woff");
''' % vars()
basename = '%s-%d' % (filename, design_size)