* lily/open-type-font.cc (attachment_point): new function.
(load_table): read LILC table
* buildscripts/gen-bigcheese-scripts.py (Module): new
file. Generate FF scripts.
* mf/feta-din10.mf: idem.
* mf/feta-nummer10.mf: remove mf files.
* mf/feta-alphabet.mf (dynamic_design_size): merge din and number font.
+2004-12-12 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/dots.cc (print): replace -
+
+ * lily/open-type-font.cc (attachment_point): new function.
+ (load_table): read LILC table
+
+ * buildscripts/gen-bigcheese-scripts.py (Module): new
+ file. Generate FF scripts.
+
+ * mf/feta-din10.mf: idem.
+
+ * mf/feta-nummer10.mf: remove mf files.
+
+ * mf/feta-alphabet.mf (dynamic_design_size): merge din and number font.
+
2004-12-12 Jan Nieuwenhuizen <janneke@gnu.org>
* lily/lily-guile.cc: Use scm_from_locale_stringn.
--- /dev/null
+#!@PYTHON@
+import sys
+import getopt
+import re
+import os
+
+(options, files) = \
+ getopt.getopt (sys.argv[1:],
+ '',
+ ['dir='])
+
+
+outdir = ''
+for opt in options:
+ o = opt[0]
+ a = opt[1]
+ if o == '--dir':
+ outdir = a
+ else:
+ print o
+ raise getopt.error
+
+
+for design_size in [11,13,14,16,18,20,23,26]:
+ name = 'bigcheese'
+ script = '''#!@FONTFORGE@
+New();
+
+# Separate Feta versioning?
+# Naming: * expose LilyPond20/LilyPond rather than %(name)s
+# * using 20 as Weight works for gnome-font-select widget: gfs
+SetFontNames("%(name)s%(design_size)d", "LilyPond", "LilyPond %(name)s %(design_size)d", "%(design_size)d", "GNU GPL", "@TOPLEVEL_VERSION@");
+
+MergeFonts("feta%(design_size)d.pfa");
+MergeFonts("parmesan%(design_size)d.pfa");
+
+# load nummer/din after setting PUA.
+i = 0;
+while (i < CharCnt())
+ Select(i);
+# crashes fontforge, use PUA for now -- jcn
+# SetUnicodeValue(i + 0xF0000, 0);
+/*
+PRIVATE AREA
+ In the BMP, the range 0xe000 to 0xf8ff will never be assigned to any
+ characters by the standard and is reserved for private usage. For the
+ Linux community, this private area has been subdivided further into the
+ range 0xe000 to 0xefff which can be used individually by any end-user
+ and the Linux zone in the range 0xf000 to 0xf8ff where extensions are
+ coordinated among all Linux users. The registry of the characters
+ assigned to the Linux zone is currently maintained by H. Peter Anvin
+ <Peter.Anvin@linux.org>.
+*/
+ SetUnicodeValue(i + 0xE000, 0);
+ ++i;
+endloop
+
+
+MergeFonts("feta-alphabet%(design_size)d.pfa");
+MergeKern("feta-alphabet%(design_size)d.tfm");
+
+LoadTableFromFile("LILC", "feta%(design_size)d.otf-table")
+
+Generate("%(name)s%(design_size)d.otf");
+Generate("%(name)s%(design_size)d.cff");''' % vars()
+
+ path = os.path.join (outdir, name + '%d' % design_size + '.pe')
+ open (path, 'w').write (script)
+
+ path = os.path.join (outdir, name + '%d' % design_size + '.dep')
+
+ deps = r'''%(name)s%(design_size)d.otf: $(outdir)/feta%(design_size)d.pfa \
+ $(outdir)/parmesan%(design_size)d.pfa \
+ $(outdir)/feta-alphabet%(design_size)d.pfa
+''' % vars()
+ open (path, 'w').write (deps)
def conv_char_metric (charmetric):
f = 1.0
- s = """((%s .
-(bbox . (%f %f %f %f))
-(attachment . (%f %f))))
+ s = """(%s .
+((bbox . (%f %f %f %f))
+ (attachment . (%f . %f))))
""" %(charmetric['name'],
-charmetric['breapth'] * f,
-charmetric['depth'] * f,
if (scm_is_number (c))
{
- Stencil d = Font_interface::get_default_font (sc)->find_by_name (String ("dots-dot"));
+ Stencil d = Font_interface::get_default_font (sc)->find_by_name (String ("dots.dot"));
Real dw = d.extent (X_AXIS).length ();
scm_int2num (code));
return scm_to_int (s);
}
+
+Offset
+Font_metric::attachment_point (String str) const
+{
+ return Offset (0, 0);
+}
String file_name_;
virtual int count () const;
+ virtual Offset attachment_point (String) const;
virtual Offset get_indexed_wxwy (int) const;
virtual Box get_indexed_char (int index) const;
virtual Box get_ascii_char (int ascii) const;
class Open_type_font : public Font_metric
{
- FT_Face face_; /* handle to face object */
+ FT_Face face_; /* handle to face object */
+ SCM lily_character_table_;
+ Open_type_font();
public:
static SCM make_otf (String);
virtual ~Open_type_font();
+ virtual Offset attachment_point (String) const;
virtual Box get_indexed_char (int) const;
virtual int name_to_index (String) const;
-
+ virtual void derived_mark () const;
#if 0
virtual int count () const;
virtual int index_to_ascii (int) const;
#include <stdio.h>
+#include <freetype/tttables.h>
+
#include "warn.hh"
#include "open-type-font.hh"
#include "dimensions.hh"
+FT_Byte *
+load_table (char const *tag_str, FT_Face face)
+{
+ FT_ULong length = 0;
+ FT_ULong tag = FT_MAKE_TAG(tag_str[0], tag_str[1], tag_str[2], tag_str[3]);
+
+ int error_code = FT_Load_Sfnt_Table (face, tag, 0, NULL, &length);
+ if (!error_code)
+ {
+ FT_Byte*buffer = (FT_Byte*) malloc (length);
+ if (buffer == NULL)
+ error ("Not enough memory");
+
+ error_code = FT_Load_Sfnt_Table (face, tag, 0, buffer, &length );
+ if (error_code)
+ {
+ error (_f ("Could not load %s font table", tag_str));
+ }
+
+ return buffer;
+ }
+
+ return 0 ;
+}
+
+
SCM
Open_type_font::make_otf (String str)
{
error ("Unknown error reading font file.");
}
+
+ FT_Byte* buffer =load_table ("LILC", otf->face_);
+ if (buffer)
+ {
+ String contents ((char const*)buffer);
+ contents = "(quote " + contents + ")";
+
+ SCM alist = scm_c_eval_string (contents.to_str0());
+ otf->lily_character_table_ = alist_to_hashq (alist);
+ free (buffer);
+ }
+
return otf->self_scm ();
}
+Open_type_font::Open_type_font()
+{
+ lily_character_table_ = SCM_EOL;
+}
+
+void
+Open_type_font::derived_mark () const
+{
+ scm_gc_mark (lily_character_table_);
+}
+
+Offset
+Open_type_font::attachment_point (String glyph_name) const
+{
+ SCM sym = ly_symbol2scm (glyph_name.to_str0 ());
+ SCM entry = scm_hashq_ref (lily_character_table_, sym, SCM_BOOL_F);
+
+ Offset o;
+ if (entry == SCM_BOOL_F)
+ return o;
+
+ SCM char_alist = entry;
+
+ SCM att_scm =scm_cdr (scm_assq (char_alist, ly_symbol2scm ("attachment")));
+
+ return ly_scm2offset (att_scm);
+}
+
+
Open_type_font::~Open_type_font()
{
FT_Done_Face (face_);
# We don't use $(MF_FILES), because there's more .mf cruft here
FETA_MF_FILES = $(wildcard feta[0-9]*.mf)\
$(wildcard feta-braces-[a-z].mf)\
- $(wildcard feta-din*[0-9].mf)\
- $(wildcard feta-nummer*[0-9].mf)\
+ $(wildcard feta-alphabet*[0-9].mf)\
$(wildcard parmesan[0-9]*.mf)
+STAFF_SIZES=11 13 14 16 18 20 23 26
+
+CHEESES=$(addsuffix .otf,$(addprefix $(outdir)/bigcheese,$(STAFF_SIZES)))
+PE_SCRIPTS=$(addsuffix .pe, $(addprefix $(outdir)/bigcheese,$(STAFF_SIZES))) \
+ $(addsuffix .dep, $(addprefix $(outdir)/bigcheese,$(STAFF_SIZES)))
+OTF_TABLES=$(addsuffix .otf-table, $(addprefix $(outdir)/feta,$(STAFF_SIZES)))
FETA_FONTS = $(FETA_MF_FILES:.mf=)
-XPM_FONTS = feta20 feta-din10 feta-nummer10 feta-braces20 parmesan20
+
LOG_FILES = $(FETA_MF_FILES:%.mf=$(outdir)/%.log)
TEXTABLES = $(FETA_MF_FILES:%.mf=$(outdir)/%.tex)
$(outdir)/feta20.otf-table:
cat $(outdir)/feta20.lisp $(outdir)/parmesan20.lisp > $@
-$(outdir)/bigcheese20.otf: $(outdir)/bigcheese.pe $(outdir)/feta20.otf-table
- (cd $(outdir) && fontforge -script bigcheese.pe)
+$(outdir)/%.otf: $(outdir)/%.pe
+ (cd $(outdir) && fontforge -script $(notdir $<))
+
+$(outdir)/%.otf-table: $(outdir)/%.lisp
+ cat $< $(subst parmesan,feta,$<) > $@
+
+
+
+$(PE_SCRIPTS):
+ $(PYTHON) $(buildscript-dir)/gen-bigcheese-scripts.py --dir=$(outdir)
+
+include $(outdir)/bigcheese20.dep
+
+foo:
+ echo $(CHEESES)
## use separate package sauter-fonts-mftraced.
SAUTER_FONTS =
# Make tfm files first, log files last,
# so that normally log files aren't made twice
-ALL_GEN_FILES= $(TFM_FILES) $(TEXTABLES) $(AFM_FILES) $(TFM_FILES) $(LOG_FILES) $(ENC_FILES) $(FETA_LIST_FILES) $(PFA_FILES) $(outdir)/lilypond.map $(outdir)/fonts.scale $(outdir)/Fontmap.lily
+ALL_GEN_FILES= $(TFM_FILES) $(TEXTABLES) $(AFM_FILES) $(TFM_FILES) $(LOG_FILES) $(ENC_FILES) $(FETA_LIST_FILES) $(OTF_TABLES) $(PFA_FILES) $(outdir)/lilypond.map $(outdir)/fonts.scale $(outdir)/Fontmap.lily $(CHEESES)
#PRE_INSTALL=$(MAKE) "$(ALL_GEN_FILES)"
INSTALLATION_DIR=$(local_lilypond_datadir)/fonts/source
#!@FONTFORGE@
+
+
New();
# Separate Feta versioning?
--- /dev/null
+
+
+test:=0;
+
+input feta-autometric;
+input feta-macros;
+
+fet_beginfont("feta-alphabet", staffheight, "fetaNumber");
+
+mode_setup;
+
+number_design_size := staffheight/2;
+dynamic_design_size := 14 staffheight / 20;
+
+
+input feta-nummer-code;
+input feta-din-code;
+
+fet_endfont("feta-nummer");
+
--- /dev/null
+% part of LilyPond's pretty-but-neat music font
+
+staffheight := 11.22;
+input feta-alphabet;
+end.
+
--- /dev/null
+% part of LilyPond's pretty-but-neat music font
+
+staffheight := 12.60;
+input feta-alphabet;
+end.
+
--- /dev/null
+% part of LilyPond's pretty-but-neat music font
+
+staffheight := 14.14;
+input feta-alphabet;
+end.
+
--- /dev/null
+% part of LilyPond's pretty-but-neat music font
+
+staffheight := 15.87;
+input feta-alphabet;
+end.
+
--- /dev/null
+% part of LilyPond's pretty-but-neat music font
+
+staffheight := 17.82;
+input feta-alphabet;
+end.
+
--- /dev/null
+% feta-alphabet20.mf
+% part of LilyPond's pretty-but-neat music font
+
+staffheight := 20;
+input feta-alphabet;
+end.
+
--- /dev/null
+% feta-alphabet20.mf
+% part of LilyPond's pretty-but-neat music font
+
+staffheight := 22.45;
+input feta-alphabet;
+end.
+
--- /dev/null
+% part of LilyPond's pretty-but-neat music font
+
+staffheight := 17.82;
+input feta-alphabet;
+end.
+
+
+ex# := (dynamic_design_size / 2.4)* pt#;
+descender# := 0.5 ex#;
+ascender# := 0.72 ex#;
+staffspace# := 1.75 / 2.0 * ex#;
+
+
+%% !! synchronize with feta-params.mf
+linethickness# := 0.3 pt# + 0.04 staffspace#;
+stafflinethickness# := stafflinethickness#;
+
+horizontal_space# := .66 ex#;
+
+font_x_height ex#;
+font_normal_space horizontal_space#;
+
+define_pixels (staffspace, linethickness, stafflinethickness, ex, descender, ascender);
+
+
+
%%
%
% TODO: blot diameter should be fixed, not scalable.
% input feta-params;
mode_setup;
-ex# := (design_size / 2.4)* pt#;
-descender# := 0.5 ex#;
-ascender# := 0.72 ex#;
-staffspace# := 1.75 / 2.0 * ex#;
-
-
-%% !! synchronize with feta-params.mf
-linethickness# := 0.3 pt# + 0.04 staffspace#;
-stafflinethickness# := stafflinethickness#;
-
-horizontal_space# := .66 ex#;
-
-font_x_height ex#;
-font_normal_space horizontal_space#;
-
-define_pixels (staffspace, linethickness, stafflinethickness, ex, descender, ascender);
-
-fet_beginfont("feta-din", design_size, "TeX text");
+fet_beginfont("feta-din", dynamic_design_size, "TeX text");
input feta-din-code;
+++ /dev/null
-% feta-din10.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=10; % feta20 = 20pt
-
-input feta-din;
-
-end.
-
+++ /dev/null
-% feta-din12.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=12; % feta16 = 16pt
-
-input feta-din;
-
-end.
-
+++ /dev/null
-% feta-din14.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=14; % feta20 = 20pt
-
-input feta-din;
-
-end.
-
+++ /dev/null
-% feta-din17.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=17; % feta23 = 23pt
-
-input feta-din;
-
-end.
-
+++ /dev/null
-% feta-din6.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=5.5; % feta11 = 11pt
-
-input feta-din.mf;
-
-end.
-
+++ /dev/null
-% feta-din8.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=8; % feta16 = 16pt
-
-input feta-din.mf;
-
%
% (c) 1997--2004 Jan Nieuwenhuizen <janneke@gnu.org>
+
+
+height#:= number_design_size;
+space# := number_design_size/2;
+
+font_x_height height#;
+font_normal_space space#;
+
+
+%
+% DOCME!
+%ugh. b and h are reused.
+%
+
+save b,h; 4h+b=1.15; 10h+b=1;
+fatten:=number_design_size*h+b;
+
+save b,h; 4h+b=1.05; 10h+b=1;
+widen:=number_design_size*h+b;
+
+tense=0.85;
+thick#:=7/30height#*fatten;
+thin#:=thick#/4*fatten + max(.1 (height# / 10 - 1), 0);
+
+%% sqrt(.8 * blot_diameter#* thin#) ;
+hair#:= thin# * .8 ;
+
+
+flare#:=9/8 thick# + .75 (height# / 10 - 1);
+
+save b,h; 4h+b=1/8; 10h+b=1/6;
+kuulleke#:=thick#*number_design_size*h+b;
+foot_top#:=thick#;
+foot_width#:=9/4thick#;
+
+
%
% These numbers were taken from a part that that the EJE violas played
% 1997 -- Probably Mendelssohn's ouverture Heimkehr aus der Fremde.
%blot_diameter# = .4pt#;
-fet_beginfont("feta-nummer", design_size, "fetaNumber");
+fet_beginfont("feta-nummer", numberdesignsize/2, "fetaNumber");
mode_setup;
-height#:=designsize;
-space# := design_size/2;
-
-font_x_height height#;
-font_normal_space space#;
-
-
-%
-% DOCME!
-%ugh. b and h are reused.
-%
-
-save b,h; 4h+b=1.15; 10h+b=1;
-fatten:=designsize*h+b;
-
-save b,h; 4h+b=1.05; 10h+b=1;
-widen:=designsize*h+b;
-
-tense=0.85;
-thick#:=7/30height#*fatten;
-thin#:=thick#/4*fatten + max(.1 (height# / 10 - 1), 0);
-
-%% sqrt(.8 * blot_diameter#* thin#) ;
-hair#:= thin# * .8 ;
-
-
-flare#:=9/8 thick# + .75 (height# / 10 - 1);
-
-save b,h; 4h+b=1/8; 10h+b=1/6;
-kuulleke#:=thick#*designsize*h+b;
-foot_top#:=thick#;
-foot_width#:=9/4thick#;
input feta-nummer-code;
+++ /dev/null
-% feta-nummer10.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=10; % feta20 = 20pt
-% mode := smoke;
-input feta-nummer;
-
-end.
-
+++ /dev/null
-design_size := 12;
-input feta-nummer;
+++ /dev/null
-design_size := 16;
-input feta-nummer;
+++ /dev/null
-design_size := 20.74;
-input feta-nummer;
+++ /dev/null
-design_size := 23;
-input feta-nummer;
+++ /dev/null
-design_size := 26;
-input feta-nummer;
+++ /dev/null
-% feta-nummer4.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=3.82; % 5.5/1.2/1.2 nummer6 = 5.5pt
-
-input feta-nummer.mf;
-
-end.
-
+++ /dev/null
-% feta-nummer6.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=5.5; % feta11 = 11pt
-
-input feta-nummer.mf;
-
-end.
-
+++ /dev/null
-% feta-nummer8.mf
-% part of LilyPond's pretty-but-neat music font
-
-design_size:=8; % feta16 = 16pt
-
-input feta-nummer.mf;
-end.
filldraw z3 -- z12 {dir -130} .. {dir -110} z10 {dir 110} .. {dir 130} z11 -- cycle;
enddef;
-fet_beginchar("Arpeggio arrow down", "arpeggio-arrow--1", "arpeggioarrowdown");
+fet_beginchar("Arpeggio arrow down", "arpeggio.arrow.M1", "arpeggioarrowdown");
draw_arpeggio_arrow;
fet_endchar;
-fet_beginchar("Arpeggio arrow up", "arpeggio-arrow-1", "arpeggioarrowup");
+fet_beginchar("Arpeggio arrow up", "arpeggio.arrow.1", "arpeggioarrowup");
draw_arpeggio_arrow;
- currentpicture := currentpicture scaled -1 shifted (0.8staff_space, staff_space);
+ currentpicture := currentpicture scaled -1 shifted (0.8 staff_space, staff_space);
fet_endchar;
-% feta16.mf
+% feta26.mf
% part of LilyPond's pretty-but-neat music font
input feta-autometric;
(list (cons 'font-encoding (car x)))
(cons (* factor (cadr x))
(caddr x))))
- `((fetaNumber 10
- #(,(delay (ly:font-load "feta-nummer4"))
- ,(delay (ly:font-load "feta-nummer6"))
- ,(delay (ly:font-load "feta-nummer8"))
- ,(delay (ly:font-load "feta-nummer10"))
- ,(delay (ly:font-load "feta-nummer12"))
- ,(delay (ly:font-load "feta-nummer16"))))
- (fetaDynamic 14.0 #(,(delay (ly:font-load "feta-din6"))
- ,(delay (ly:font-load "feta-din8"))
- ,(delay (ly:font-load "feta-din10"))
- ,(delay (ly:font-load "feta-din12"))
- ,(delay (ly:font-load "feta-din14"))
- ,(delay (ly:font-load "feta-din17"))))
-
+ `(
+ (fetaNumber 14
+ #(
+ ,(delay (ly:font-load "bigcheese11"))
+ ,(delay (ly:font-load "bigcheese13"))
+ ,(delay (ly:font-load "bigcheese14"))
+ ,(delay (ly:font-load "bigcheese16"))
+ ,(delay (ly:font-load "bigcheese18"))
+ ,(delay (ly:font-load "bigcheese20"))
+ ,(delay (ly:font-load "bigcheese23"))
+ ,(delay (ly:font-load "bigcheese26"))))
+
+ (fetaDynamic 20.0 #(
+ ,(delay (ly:font-load "bigcheese11"))
+ ,(delay (ly:font-load "bigcheese13"))
+ ,(delay (ly:font-load "bigcheese14"))
+ ,(delay (ly:font-load "bigcheese16"))
+ ,(delay (ly:font-load "bigcheese18"))
+ ,(delay (ly:font-load "bigcheese20"))
+ ,(delay (ly:font-load "bigcheese23"))
+ ,(delay (ly:font-load "bigcheese26"))))
+
(fetaMusic 20.0
- #(,(delay (ly:make-virtual-font
- (ly:font-load "feta11")
- (ly:font-load "parmesan11")))
- ,(delay (ly:make-virtual-font
- (ly:font-load "feta13")
- (ly:font-load "parmesan13")))
- ,(delay (ly:make-virtual-font
- (ly:font-load "feta14")
- (ly:font-load "parmesan14")))
- ,(delay (ly:make-virtual-font
- (ly:font-load "feta16")
- (ly:font-load "parmesan16")))
- ,(delay (ly:make-virtual-font
- (ly:font-load "feta18")
- (ly:font-load "parmesan18")))
-; ,(delay (ly:make-virtual-font (ly:font-load "feta20") (ly:font-load "parmesan20")))
- ,(delay (ly:make-virtual-font (ly:font-load "bigcheese20")))
- ,(delay (ly:make-virtual-font
- (ly:font-load "feta23")
- (ly:font-load "parmesan23")))
- ,(delay (ly:make-virtual-font
- (ly:font-load "feta26")
- (ly:font-load "parmesan26")))))
-
+ #(
+ ,(delay (ly:font-load "bigcheese11"))
+ ,(delay (ly:font-load "bigcheese13"))
+ ,(delay (ly:font-load "bigcheese14"))
+ ,(delay (ly:font-load "bigcheese16"))
+ ,(delay (ly:font-load "bigcheese18"))
+ ,(delay (ly:font-load "bigcheese20"))
+ ,(delay (ly:font-load "bigcheese23"))
+ ,(delay (ly:font-load "bigcheese26"))))
(fetaBraces 15 #(,(delay
(ly:make-virtual-font
(equal? (substring fontname 0 2) "ec")))
(define (ps-embed-cff body font-set-name version)
- (string-append
- (format
+ (let*
+ ((binary-data
+ (string-append
+ (format "/~a ~s StartData " font-set-name (string-length body))
+ body)))
+
+ (string-append
+ (format
"%!PS-Adobe-3.0 Resource-FontSet
%%DocumentNeededResources: ProcSet (FontSetInit)
%%EndComments
%%Version: ~s
/FontSetInit /ProcSet findresource begin
%%BeginData: ~s Binary Bytes
-/~a ~s StartData "
- font-set-name font-set-name version 0 font-set-name (string-length body)
+"
+ font-set-name font-set-name version (string-length binary-data)
)
-
- body
-
+ binary-data
"%%EndData
%%EndResource
%%EOF
"
- ))
+ )))
(define (load-fonts paper)
(cffpath (ly:find-file cffname))
(apath (ly:kpathsea-find-file aname))
(bpath (ly:kpathsea-find-file bname)))
- (display (list x cffpath))
(cond
(cffpath (ps-embed-cff (ly:gulp-file cffpath) x 0))
(apath (ly:gulp-file apath))
(ly:warn "cannot find T42/PFA/PFB font ~S" x)
""))))
(filter string? font-names))))
-
+
(string-join pfas "\n")))
(define (define-fonts paper)