]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/font-metric.hh
Add Output_def argument to Font_metric::text_stencil().
[lilypond.git] / lily / include / font-metric.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef FONT_METRIC_HH
21 #define FONT_METRIC_HH
22
23 #include "box.hh"
24 #include "lily-proto.hh"
25 #include "smobs.hh"
26 #include "virtual-methods.hh"
27 #include "freetype.hh"
28
29 #include <map>
30 using namespace std;
31
32 typedef map<FT_UInt, FT_ULong> Index_to_charcode_map;
33
34 class Font_metric
35 {
36   DECLARE_CLASSNAME(Font_metric);
37
38 public:
39   SCM description_;
40   string file_name_;
41
42   // Return stencil for given string. output_state may be modified to
43   // record the font.
44   virtual Stencil text_stencil (Output_def* output_state,
45                                 string text, bool music) const;
46
47   // ugh.
48   virtual Box text_dimension (string) const;
49
50   virtual string font_name () const;
51   virtual size_t count () const;
52   virtual Offset attachment_point (string) const;
53   virtual Offset get_indexed_wxwy (size_t) const;
54   virtual Box get_indexed_char (size_t index) const;
55   virtual Box get_ascii_char (size_t ascii) const;
56
57   /*
58     WTF are these vsize ?
59
60     Font_metric is not related to vector<> 
61    */
62   virtual size_t name_to_index (string) const;
63   virtual size_t index_to_charcode (size_t) const;
64   virtual size_t index_to_ascii (size_t) const;
65   virtual Real design_size () const;
66   virtual Stencil find_by_name (string) const;
67   virtual Stencil get_indexed_char_stencil (size_t k) const;
68   virtual Stencil get_ascii_char_stencil (size_t k) const;
69   virtual SCM sub_fonts () const;
70   virtual SCM font_file_name () const;
71   DECLARE_SMOBS (Font_metric);
72
73 private:
74   /* No copying, no implicit copy constructor.  */
75   Font_metric (Font_metric const &);
76
77 protected:
78   virtual void derived_mark () const;
79
80   Font_metric ();
81 };
82
83 int get_encoded_index (Font_metric *m, string input_coding, int code);
84
85 class Simple_font_metric : public Font_metric
86 {
87   DECLARE_CLASSNAME(Simple_font_metric);
88 public:
89 };
90
91 DECLARE_UNSMOB (Font_metric, metrics);
92
93 char *pfb2pfa (Byte const *pfb, int length);
94
95 #endif /* FONT_METRIC_HH */