X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftfm-reader.cc;h=c7ca5ee6c9eb40928e8b5db93dd1d10dd58a5b7d;hb=f803dfe5c67d7a51f3b9b347f41fe43005963810;hp=1edeef43c568e58ab28006d49a0f94f6f4d1d909;hpb=332da9f4d25f9f63a3222efc87fae06b0c7abbdd;p=lilypond.git diff --git a/lily/tfm-reader.cc b/lily/tfm-reader.cc index 1edeef43c5..c7ca5ee6c9 100644 --- a/lily/tfm-reader.cc +++ b/lily/tfm-reader.cc @@ -1,13 +1,13 @@ -/* - tfm-reader.cc -- implement Tex_font_metric_reader - +/* + tfm-reader.cc -- implement Tex_font_metric_reader + source file of the GNU LilyPond music typesetter - - (c) 1999--2004 Jan Nieuwenhuizen - + + (c) 1999--2005 Jan Nieuwenhuizen + some code shamelessly copied from GNU fontutils-0.6/tfm/tfm_input.c - */ +*/ #include "tfm-reader.hh" @@ -15,22 +15,20 @@ #include "warn.hh" #define format_string String_convert::form_string -#define FIX_UNITY \ - (1 << 20) +#define FIX_UNITY \ + (1 << 20) static const Real fix_to_real (Fix f); - Tex_font_metric_reader::Tex_font_metric_reader (String name) : input_ (name) { - + for (int i = 0; i < TFM_SIZE; i++) ascii_to_metric_idx_.push (-1); read_header (); read_params (); read_char_metrics (); - } static const Real @@ -71,7 +69,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 (); @@ -82,21 +80,21 @@ 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; header_.char_info_pos = (6 + header_length) * 4; header_.width_pos = header_.char_info_pos - + (info_.last_charcode - - info_.first_charcode + 1) * 4; + + (info_.last_charcode + - info_.first_charcode + 1) * 4; header_.height_pos = header_.width_pos + width_word_count * 4; header_.depth_pos = header_.height_pos + height_word_count * 4; header_.italic_correction_pos = header_.depth_pos - + depth_word_count * 4; + + depth_word_count * 4; header_.lig_kern_pos = header_.italic_correction_pos + italic_correction_word_count * 4; header_.kern_pos = header_.lig_kern_pos + lig_kern_word_count * 4; @@ -115,7 +113,6 @@ Tex_font_metric_reader::read_header () font family and face byte probably aren't. So we don't read them. */ info_.coding_scheme = header_length > 2 ? get_bcpl_string () : "unspecified"; - } /* Although TFM files are only usable by TeX if they have at least seven @@ -152,7 +149,6 @@ Tex_font_metric_reader::read_params () for (Char_code i = 2; i <= header_.param_word_count; i++) info_.parameters[i - 1] = get_U32_fix_scaled (); - } /* Read every character in the TFM file, storing the result in the @@ -183,7 +179,7 @@ Tex_font_metric_reader::read_char_metric (Char_code code) try to read it. */ if (code < info_.first_charcode || code > info_.last_charcode) return tfm_char; - + //brr /* Move to the appropriate place in the `char_info' array. */ input_.seek_str0 (header_.char_info_pos + (code - info_.first_charcode) * 4); @@ -197,7 +193,6 @@ Tex_font_metric_reader::read_char_metric (Char_code code) return tfm_char; } - /* We assume we are positioned at the beginning of a `char_info' word. We read that word to get the indexes into the dimension tables; then we go read the tables to get the values (if the character exists). */ @@ -221,14 +216,14 @@ Tex_font_metric_reader::read_char () Tex_font_char_metric tfm_char; -#define GET_CHAR_DIMEN(d) \ - if (d##_index != 0) \ - { \ - 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; \ - } +#define GET_CHAR_DIMEN(d) \ + if (d##_index != 0) \ + { \ + 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); @@ -259,7 +254,7 @@ Tex_font_metric_reader::read_char () #define KERN_FLAG 128 void -Tex_font_metric_reader::read_lig_kern_program (Array * ligatures, Array * kerns) +Tex_font_metric_reader::read_lig_kern_program (Array *ligatures, Array *kerns) { bool end_b; @@ -271,19 +266,17 @@ Tex_font_metric_reader::read_lig_kern_program (Array * ligatures, bool kern_step_b = input_.get_U8 () >= KERN_FLAG; U8 remainder = input_.get_U8 (); - if (kern_step_b) { Tfm_kern kern_element; kern_element.character = next_char; - char const* old_pos = input_.pos_str0 (); + 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); kerns->push (kern_element); - } else { @@ -291,8 +284,8 @@ Tex_font_metric_reader::read_lig_kern_program (Array * ligatures, ligature_element.character = next_char; ligature_element.ligature = remainder; ligatures->push (ligature_element); - } - } while (!end_b); + } + while (!end_b); }