From: fred Date: Fri, 18 Oct 1996 20:45:06 +0000 (+0000) Subject: lilypond-0.0.4 X-Git-Tag: release/1.5.59~7063 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f4dfcca1d91d96d55f5e751a8b816a0c8ca32949;p=lilypond.git lilypond-0.0.4 --- diff --git a/dimen.cc b/dimen.cc new file mode 100644 index 0000000000..eb53756b45 --- /dev/null +++ b/dimen.cc @@ -0,0 +1,40 @@ +#include +#include "dimen.hh" +#include "debug.hh" +#include "string.hh" + +Real +parse_dimen(String dim) +{ + int i=dim.len()-1; + const char *s = dim; + while (i > 0 && (isspace(s[i]) || isalpha(s[i])) ){ + i--; + } + String unit(s + i+1); + return convert_dimen(dim.fvalue(), unit); +} + +const Real CM_TO_PT=72/2.54; + +Real +convert_dimen(Real quant, String unit) +{ + if (unit == "cm") + return quant * CM_TO_PT; + if (unit == "pt") + return quant; + if (unit == "mm") + return quant*CM_TO_PT/10; + if (unit == "in") + return quant * 72; + error ("unknown length unit: `" + unit+"'"); +} + +String +print_dimen(Real r) +{ + String s(r); + s += "pt "; + return s; +} diff --git a/dimen.hh b/dimen.hh new file mode 100644 index 0000000000..4ee17ea140 --- /dev/null +++ b/dimen.hh @@ -0,0 +1,12 @@ +#ifndef DIMEN_HH +#define DIMEN_HH + +#include "real.hh" +#include "string.hh" + +Real parse_dimen(String); +Real convert_dimen(Real, String); +String print_dimen(Real); + +#endif + diff --git a/lookupsyms.hh b/lookupsyms.hh new file mode 100644 index 0000000000..d4e08667db --- /dev/null +++ b/lookupsyms.hh @@ -0,0 +1,18 @@ +/* + lilypond, (c) 1996 Han-Wen Nienhuys +*/ +#ifndef LOOKUPSYMS_HH +#define LOOKUPSYMS_HH + +#include "symbol.hh" + +struct Lookup { + static Parametric_symbol *linestaff(int n); + static Parametric_symbol *meter(String); + static Symbol ball(int); + static Symbol rest(int); + static Symbol bar(String); + static Symbol dots(int); +}; + +#endif diff --git a/symtable.cc b/symtable.cc index 5d295d0be5..b4de607b8d 100644 --- a/symtable.cc +++ b/symtable.cc @@ -1,23 +1,24 @@ #include "misc.hh" +#include "dimen.hh" #include "debug.hh" #include "real.hh" #include "symbol.hh" #include "assoc.hh" #include "symtable.hh" -#include "const.hh" -static Symbol unknown; -// scary! What if Symtable resizes on the fly...? -const Symbol * + + +Symbol Symtable::lookup(String s) const { if (elt_query(s)) - return &(*this)[s]; + return (*this)[s]; else { + Symbol unknown; WARN<<"Unknown symbol " << s <<'\n'; - return &unknown; + return unknown; } } @@ -54,7 +55,7 @@ Symtables::read() String tex=r[i++]; svec dims; for (int j=0; j < 4; j++) - dims.add( r[i++].fvalue() *1.0/CM_TO_PT); + dims.add( parse_dimen(r[i++])); Symbol s(tex, Box(dims)); (*sp)[id] = s; @@ -63,56 +64,5 @@ Symtables::read() } } -Symtables the_sym_tables("symbol.ini"); - - -const Symbol* -Symbol::find_ball(int j) -{ - if (j > 4) j = 4; - Symtable * st = the_sym_tables("balls"); - return st->lookup(String(j)); -} -const Symbol* -Symbol::find_rest(int j) -{ - return the_sym_tables("rests")->lookup(String(j)); -} -const Symbol* -Symbol::find_bar(String s) -{ - return the_sym_tables("bars")->lookup(s); -} -/****************************************************************/ -// bare bones. -struct Linestaf_symbol : Stretchable_symbol { - int lines; - String operator ()(Real w); - Linestaf_symbol(int n) { lines = n;} - Interval height(Real) const { return Interval(0,lines*1/CM_TO_PT); } -}; - - - -// should be done in TeX -String -Linestaf_symbol::operator()(Real w) -{ - String s; - s += "\\hbox to 0pt{"; - s+= "\\vbox to 0pt{"; - for (int i=0; i args) +{ + String retval (source); + for (int i = 0 ; i < args.sz(); i++) + substitute_arg(retval, args[i]); + while (retval.pos('%')) + substitute_arg(retval, ""); + return retval; +}