- return Font_metric::text_stencil (text);
-}
-
-Box
-Modified_font_metric::text_dimension (String text) const
-{
- SCM stext = scm_makfrom0str (text.to_str0 ());
- Box b = lookup_tex_text_dimension (orig_, stext);
- if (!b[Y_AXIS].is_empty ())
- {
- b.scale (magnification_);
- return b;
- }
-
- if (input_encoding_ == "TeX")
- b = tex_kludge (text);
- else if (input_encoding_ == "ASCII"
- || input_encoding_ == ""
- || input_encoding_ == orig_->coding_scheme ())
- {
- Interval ydims;
-
- Real w = 0.0;
-
- for (int i = 0; i < text.length (); i++)
- {
- Box b = get_ascii_char ((unsigned char)text[i]);
-
- w += b[X_AXIS].length ();
- ydims.unite (b[Y_AXIS]);
- }
- if (ydims.is_empty ())
- ydims = Interval (0, 0);
-
- b = Box(Interval(0,w), ydims);
- }
- else
- {
- Interval ydims;
- Real w = 0.0;
-
- for (int i = 0; i < text.length (); i++)
- {
- SCM sym = scm_vector_ref (coding_vector_,
- scm_from_int((unsigned char) text[i]));
-
- Box char_box;
-
- if (!scm_is_symbol (sym))
- continue;
-
- char const *chars = scm_i_string_chars (scm_symbol_to_string (sym));
-
- int idx = orig_->name_to_index (chars);
- if (idx >= 0)
- char_box = orig_->get_indexed_char (idx);
-
- if (!char_box[X_AXIS].is_empty ())
- /* length ? */
- w += char_box[X_AXIS][RIGHT];
-
- ydims.unite (char_box[Y_AXIS]);
- }
-
- if (ydims.is_empty ())
- ydims = Interval (0, 0);
-
- b = Box (Interval (0, w), ydims);
- b.scale (magnification_);
- }
-
- return b;