]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tfm-reader.cc
* po/nl.po: Update.
[lilypond.git] / lily / tfm-reader.cc
index 37d3ecf7c3fc04e29c6b98b15a6dc5aeeef9d0ab..2e3b1148c90313137a38d239ad546dc7e2b3549b 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999--2001 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1999--2004 Jan Nieuwenhuizen <janneke@gnu.org>
   
 
   some code shamelessly copied from GNU fontutils-0.6/tfm/tfm_input.c
 
 #include "tfm-reader.hh"
 #include "string-convert.hh"
-#include "debug.hh"
+#include "warn.hh"
 #include "warn.hh"
 
-#define format_str String_convert::form_str
-#define FIX_UNITY (1 << 20)
+#define format_string String_convert::form_string
+#define FIX_UNITY \
+ (1 << 20)
 static const Real fix_to_real (Fix f);
 
 
@@ -42,7 +43,7 @@ fix_to_real (Fix f)
 /* Most quantities are fixed-point fractions.  */
 
 Real
-Tex_font_metric_reader::get_U32_fix_f ()
+Tex_font_metric_reader::get_U32_fix ()
 {
   return fix_to_real (input_.get_U32 ());
 }
@@ -50,16 +51,16 @@ Tex_font_metric_reader::get_U32_fix_f ()
 /* Dimensions are a `Fix' scaled by the design size.  */
 
 Real
-Tex_font_metric_reader::get_U32_fix_scaled_f ()
+Tex_font_metric_reader::get_U32_fix_scaled ()
 {
-  return get_U32_fix_f () * info_.design_size;
+  return get_U32_fix () * info_.design_size;
 }
 
 String
-Tex_font_metric_reader::get_bcpl_str ()
+Tex_font_metric_reader::get_bcpl_string ()
 {
   U8 length_u8 = input_.get_U8 ();
-  String str = input_.get_str (length_u8);
+  String str = input_.get_string (length_u8);
   return str;
 }
 
@@ -70,7 +71,7 @@ void
 Tex_font_metric_reader::read_header ()
 {
   U16 file_length = input_.get_U16 ();
 (void) file_length;
+ (void) file_length;
   U16 header_length = input_.get_U16 ();
 
   info_.first_charcode = input_.get_U16 ();
@@ -81,9 +82,9 @@ Tex_font_metric_reader::read_header ()
   U16 italic_correction_word_count = input_.get_U16 ();
   U16 lig_kern_word_count = input_.get_U16 ();
   U16 kern_word_count = input_.get_U16 ();
 (void)kern_word_count;
+ (void)kern_word_count;
   U16 extensible_word_count = input_.get_U16 ();
 (void)extensible_word_count;
+ (void)extensible_word_count;
   
   header_.param_word_count = input_.get_U16 ();
   info_.parameter_count = header_.param_word_count;
@@ -102,16 +103,18 @@ Tex_font_metric_reader::read_header ()
   /* We don't care about the extensible table.  */
 
   if (header_length < 2)
-    error (_f ("TFM header of `%s' has only %u word(s)",
-              input_.name_str ().ch_C (), header_length));
+    /* Not using ngettext's plural feature here, as this message is
+       more of a programming error.  */
+    error (_f ("TFM header of `%s' has only %u word (s)",
+              input_.name_string ().to_str0 (), header_length));
 
   info_.checksum = input_.get_U32 ();
-  info_.design_size = get_U32_fix_f ();
+  info_.design_size = get_U32_fix ();
 
   /* Although the coding scheme might be interesting to the caller, the
      font family and face byte probably aren't.  So we don't read them.  */
   info_.coding_scheme = header_length > 2
-    ? get_bcpl_str () : "unspecified";
+    ? get_bcpl_string () : "unspecified";
 
 }
 
@@ -130,14 +133,14 @@ Tex_font_metric_reader::read_params ()
 
   //brrr
   /* Move to the beginning of the parameter table in the file.  */
