static const Real fix_to_real (Fix f);
-Tex_font_metric_reader::Tex_font_metric_reader (String name)
+Tex_font_metric_reader::Tex_font_metric_reader (Tex_font_metric* fp, String name)
: input_ (name)
{
- tfm_.clear (TFM_SIZE);
-}
-
-Tex_font_metric
-Tex_font_metric_reader::read_tfm ()
-{
+ tfm_l_=fp;
+ tfm_l_->clear (TFM_SIZE);
read_header ();
read_params ();
read_char_metrics ();
- return tfm_;
+
+}
+
+Tex_font_metric *
+Tex_font_metric_reader::read_file (String name)
+{
+ Tex_font_metric * tfmp = new Tex_font_metric;
+ Tex_font_metric_reader tfm_reader (tfmp, name);
+
+ return tfmp;
}
+
+
static const Real
fix_to_real (Fix f)
{
Real
Tex_font_metric_reader::get_U32_fix_scaled_f ()
{
- return get_U32_fix_f () * tfm_.info_.design_size;
+ return get_U32_fix_f () * tfm_l_->info_.design_size;
}
String
(void) file_length;
U16 header_length = input_.get_U16 ();
- tfm_.info_.first_charcode = input_.get_U16 ();
- tfm_.info_.last_charcode = input_.get_U16 ();
+ tfm_l_->info_.first_charcode = input_.get_U16 ();
+ tfm_l_->info_.last_charcode = input_.get_U16 ();
U16 width_word_count = input_.get_U16 ();
U16 height_word_count = input_.get_U16 ();
U16 depth_word_count = input_.get_U16 ();
U16 extensible_word_count = input_.get_U16 ();
(void)extensible_word_count;
- tfm_.header_.param_word_count = input_.get_U16 ();
- tfm_.info_.parameter_count = tfm_.header_.param_word_count;
-
- tfm_.header_.char_info_pos = (6 + header_length) * 4;
- tfm_.header_.width_pos = tfm_.header_.char_info_pos
- + (tfm_.info_.last_charcode
- - tfm_.info_.first_charcode + 1) * 4;
- tfm_.header_.height_pos = tfm_.header_.width_pos + width_word_count * 4;
- tfm_.header_.depth_pos = tfm_.header_.height_pos + height_word_count * 4;
- tfm_.header_.italic_correction_pos = tfm_.header_.depth_pos
+ tfm_l_->header_.param_word_count = input_.get_U16 ();
+ tfm_l_->info_.parameter_count = tfm_l_->header_.param_word_count;
+
+ tfm_l_->header_.char_info_pos = (6 + header_length) * 4;
+ tfm_l_->header_.width_pos = tfm_l_->header_.char_info_pos
+ + (tfm_l_->info_.last_charcode
+ - tfm_l_->info_.first_charcode + 1) * 4;
+ tfm_l_->header_.height_pos = tfm_l_->header_.width_pos + width_word_count * 4;
+ tfm_l_->header_.depth_pos = tfm_l_->header_.height_pos + height_word_count * 4;
+ tfm_l_->header_.italic_correction_pos = tfm_l_->header_.depth_pos
+ depth_word_count * 4;
- tfm_.header_.lig_kern_pos = tfm_.header_.italic_correction_pos
+ tfm_l_->header_.lig_kern_pos = tfm_l_->header_.italic_correction_pos
+ italic_correction_word_count * 4;
- tfm_.header_.kern_pos = tfm_.header_.lig_kern_pos + lig_kern_word_count * 4;
+ tfm_l_->header_.kern_pos = tfm_l_->header_.lig_kern_pos + lig_kern_word_count * 4;
/* 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));
- tfm_.info_.checksum = input_.get_U32 ();
- tfm_.info_.design_size = get_U32_fix_f ();
+ tfm_l_->info_.checksum = input_.get_U32 ();
+ tfm_l_->info_.design_size = get_U32_fix_f ();
/* 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. */
- tfm_.info_.coding_scheme = header_length > 2
+ tfm_l_->info_.coding_scheme = header_length > 2
? get_bcpl_str () : "unspecified";
DEBUG_OUT << format_str ("TFM checksum = %u, design_size = %fpt, coding scheme = `%s'.\n",
- tfm_.info_.checksum,
- tfm_.info_.design_size,
- tfm_.info_.coding_scheme.ch_C ());
+ tfm_l_->info_.checksum,
+ tfm_l_->info_.design_size,
+ tfm_l_->info_.coding_scheme.ch_C ());
}
/* Although TFM files are only usable by TeX if they have at least seven
Tex_font_metric_reader::read_params ()
{
/* If we have no font parameters at all, we're done. */
- if (tfm_.header_.param_word_count == 0)
+ if (tfm_l_->header_.param_word_count == 0)
return;
//brrr
/* Move to the beginning of the parameter table in the file. */
- input_.seek_ch_C (-4 * tfm_.header_.param_word_count);
+ input_.seek_ch_C (-4 * tfm_l_->header_.param_word_count);
/* It's unlikely but possible that this TFM file has more fontdimens
than we can deal with. */
- if (tfm_.header_.param_word_count > TFM_MAX_FONTDIMENS)
+ if (tfm_l_->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 (),
- tfm_.header_.param_word_count,
+ tfm_l_->header_.param_word_count,
TFM_MAX_FONTDIMENS));
- tfm_.header_.param_word_count = TFM_MAX_FONTDIMENS;
+ tfm_l_->header_.param_word_count = TFM_MAX_FONTDIMENS;
}
/* The first parameter is different than all the rest, because it
isn't scaled by the design size. */
- tfm_.info_.parameters[(TFM_SLANT_PARAMETER) - 1] = get_U32_fix_f ();
+ tfm_l_->info_.parameters[(TFM_SLANT_PARAMETER) - 1] = get_U32_fix_f ();
- for (Char_code i = 2; i <= tfm_.header_.param_word_count; i++)
- tfm_.info_.parameters[i - 1] = get_U32_fix_scaled_f ();
+ for (Char_code i = 2; i <= tfm_l_->header_.param_word_count; i++)
+ tfm_l_->info_.parameters[i - 1] = get_U32_fix_scaled_f ();
#ifdef PRINT
- for (Char_code i = 1; i <= tfm_.header_.param_word_count; i++)
- DEBUG_OUT << format_str ("TFM parameter %d: %.3f", i, tfm_.info_.parameters[i - 1]);
+ for (Char_code i = 1; i <= tfm_l_->header_.param_word_count; i++)
+ DEBUG_OUT << format_str ("TFM parameter %d: %.3f", i, tfm_l_->info_.parameters[i - 1]);
#endif
}
void
Tex_font_metric_reader::read_char_metrics ()
{
- for (int i = tfm_.info_.first_charcode; i <= tfm_.info_.last_charcode; i++)
+ for (int i = tfm_l_->info_.first_charcode; i <= tfm_l_->info_.last_charcode; i++)
{
Tex_font_char_metric tfm_char = read_char_metric (i);
if (tfm_char.exists_b_)
- tfm_.ascii_to_metric_idx_[tfm_char.code_] = tfm_.char_metrics_.size ();
- tfm_.char_metrics_.push (tfm_char);
+ tfm_l_->ascii_to_metric_idx_[tfm_char.code_] = tfm_l_->char_metrics_.size ();
+ tfm_l_->char_metrics_.push (tfm_char);
}
}
/* If the character is outside the declared bounds in the file, don't
try to read it. */
- if (code < tfm_.info_.first_charcode || code > tfm_.info_.last_charcode)
+ if (code < tfm_l_->info_.first_charcode || code > tfm_l_->info_.last_charcode)
return tfm_char;
//brr
/* Move to the appropriate place in the `char_info' array. */
- input_.seek_ch_C (tfm_.header_.char_info_pos + (code - tfm_.info_.first_charcode) * 4);
+ input_.seek_ch_C (tfm_l_->header_.char_info_pos + (code - tfm_l_->info_.first_charcode) * 4);
/* Read the character. */
tfm_char = read_char ();
#define GET_CHAR_DIMEN(d) \
if (d##_index != 0) \
{ \
- input_.seek_ch_C (tfm_.header_.##d##_pos + d##_index*4); \
+ input_.seek_ch_C (tfm_l_->header_.##d##_pos + d##_index*4); \
tfm_char.d##_fix_ = input_.get_U32 (); \
tfm_char.d##_ = fix_to_real (tfm_char.d##_fix_) \
- * tfm_.info_.design_size; \
+ * tfm_l_->info_.design_size; \
}
GET_CHAR_DIMEN (width);
if (tag == 1)
{
- input_.seek_ch_C (tfm_.header_.lig_kern_pos + remainder * 4);
+ input_.seek_ch_C (tfm_l_->header_.lig_kern_pos + remainder * 4);
read_lig_kern_program (&tfm_char.ligature_arr_, &tfm_char.kern_arr_);
}
kern_element.character = next_char;
char const* old_pos = input_.pos_ch_C ();
- input_.seek_ch_C (tfm_.header_.kern_pos + remainder * 4);
+ input_.seek_ch_C (tfm_l_->header_.kern_pos + remainder * 4);
kern_element.kern = get_U32_fix_scaled_f ();
input_.set_pos (old_pos);