]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/modified-font-metric.cc (text_dimension): try
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 27 Dec 2004 23:47:12 +0000 (23:47 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 27 Dec 2004 23:47:12 +0000 (23:47 +0000)
lookup_tex_text_dimension() first.

* lily/tfm.cc: new function ly:load-text-dimensions

22 files changed:
lily/break-substitution.cc
lily/clef-engraver.cc
lily/font-metric.cc
lily/font-select.cc
lily/include/lily-guile.hh
lily/key-performer.cc
lily/lexer.ll
lily/lily-guile.cc
lily/lily-parser.cc
lily/ly-module.cc
lily/main.cc
lily/midi-item.cc
lily/modified-font-metric.cc
lily/music-function.cc
lily/music.cc
lily/paper-def.cc
lily/parse-scm.cc
lily/parser.yy
lily/score.cc
lily/staff-performer.cc
lily/tfm.cc
tex/lilypond-tex-metrics.tex [new file with mode: 0644]

index c5f98c727e45818ec8e5b7cca1c6b73bdb87036f..29298fe15aab2ed123b02c92a8b8eb6eb5c60d42 100644 (file)
@@ -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);
 
index 6afa86229ebe7a0f2853d68d9c30fc9f9ce1b3d1..6e207877b5823b8750b60f3055ff3c631ab58ad3 100644 (file)
@@ -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_);      
 
index 277c2cadfc25719ae843f5bba527139e0833065a..cc0ae4244f588a9ed9394d24c42e05eaab4b20c2 100644 (file)
@@ -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));
index c05f0b1f2016a0ae6fc911a70e7728a22e107fcd..9ded64e067b4a52f206ae1bcbfcdfdbfdedd6b02 100644 (file)
@@ -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 *
index d813ed44cfa9d5dc8ffae8dd139e98cd4a2817dd..8a9a7cc24c93292a54ab7719b8739a1b99cd2f6b 100644 (file)
@@ -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 */ \
index 8d00b911cd026e0f93c6ef56df4d0ce0b63be789..92f8f16f6628ffe360de7e2c8369742dabd4f785 100644 (file)
@@ -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);
       
index 081dd002215078bc6996579bf418db57d648b2c8..d0a2dc50f01a2285bde30c5b603e14357f2cf00d 100644 (file)
@@ -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 ()));
 }
 
index a5cd70e2e9f92ebacd1b3642e9438d121af5b3b8..aa1161a37dcbe0c61a8cd2df26ebf0a07a303d4b 100644 (file)
@@ -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);
 
         
index fd982bc65928fd4b7abba84f18b44f1a655444f3..fb09a41e5290f3356b5d99eeae0e425fc444694d 100644 (file)
@@ -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);
index 9b0a6dc5586b1b40329e59798f8da6418156027b..c8ccf10d74a7bc914950bcd53d7df8ed6e0da126 100644 (file)
@@ -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;
index 918faa08c9787ad46780f83229ea331bb9033f74..8cca9aa0e3281e14e818630243dcbd1efd16ec96 100644 (file)
@@ -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;
 
 
index 064fdd2292deb1ff2986e00fc069e7a543410171..827e5c869fb38ca57bd0343f3173c9cc14b864ce 100644 (file)
@@ -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)
index f1a81ae5f9d4292d3ceef8dd3db0876f78082cdc..de1b23e834de93c71e3e6cf4252fd82d60e14074 100644 (file)
@@ -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_);
 
index 392aeb3a59237c8c86a55fe7616dc478ab5b2e76..46ac068575c92f0dce211807c0f5378fb167954c 100644 (file)
@@ -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";
index b5f407d3d3db17368534500f6cdf569bb4bc92d9..ca9f2c028afdc02cf2c65359e4de75cb5de698af 100644 (file)
@@ -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. */
index bfe6e5c13bdfc7d629a8da890f01b661db4d8255..83b3491da85bc80493f9072ac8ac176429054b4a 100644 (file)
@@ -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))
index 629366baf15927463a83974f05de12af1ba0bf14..2f55783edf46ddfdf70a6bd372b1b6ce364b9d21 100644 (file)
@@ -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);
index f93b0b5df771252ce00e2a5afd76e39af020fc4f..d9fa443eb72823fe4d1db5321d5705a4f6f787af 100644 (file)
@@ -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;
index d2dd56d84928087283926ff00efa766c629c7c84..945b7c75e0b694df981d0759324f60c82b190dcf 100644 (file)
@@ -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);
 
index ffc0cb7358788eb368e008b91d8a8e6ac5ae7ddb..ee168faa824cb99f45b24378d87ac1ab08250684 100644 (file)
@@ -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 );
index b0d1daaa712c90569a534669c279f51928bc4c33..ed97e417b17d75819a5cc47d9554840a8af83fbc 100644 (file)
@@ -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 (file)
index 0000000..5a4450b
--- /dev/null
@@ -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