]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/font-metric.cc
Massive changes - see ChangeLog.
[lilypond.git] / lily / font-metric.cc
index 20776e444a6e97c8fc980ca4e9c070b903f518ab..a1c0f72bff479983fe3967615dbd22e9f2d61163 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
     Mats Bengtsson <matsb@s3.kth.se> (the ugly TeX parsing in text_dimension)
  */
@@ -143,11 +143,10 @@ Font_metric::find_by_name (String) const
   return m;
 }
 
-
 LY_DEFINE(ly_find_glyph_by_name, "ly:find-glyph-by-name", 2 , 0, 0,
          (SCM font, SCM name),
-         "This function retrieves a Molecule for the glyph named @var{name} in
-@var{font}.  The font must be available as an AFM file.")
+         "This function retrieves a Molecule for the glyph named @var{name} in "
+"@var{font}.  The font must be available as an AFM file.")
 {
   Font_metric *fm = unsmob_metrics (font);
   SCM_ASSERT_TYPE(fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
@@ -156,12 +155,23 @@ LY_DEFINE(ly_find_glyph_by_name, "ly:find-glyph-by-name", 2 , 0, 0,
   return fm->find_by_name (ly_scm2string (name)).smobbed_copy ();
 }
 
+LY_DEFINE(ly_get_glyph, "ly:get-glyph", 2 , 0, 0,
+         (SCM font, SCM index),
+         "This function retrieves a Molecule for the glyph numbered @var{index} in "
+"@var{font}. ")
+{
+  Font_metric *fm = unsmob_metrics (font);
+  SCM_ASSERT_TYPE(fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
+  SCM_ASSERT_TYPE(gh_number_p (index), index, SCM_ARG2, __FUNCTION__, "number");
+
+  return fm->get_char_molecule (gh_scm2int (index)).smobbed_copy ();
+}
 
 LY_DEFINE(ly_text_dimension,"ly:text-dimension", 2 , 0, 0,
          (SCM font, SCM text),
-         "Given the font metric in @var{font} and the string @var{text}, compute
-the extents of that text in that font. The return value is a pair of
-number-pairs.")
+         "Given the font metric in @var{font} and the string @var{text}, compute "
+"the extents of that text in that font. The return value is a pair of "
+"number-pairs.")
 {
   Box b;
   Font_metric *fm = unsmob_metrics (font);
@@ -172,15 +182,10 @@ number-pairs.")
   
   return gh_cons (ly_interval2scm (b[X_AXIS]), ly_interval2scm(b[Y_AXIS]));
 }
-
-
-
-
   
 Molecule
 Font_metric::get_char_molecule (int code)  const
 {
-  Molecule  m ;
   SCM at = scm_list_n (ly_symbol2scm ("char"), gh_int2scm (code),
                       SCM_UNDEFINED);
   at = fontify_atom (this, at);