2 tfm.cc -- implement Tex_font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
9 some code shamelessly copied from GNU fontutils-0.6/tfm/tfm_input.c
13 #include "tfm-reader.hh"
14 #include "string-convert.hh"
19 Tex_font_char_metric::dimensions () const
22 return Box (Interval (0, width_
),Interval ( d
<? height_
, d
>? height_
));
25 Tex_font_char_metric::Tex_font_char_metric ()
29 width_
= height_
= depth_
= italic_correction_
= 0;
30 width_fix_
= height_fix_
= depth_fix_
= italic_correction_fix_
= 0;
33 #define APPEND_CHAR_METRIC_ELT(k) outstr += to_str (#k) + " " + to_str (k ## _) + "; "
36 Tex_font_char_metric::str () const
40 APPEND_CHAR_METRIC_ELT (exists_b
);
41 APPEND_CHAR_METRIC_ELT (code
);
42 APPEND_CHAR_METRIC_ELT (width
);
43 APPEND_CHAR_METRIC_ELT (height
);
44 APPEND_CHAR_METRIC_ELT (depth
);
45 APPEND_CHAR_METRIC_ELT (italic_correction
);
50 Tex_font_metric::Tex_font_metric ()
54 static Tex_font_char_metric dummy_static_char_metric
;
56 Tex_font_char_metric
const &
57 Tex_font_metric::find_ascii (int ascii
, bool warn
) const
59 if (ascii
< ascii_to_metric_idx_
.size() && ascii_to_metric_idx_
[ascii
] >= 0)
60 return char_metrics_
[ascii_to_metric_idx_
[ascii
]];
64 warning (_f ("Can't find ascii character: `%d'", ascii
));
66 return dummy_static_char_metric
;
69 Character_metric
const*
70 Tex_font_metric::get_char (int a
, bool w
) const
72 return &find_ascii (a
, w
);
77 Tex_font_metric::str () const
80 for (int i
=0; i
< char_metrics_
.size (); i
++)
81 outstr
+= char_metrics_
[i
].str ();
87 Tex_font_metric::clear (int n
)
89 for (int i
=0; i
< n
; i
++)
90 ascii_to_metric_idx_
.push (-1);