-  input_.seek_ch_C (-4 * header_.param_word_count);
+  input_.seek_str0 (-4 * header_.param_word_count);
 
   /* It's unlikely but possible that this TFM file has more fontdimens
      than we can deal with.  */
   if (header_.param_word_count > TFM_MAX_FONTDIMENS)
     {
       warning (_f ("%s: TFM file has %u parameters, which is more than the %u I can handle",
-                  input_.name_str ().ch_C (),
+                  input_.name_string ().to_str0 (),
                   header_.param_word_count,
                   TFM_MAX_FONTDIMENS));
       header_.param_word_count = TFM_MAX_FONTDIMENS;
@@ -145,10 +148,10 @@ Tex_font_metric_reader::read_params ()
 
   /* The first parameter is different than all the rest, because it
      isn't scaled by the design size.  */
-  info_.parameters[(TFM_SLANT_PARAMETER) - 1] = get_U32_fix_f ();
+  info_.parameters[ (TFM_SLANT_PARAMETER) - 1] = get_U32_fix ();
 
   for (Char_code i = 2; i <= header_.param_word_count; i++)
-    info_.parameters[i - 1] = get_U32_fix_scaled_f ();
+    info_.parameters[i - 1] = get_U32_fix_scaled ();
 
 }
 
@@ -183,7 +186,7 @@ Tex_font_metric_reader::read_char_metric (Char_code code)
   
   //brr
   /* Move to the appropriate place in the `char_info' array.  */
-  input_.seek_ch_C (header_.char_info_pos + (code - info_.first_charcode) * 4);
+  input_.seek_str0 (header_.char_info_pos + (code - info_.first_charcode) * 4);
 
   /* Read the character.  */
   tfm_char = read_char ();
@@ -221,16 +224,16 @@ Tex_font_metric_reader::read_char ()
 #define GET_CHAR_DIMEN(d) \
    if (d##_index != 0) \
      { \
-       input_.seek_ch_C (header_.##d##_pos + d##_index*4); \
+       input_.seek_str0 (header_. d##_pos + d##_index*4); \
        tfm_char.d##_fix_ = input_.get_U32 (); \
        tfm_char.d##_ = fix_to_real (tfm_char.d##_fix_) \
                       * info_.design_size; \
      }
 
-  GET_CHAR_DIMEN(width);
-  GET_CHAR_DIMEN(height);
-  GET_CHAR_DIMEN(depth);
-  GET_CHAR_DIMEN(italic_correction);
+  GET_CHAR_DIMEN (width);
+  GET_CHAR_DIMEN (height);
+  GET_CHAR_DIMEN (depth);
+  GET_CHAR_DIMEN (italic_correction);
 
   /* The other condition for a character existing is that it be between
      the first and last character codes given in the header.  We've
@@ -240,8 +243,8 @@ Tex_font_metric_reader::read_char ()
 
   if (tag == 1)
     {
-      input_.seek_ch_C (header_.lig_kern_pos + remainder * 4);
-      read_lig_kern_program (&tfm_char.ligature_arr_, &tfm_char.kern_arr_);
+      input_.seek_str0 (header_.lig_kern_pos + remainder * 4);
+      read_lig_kern_program (&tfm_char.ligatures_, &tfm_char.kerns_);
     }
 
   /* We don't handle the other tags.  */
@@ -256,7 +259,7 @@ Tex_font_metric_reader::read_char ()
 #define KERN_FLAG 128
 
 void
-Tex_font_metric_reader::read_lig_kern_program (Array <Tfm_ligature>* ligature_arr_p, Array <Tfm_kern>* kern_arr_p)
+Tex_font_metric_reader::read_lig_kern_program (Array <Tfm_ligature>* ligatures, Array <Tfm_kern>* kerns)
 {
   bool end_b;
 
@@ -274,12 +277,12 @@ Tex_font_metric_reader::read_lig_kern_program (Array <Tfm_ligature>* ligature_ar
          Tfm_kern kern_element;
          kern_element.character = next_char;
 
-         char const* old_pos = input_.pos_ch_C ();
-         input_.seek_ch_C (header_.kern_pos + remainder * 4);
-         kern_element.kern = get_U32_fix_scaled_f ();
+         char const* old_pos = input_.pos_str0 ();
+         input_.seek_str0 (header_.kern_pos + remainder * 4);
+         kern_element.kern = get_U32_fix_scaled ();
          input_.set_pos (old_pos);
 
-         kern_arr_p->push (kern_element);
+         kerns->push (kern_element);
 
        }
       else
@@ -287,7 +290,7 @@ Tex_font_metric_reader::read_lig_kern_program (Array <Tfm_ligature>* ligature_ar
          Tfm_ligature ligature_element;
          ligature_element.character = next_char;
          ligature_element.ligature = remainder;
-         ligature_arr_p->push (ligature_element);
+         ligatures->push (ligature_element);
 
        }
   } while (!end_b);