This file is part of LilyPond, the GNU music typesetter.
Copyright (C) 1999--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
- Mats Bengtsson <matsb@s3.kth.se> (the ugly TeX parsing in text_dimension)
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
programming_error ("Cannot get a text stencil from this font");
return Stencil (Box (), SCM_EOL);
}
-
-Box
-Font_metric::text_dimension (string) const
-{
- return Box (Interval (0, 0), Interval (0, 0));
-}
-
virtual Stencil text_stencil (Output_def* output_state,
string text, bool music) const;
- // ugh.
- virtual Box text_dimension (string) const;
-
virtual string font_name () const;
virtual size_t count () const;
virtual Offset attachment_point (string) const;
int get_encoded_index (Font_metric *m, string input_coding, int code);
-class Simple_font_metric : public Font_metric
-{
- DECLARE_CLASSNAME(Simple_font_metric);
-public:
-};
-
DECLARE_UNSMOB (Font_metric, metrics);
char *pfb2pfa (Byte const *pfb, int length);
struct Modified_font_metric : public Font_metric
{
public:
- Box text_dimension (string) const;
- Box word_dimension (string) const;
Stencil text_stencil (Output_def* output_state, string, bool) const;
static SCM make_scaled_font_metric (Font_metric *fm, Real magnification);
return Font_metric::text_stencil (state, text, feta);
}
-Box
-Modified_font_metric::text_dimension (string text) const
-{
- Box b;
- Interval ydims;
- Real w = 0.0;
-
- for (ssize 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);
- return b;
-}
-
Font_metric *
Modified_font_metric::original_font () const
{