]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/font-metric.hh
Issue 1388: Initial work to support opentype font features.
[lilypond.git] / lily / include / font-metric.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2015 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 "freetype.hh"
25 #include "lily-proto.hh"
26 #include "smobs.hh"
27 #include "virtual-methods.hh"
28
29 #include <map>
30
31 typedef std::map<FT_UInt, FT_ULong> Index_to_charcode_map;
32
33 class Font_metric : public Smob<Font_metric>
34 {
35 public:
36   int print_smob (SCM, scm_print_state *) const;
37   SCM mark_smob () const;
38   static const char * const type_p_name_;
39   virtual ~Font_metric ();
40 private:
41   DECLARE_CLASSNAME (Font_metric);
42
43 public:
44   SCM description_;
45   string file_name_;
46
47   // Return stencil for given string. output_state may be modified to
48   // record the font.
49   virtual Stencil text_stencil (Output_def *output_state,
50                                 const string &text,
51                                 bool music,
52                                 const string &features_str) const;
53
54   virtual string font_name () const;
55   virtual size_t count () const;
56   virtual Offset attachment_point (const string&) const;
57   virtual Offset get_indexed_wxwy (size_t) const;
58   virtual Box get_indexed_char_dimensions (size_t index) const;
59   virtual size_t name_to_index (string) const=0;
60   virtual size_t index_to_charcode (size_t) const;
61   virtual Real design_size () const;
62   virtual Stencil find_by_name (string) const;
63   virtual SCM sub_fonts () const;
64   virtual SCM font_file_name () const;
65
66 private:
67   /* No copying, no implicit copy constructor.  */
68   Font_metric (Font_metric const &);
69
70 protected:
71   virtual void derived_mark () const;
72
73   Font_metric ();
74 };
75
76
77 vector<char> pfb2pfa (const vector<char> &pfb);
78
79 #endif /* FONT_METRIC_HH */