From: Han-Wen Nienhuys Date: Mon, 27 Dec 2004 23:47:12 +0000 (+0000) Subject: * lily/modified-font-metric.cc (text_dimension): try X-Git-Tag: release/2.5.14~346 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=24ac85edabed266d1de42c12971f4e81b4475d7d;p=lilypond.git * lily/modified-font-metric.cc (text_dimension): try lookup_tex_text_dimension() first. * lily/tfm.cc: new function ly:load-text-dimensions --- diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc index c5f98c727e..29298fe15a 100644 --- a/lily/break-substitution.cc +++ b/lily/break-substitution.cc @@ -461,7 +461,7 @@ Spanner::fast_fubstitute_grob_list (SCM sym, SCM substitute_mutable_property_alist (SCM alist) { - SCM grob_list_p = ly_scheme_function ("grob-list?"); + SCM grob_list_p = ly_lily_module_constant ("grob-list?"); SCM l = SCM_EOL; SCM *tail = &l; @@ -499,7 +499,7 @@ Spanner::substitute_one_mutable_property (SCM sym, Spanner*s = this; bool fast_done = false; - SCM grob_list_p = ly_scheme_function ("grob-list?"); + SCM grob_list_p = ly_lily_module_constant ("grob-list?"); if (type == grob_list_p) fast_done = s->fast_fubstitute_grob_list (sym, val); diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index 6afa86229e..6e207877b5 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -107,7 +107,7 @@ Clef_engraver::create_clef () scm_from_int (10)); g->set_property ("text", - scm_list_n (ly_scheme_function ("vcenter-markup"), + scm_list_n (ly_lily_module_constant ("vcenter-markup"), txt, SCM_UNDEFINED)); Side_position_interface::add_support (g,clef_); diff --git a/lily/font-metric.cc b/lily/font-metric.cc index 277c2cadfc..cc0ae4244f 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -316,7 +316,7 @@ get_encoded_index (Font_metric *m, String input_coding, int code) String font_coding = m->coding_scheme (); if (font_coding == input_coding) return code; - SCM s = scm_call_3 (ly_scheme_function ("encoded-index"), + SCM s = scm_call_3 (ly_lily_module_constant ("encoded-index"), scm_makfrom0str (input_coding.to_str0 ()), scm_makfrom0str (font_coding.to_str0 ()), scm_int2num (code)); diff --git a/lily/font-select.cc b/lily/font-select.cc index c05f0b1f20..9ded64e067 100644 --- a/lily/font-select.cc +++ b/lily/font-select.cc @@ -103,7 +103,7 @@ get_font_by_mag_step (Output_def *layout, Real requested_step, SCM properties_to_font_size_family (SCM fonts, SCM alist_chain) { - return scm_call_2 (ly_scheme_function ("lookup-font"), fonts, alist_chain); + return scm_call_2 (ly_lily_module_constant ("lookup-font"), fonts, alist_chain); } Font_metric * diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index d813ed44cf..8a9a7cc24c 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -74,7 +74,7 @@ extern SCM global_lily_module; /* TODO: rename me to ly_c_lily_module_eval */ -#define ly_scheme_function(x) \ +#define ly_lily_module_constant(x) \ ({ \ static SCM cached; \ /* We store this one locally, since G++ -O2 fucks up else */ \ diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 8d00b911cd..92f8f16f66 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -42,7 +42,7 @@ Key_performer::create_audio_elements () if (key_req_) { SCM pitchlist = key_req_->get_property ("pitch-alist"); - SCM proc = ly_scheme_function ("alterations-in-key"); + SCM proc = ly_lily_module_constant ("alterations-in-key"); SCM acc = scm_call_1 (proc, pitchlist); diff --git a/lily/lexer.ll b/lily/lexer.ll index 081dd00221..d0a2dc50f0 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -882,7 +882,7 @@ avoid_silly_flex_induced_gcc_warnings () SCM lookup_markup_command (String s) { - SCM proc = ly_scheme_function ("lookup-markup-command"); + SCM proc = ly_lily_module_constant ("lookup-markup-command"); return scm_call_1 (proc, scm_makfrom0str (s.to_str0 ())); } diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index a5cd70e2e9..aa1161a37d 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -48,7 +48,7 @@ ly_to_symbol (SCM scm) SCM ly_to_string (SCM scm) { - return scm_call_3 (ly_scheme_function ("format"), SCM_BOOL_F, + return scm_call_3 (ly_lily_module_constant ("format"), SCM_BOOL_F, scm_makfrom0str ("~S"), scm); } @@ -624,7 +624,7 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) { SCM errport = scm_current_error_port (); ok = false; - SCM typefunc = ly_scheme_function ("type-name"); + SCM typefunc = ly_lily_module_constant ("type-name"); SCM type_name = scm_call_1 (typefunc, type); diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index fd982bc659..fb09a41e52 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -226,9 +226,9 @@ LY_DEFINE (ly_set_point_and_click, "ly:set-point-and-click", /* UGH. */ SCM val = SCM_BOOL_F; if (ly_symbol2scm ("line-column") == what) - val = ly_scheme_function ("line-column-location"); + val = ly_lily_module_constant ("line-column-location"); else if (what == ly_symbol2scm ("line")) - val = ly_scheme_function ("line-location"); + val = ly_lily_module_constant ("line-location"); scm_module_define (global_lily_module, ly_symbol2scm ("point-and-click"), val); diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 9b0a6dc558..c8ccf10d74 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -33,7 +33,7 @@ ly_make_anonymous_module (bool safe) } else { - SCM proc = ly_scheme_function ("make-safe-lilypond-module"); + SCM proc = ly_lily_module_constant ("make-safe-lilypond-module"); mod = scm_call_0 (proc); } return mod; diff --git a/lily/main.cc b/lily/main.cc index 918faa08c9..8cca9aa0e3 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -339,7 +339,7 @@ main_with_guile (void *, int, char **) exit (2); } - SCM result = scm_call_1 (ly_scheme_function ("lilypond-main"), files); + SCM result = scm_call_1 (ly_lily_module_constant ("lilypond-main"), files); (void) result; diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 064fdd2292..827e5c869f 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -142,7 +142,7 @@ Midi_instrument::to_string () const /* UGH. don't use eval. */ - SCM proc = ly_scheme_function ("midi-program"); + SCM proc = ly_lily_module_constant ("midi-program"); SCM program = scm_call_1 (proc, ly_symbol2scm (audio_->str_.to_str0 ())); found = (program != SCM_BOOL_F); if (found) diff --git a/lily/modified-font-metric.cc b/lily/modified-font-metric.cc index f1a81ae5f9..de1b23e834 100644 --- a/lily/modified-font-metric.cc +++ b/lily/modified-font-metric.cc @@ -45,7 +45,7 @@ Modified_font_metric::Modified_font_metric (Font_metric *fm, && input_encoding_ != "ASCII" && input_encoding_ != font_encoding) { - coding_vector_ = scm_call_1 (ly_scheme_function ("get-coding-vector"), + coding_vector_ = scm_call_1 (ly_lily_module_constant ("get-coding-vector"), scm_makfrom0str (font_encoding.to_str0 ())); if (!ly_c_vector_p (coding_vector_)) @@ -54,11 +54,11 @@ Modified_font_metric::Modified_font_metric (Font_metric *fm, coding_vector_ = scm_c_make_vector (256, ly_symbol2scm (".notdef")); } - coding_table_ = scm_call_1 (ly_scheme_function ("get-coding-table"), + coding_table_ = scm_call_1 (ly_lily_module_constant ("get-coding-table"), scm_makfrom0str (font_encoding.to_str0 ())); coding_mapping_ - = scm_call_2 (ly_scheme_function ("make-encoding-mapping"), + = scm_call_2 (ly_lily_module_constant ("make-encoding-mapping"), coding_vector_, coding_table_); diff --git a/lily/music-function.cc b/lily/music-function.cc index 392aeb3a59..46ac068575 100644 --- a/lily/music-function.cc +++ b/lily/music-function.cc @@ -43,7 +43,7 @@ LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0, if (scm_car (s) == Music_type_p_proc) str += "music"; - else if (scm_car (s) == ly_scheme_function("markup?")) + else if (scm_car (s) == ly_lily_module_constant("markup?")) str += "markup"; else if (ly_c_procedure_p (scm_car (s))) str += "scm"; diff --git a/lily/music.cc b/lily/music.cc index b5f407d3d3..ca9f2c028a 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -245,7 +245,7 @@ Music::duration_log () const Music* make_music_by_name (SCM sym) { - SCM make_music_proc = ly_scheme_function ("make-music"); + SCM make_music_proc = ly_lily_module_constant ("make-music"); SCM rv = scm_call_1 (make_music_proc, sym); /* UGH. */ diff --git a/lily/paper-def.cc b/lily/paper-def.cc index bfe6e5c13b..83b3491da8 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -72,7 +72,7 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real m, Output_def * scale_output_def (Output_def *o, Real amount) { - SCM proc = ly_scheme_function ("scale-layout"); + SCM proc = ly_lily_module_constant ("scale-layout"); SCM new_pap = scm_call_2 (proc, o->self_scm (), scm_double2num (amount)); scm_gc_protect_object (new_pap); @@ -93,7 +93,7 @@ LY_DEFINE (ly_paper_fonts, "ly:paper-fonts", SCM ell = SCM_EOL; if (scm_hash_table_p (font_table) == SCM_BOOL_T) { - SCM func = ly_scheme_function ("hash-table->alist"); + SCM func = ly_lily_module_constant ("hash-table->alist"); for (SCM s = scm_call_1 (func, font_table); scm_is_pair (s); s = scm_cdr (s)) diff --git a/lily/parse-scm.cc b/lily/parse-scm.cc index 629366baf1..2f55783edf 100644 --- a/lily/parse-scm.cc +++ b/lily/parse-scm.cc @@ -41,7 +41,7 @@ internal_ly_parse_scm (Parse_start * ps) static SCM module = SCM_BOOL_F; if (module == SCM_BOOL_F) { - SCM function = ly_scheme_function ("make-safe-lilypond-module"); + SCM function = ly_lily_module_constant ("make-safe-lilypond-module"); module = scm_call_0 (function); } answer = scm_eval (form, module); diff --git a/lily/parser.yy b/lily/parser.yy index f93b0b5df7..d9fa443eb7 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -118,9 +118,9 @@ get_first_context_id (SCM type, Music *m) SCM make_simple_markup (SCM encoding, SCM a) { - SCM simple = ly_scheme_function ("simple-markup"); + SCM simple = ly_lily_module_constant ("simple-markup"); if (scm_is_symbol (encoding)) - return scm_list_3 (ly_scheme_function ("encoded-simple-markup"), + return scm_list_3 (ly_lily_module_constant ("encoded-simple-markup"), encoding, a); return scm_list_2 (simple, a); } @@ -154,7 +154,7 @@ make_chord_step (int step, int alter) SCM make_chord (SCM pitch, SCM dur, SCM modification_list) { - SCM chord_ctor = ly_scheme_function ("construct-chord"); + SCM chord_ctor = ly_lily_module_constant ("construct-chord"); SCM ch = scm_call_3 (chord_ctor, pitch, dur, modification_list); scm_gc_protect_object (ch); return ch; @@ -903,7 +903,7 @@ Repeated_music: } - SCM proc = ly_scheme_function ("make-repeated-music"); + SCM proc = ly_lily_module_constant ("make-repeated-music"); SCM mus = scm_call_1 (proc, $2); scm_gc_protect_object (mus); // UGH. @@ -925,7 +925,7 @@ Repeated_music: we can not get durations and other stuff correct down the line, so we have to add to the duration log here. */ - SCM func = ly_scheme_function ("shift-duration-log"); + SCM func = ly_lily_module_constant ("shift-duration-log"); int dots = ($3 % 3) ? 0 : 1; int shift = -intlog2 ((dots) ? ($3*2/3) : $3); @@ -1092,7 +1092,7 @@ Generic_prefix_music: SCM args = scm_cddr ($1); SCM sig = scm_object_property (func, ly_symbol2scm ("music-function-signature")); - SCM type_check_proc = ly_scheme_function ("type-check-list"); + SCM type_check_proc = ly_lily_module_constant ("type-check-list"); bool ok = true; if (!to_boolean (scm_call_3 (type_check_proc, scm_cadr ($1), sig, args))) @@ -1607,7 +1607,7 @@ chord_body_element: add_quote: ADDQUOTE string Music { - SCM adder = ly_scheme_function ("add-quotable"); + SCM adder = ly_lily_module_constant ("add-quotable"); scm_call_2 (adder, $2, $3->self_scm ()); scm_gc_unprotect_object ($3->self_scm ()); @@ -1699,21 +1699,21 @@ command_element: $$ = p; } | CLEF STRING { - SCM proc = ly_scheme_function ("make-clef-set"); + SCM proc = ly_lily_module_constant ("make-clef-set"); SCM result = scm_call_1 (proc, $2); scm_gc_protect_object (result); $$ = unsmob_music (result); } | TIME_T fraction { - SCM proc = ly_scheme_function ("make-time-signature-set"); + SCM proc = ly_lily_module_constant ("make-time-signature-set"); SCM result = scm_apply_2 (proc, scm_car ($2), scm_cdr ($2), SCM_EOL); scm_gc_protect_object (result); $$ = unsmob_music (result); } | MARK scalar { - SCM proc = ly_scheme_function ("make-mark-set"); + SCM proc = ly_lily_module_constant ("make-mark-set"); SCM result = scm_call_1 (proc, $2); scm_gc_protect_object (result); @@ -2101,12 +2101,12 @@ tremolo_type: bass_number: DIGIT { $$ = scm_number_to_string (scm_int2num ($1), scm_int2num (10)); - $$ = scm_list_2 (ly_scheme_function ("number-markup"), + $$ = scm_list_2 (ly_lily_module_constant ("number-markup"), $$); } | UNSIGNED { $$ = scm_number_to_string (scm_int2num ($1), scm_int2num (10)); - $$ = scm_list_2 (ly_scheme_function ("number-markup"), + $$ = scm_list_2 (ly_lily_module_constant ("number-markup"), $$); } | STRING { $$ = $1; } @@ -2268,7 +2268,7 @@ simple_element: | MULTI_MEASURE_REST optional_notemode_duration { THIS->pop_spot (); - SCM proc = ly_scheme_function ("make-multi-measure-rest"); + SCM proc = ly_lily_module_constant ("make-multi-measure-rest"); SCM mus = scm_call_2 (proc, $2, make_input (THIS->here_input ())); scm_gc_protect_object (mus); @@ -2482,10 +2482,10 @@ full_markup: markup_top: markup_list { - $$ = scm_list_2 (ly_scheme_function ("line-markup"), $1); + $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1); } | markup_head_1_list simple_markup { - $$ = scm_car (scm_call_2 (ly_scheme_function ("map-markup-command-list"), $1, scm_list_1 ($2))); + $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2))); } | simple_markup { $$ = $1; @@ -2503,7 +2503,7 @@ markup_list: markup_composed_list: markup_head_1_list markup_braced_list { - $$ = scm_call_2 (ly_scheme_function ("map-markup-command-list"), $1, $2); + $$ = scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, $2); } ; @@ -2560,7 +2560,7 @@ simple_markup: THIS->lexer_->push_note_state (alist_to_hashq (nn)); } '{' score_body '}' { Score * sc = $4; - $$ = scm_list_2 (ly_scheme_function ("score-markup"), sc->self_scm ()); + $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), sc->self_scm ()); scm_gc_unprotect_object (sc->self_scm ()); THIS->lexer_->pop_state (); } @@ -2586,7 +2586,7 @@ simple_markup: markup: markup_head_1_list simple_markup { - $$ = scm_car (scm_call_2 (ly_scheme_function ("map-markup-command-list"), $1, scm_list_1 ($2))); + $$ = scm_car (scm_call_2 (ly_lily_module_constant ("map-markup-command-list"), $1, scm_list_1 ($2))); } | simple_markup { $$ = $1; diff --git a/lily/score.cc b/lily/score.cc index d2dd56d849..945b7c75e0 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -336,7 +336,7 @@ void Score::set_music (SCM music, SCM parser) { /* URG? */ - SCM check_funcs = ly_scheme_function ("toplevel-music-functions"); + SCM check_funcs = ly_lily_module_constant ("toplevel-music-functions"); for (; scm_is_pair (check_funcs); check_funcs = scm_cdr (check_funcs)) music = scm_call_2 (scm_car (check_funcs), music, parser); diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index ffc0cb7358..ee168faa82 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -96,7 +96,7 @@ Staff_performer::create_audio_elements () void Staff_performer::stop_translation_timestep () { - SCM proc = ly_scheme_function ("percussion?"); + SCM proc = ly_lily_module_constant ("percussion?"); SCM drums = scm_call_1 (proc, ly_symbol2scm (instrument_string_.to_str0 ())); audio_staff_->channel_ = (drums == SCM_BOOL_T ? 9 : -1 ); diff --git a/lily/tfm.cc b/lily/tfm.cc index b0d1daaa71..ed97e417b1 100644 --- a/lily/tfm.cc +++ b/lily/tfm.cc @@ -26,7 +26,7 @@ lookup_tex_text_dimension (Font_metric *font, { Box b; - SCM limit = ly_scheme_function ("TEX_STRING_HASHLIMIT"); + SCM limit = ly_lily_module_constant ("TEX_STRING_HASHLIMIT"); String key_str = ly_scm2string (font->font_file_name()); int hash_code = scm_to_int (scm_hash (text, limit)); key_str = to_string (hash_code) + key_str; @@ -37,12 +37,12 @@ lookup_tex_text_dimension (Font_metric *font, if (scm_is_pair (val)) { - b[X_AXIS][LEFT] = 0.0; - b[X_AXIS][RIGHT] = scm_to_double (scm_car (val)); + b[X_AXIS][LEFT] = 0.0 PT; + b[X_AXIS][RIGHT] = scm_to_double (scm_car (val)) PT; val = scm_cdr (val); - b[Y_AXIS][UP] = scm_to_double (scm_car (val)); + b[Y_AXIS][UP] = scm_to_double (scm_car (val)) PT; val = scm_cdr (val); - b[Y_AXIS][DOWN] = scm_to_double (scm_car (val)); + b[Y_AXIS][DOWN] = scm_to_double (scm_car (val)) PT; } return b; @@ -132,7 +132,7 @@ Tex_font_metric::make_tfm (String file_name) tfm->char_metrics_ = reader.char_metrics_; tfm->ascii_to_metric_idx_ = reader.ascii_to_metric_idx_; tfm->encoding_table_ - = scm_call_1 (ly_scheme_function ("get-coding-table"), + = scm_call_1 (ly_lily_module_constant ("get-coding-table"), scm_makfrom0str (tfm->coding_scheme ().to_str0 ())); return tfm->self_scm (); diff --git a/tex/lilypond-tex-metrics.tex b/tex/lilypond-tex-metrics.tex new file mode 100644 index 0000000000..5a4450b479 --- /dev/null +++ b/tex/lilypond-tex-metrics.tex @@ -0,0 +1,56 @@ +% +% lilymetrics.tex +% +\catcode `\@=11\relax + +\newdimen\lily@globalscale +\newdimen\lily@localscale +\newbox\lily@metricsbox +\newwrite\lily@metricsfile + +\def\lilyglobalscale#1{% + \lily@globalscale #1pt +} + +\def\lilymetricsfile#1{% + \immediate\openout\lily@metricsfile #1\relax +} + +\begingroup + \catcode `P=12 + \catcode `T=12 + \lowercase{% + \def\x{% + \def\lily@rempt##1.##2PT{% + ##1\ifnum ##2 > \z@ .##2\fi + }% + }% + } +\expandafter\endgroup\x + +\def\lily@strippt{% + \expandafter\lily@rempt +} + +\long\def\lilygetmetrics#1#2#3#4{% + \lily@localscale #3\lily@globalscale + % convert pt to 1000*sp (1000/65536) + \lily@localscale 0.015259\lily@localscale + \font\lily@font = #2 scaled \lily@localscale + \setbox\lily@metricsbox\hbox{% + \lily@font + #4% + }% + \edef\lily@wd{\the\wd\lily@metricsbox}% + \edef\lily@ht{\the\ht\lily@metricsbox}% + \edef\lily@dp{\the\dp\lily@metricsbox}% + \immediate\write\lily@metricsfile{% + ("#1" . (\lily@strippt\lily@wd + \space\lily@strippt\lily@ht + \space\lily@strippt\lily@dp))% + }% +} + +\catcode `\@=13\relax + +\endinput