From: Jan Nieuwenhuizen Date: Thu, 12 Nov 1998 13:24:25 +0000 (+0100) Subject: patch::: 1.1.4.jcn1 X-Git-Tag: release/1.1.5~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5a42c3ec738076a6e520e630ad837b687729a492;p=lilypond.git patch::: 1.1.4.jcn1 pl4.jcn1 - read (cmr12)afm for text char widths --- diff --git a/NEWS b/NEWS index 78c854e1cd..3879229f44 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +pl4.jcn1 + - read (cmr12)afm for text char widths + 1.1.4 pl 3.tca1 diff --git a/VERSION b/VERSION index 66f4cf93b6..704da620af 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=1 PATCH_LEVEL=4 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=jcn1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/test/alphabet.ly b/input/test/alphabet.ly new file mode 100644 index 0000000000..b53c5ba50c --- /dev/null +++ b/input/test/alphabet.ly @@ -0,0 +1,64 @@ +\score{ + < + \type Staff \notes{ c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c } + \type Lyrics \lyrics{ +aaaaaaaaaaaaaaaaaaa +bbbbbbbbbbbbbbbbbbb +ccccccccccccccccccc +ddddddddddddddddddd +eeeeeeeeeeeeeeeeeee +fffffffffffffffffff +ggggggggggggggggggg +hhhhhhhhhhhhhhhhhhh +iiiiiiiiiiiiiiiiiii +jjjjjjjjjjjjjjjjjjj +kkkkkkkkkkkkkkkkkkk +lllllllllllllllllll +mmmmmmmmmmmmmmmmmmm +nnnnnnnnnnnnnnnnnnn +ooooooooooooooooooo +ppppppppppppppppppp +qqqqqqqqqqqqqqqqqqq +rrrrrrrrrrrrrrrrrrr +sssssssssssssssssss +ttttttttttttttttttt +uuuuuuuuuuuuuuuuuuu +vvvvvvvvvvvvvvvvvvv +wwwwwwwwwwwwwwwwwww +xxxxxxxxxxxxxxxxxxx +yyyyyyyyyyyyyyyyyyy +zzzzzzzzzzzzzzzzzzz +................... +AAAAAAAAAAAAAAAAAAA +BBBBBBBBBBBBBBBBBBB +CCCCCCCCCCCCCCCCCCC +DDDDDDDDDDDDDDDDDDD +EEEEEEEEEEEEEEEEEEE +FFFFFFFFFFFFFFFFFFF +GGGGGGGGGGGGGGGGGGG +HHHHHHHHHHHHHHHHHHH +IIIIIIIIIIIIIIIIIII +JJJJJJJJJJJJJJJJJJJ +KKKKKKKKKKKKKKKKKKK +LLLLLLLLLLLLLLLLLLL +MMMMMMMMMMMMMMMMMMM +NNNNNNNNNNNNNNNNNNN +OOOOOOOOOOOOOOOOOOO +PPPPPPPPPPPPPPPPPPP +QQQQQQQQQQQQQQQQQQQ +RRRRRRRRRRRRRRRRRRR +SSSSSSSSSSSSSSSSSSS +TTTTTTTTTTTTTTTTTTT +UUUUUUUUUUUUUUUUUUU +VVVVVVVVVVVVVVVVVVV +WWWWWWWWWWWWWWWWWWW +XXXXXXXXXXXXXXXXXXX +YYYYYYYYYYYYYYYYYYY +ZZZZZZZZZZZZZZZZZZZ +aaaaaaaaaaaaaaaaaaa + } + > + \paper { + castingalgorithm = \Wordwrap; + } +} diff --git a/lily/lookup.cc b/lily/lookup.cc index 300439b3dd..22518b575d 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -12,6 +12,7 @@ Glissando */ +#include #include "lookup.hh" #include "debug.hh" #include "dimensions.hh" @@ -19,6 +20,7 @@ #include "scalar.hh" #include "paper-def.hh" #include "string-convert.hh" +#include "file-path.hh" #include "main.hh" #include "lily-guile.hh" @@ -311,6 +313,9 @@ Lookup::streepje (int type) const return afm_find ("balls" + String ("-") +to_str (type) + "l"); } +Dictionary cmr_dict; +Dictionary afm_p_dict; + Atom Lookup::text (String style, String text) const { @@ -319,10 +324,53 @@ Lookup::text (String style, String text) const arr.push (text); Atom a = (*symtables_p_) ("style")->lookup (style); a.lambda_ = lambda_scm (a.str_, arr); + +// urg +// if (!cmr_dict.length_i ()) + if (!cmr_dict.elem_b ("roman")) + { + cmr_dict.elem ("italic") = "cmri12.afm"; + cmr_dict.elem ("roman") = "cmr12.afm"; + } + + if (!afm_p_dict.elem_b (style)) + { + String cmr_str = cmr_dict.elem (style); + String font_path = global_path.find (cmr_str); + if (!font_path.length_i ()) + error (_f("can't open file: `%s'", cmr_str.ch_C ())); + *mlog << "[" << font_path; + Adobe_font_metric* afm_p = new Adobe_font_metric (read_afm (font_path)); + DOUT << afm_p->str (); + *mlog << "]" << flush ; + afm_p_dict.elem (style) = afm_p; + } + Real w = 0; + Real guess_w = a.dim_.x ().length (); + Adobe_font_metric* afm_p = afm_p_dict.elem (style); + DOUT << "\nChars: "; + for (int i = 0; i < text.length_i (); i++) + { + if (text[i]=='\\') + for (i++; (i < text.length_i ()) && isalpha(text[i]); i++) + ; + else + { + if (afm_p) + { + Adobe_font_char_metric m = afm_p->char_metrics_[(int)text[i]]; + w += m.B_.x ().length (); + DOUT << to_str (m.B_.x ().length ()) << " "; + } + else + w += guess_w; + } + } + DOUT << "\n" << to_str (w) << "\n"; + a.dim_.x () = Interval (0, w); a.str_ = "text"; a.font_ = font_; return a; - } diff --git a/lily/text-def.cc b/lily/text-def.cc index 06eccd3fe6..33d6da977e 100644 --- a/lily/text-def.cc +++ b/lily/text-def.cc @@ -6,12 +6,12 @@ (c) 1996, 1997--1998 Han-Wen Nienhuys */ +#include #include "debug.hh" #include "lookup.hh" #include "paper-def.hh" #include "molecule.hh" #include "text-def.hh" -#include Direction Text_def::staff_dir () const @@ -24,17 +24,7 @@ Text_def::staff_dir () const Real Text_def::guess_width_f(Atom& a) const { - // Count each TeX command as one character, ugh - int index, length=0; - int total_length=text_str_.length_i(); - const char* str=text_str_.ch_C(); - for (index=0;index