]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/pango-font.hh
aaae077b769d01bd257e1e96414581a6ea147dd4
[lilypond.git] / lily / include / pango-font.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2004--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 PANGO_FONT_HH
21 #define PANGO_FONT_HH
22
23 #include "config.hh"
24
25 #if HAVE_PANGO_FT2
26
27 #include <pango/pango.h>
28 #include <pango/pangoft2.h>
29
30 #include "font-metric.hh"
31
32 struct Preinit_Pango_font {
33   SCM physical_font_tab_;
34   Preinit_Pango_font ();
35 };
36
37 class Pango_font : Preinit_Pango_font, public Font_metric
38 {
39   PangoContext *context_;
40   PangoFontDescription *pango_description_;
41   PangoAttrList *attribute_list_;
42   Real scale_;
43   Real output_scale_;
44   Direction text_direction_;
45
46 public:
47   SCM physical_font_tab () const;
48   Pango_font (PangoFT2FontMap *,
49               PangoFontDescription const *,
50               Real);
51   ~Pango_font ();
52
53   string description_string () const;
54   SCM font_file_name () const;
55   void register_font_file (const string &filename, const string &ps_name, int face_index);
56
57   size_t name_to_index (string) const;
58   SCM get_glyph_outline (size_t signed_idx) const;
59   Box get_glyph_outline_bbox (size_t signed_idx) const;
60   Box get_unscaled_indexed_char_dimensions (size_t) const;
61   Box get_scaled_indexed_char_dimensions (size_t) const;
62
63   Stencil pango_item_string_stencil (PangoGlyphItem const *) const;
64
65   virtual Stencil text_stencil (Output_def *output_state,
66                                 const string &text, bool music) const;
67   virtual void derived_mark () const;
68 };
69
70 PangoFontDescription *
71 symbols_to_pango_font_description (SCM family,
72                                    SCM style,
73                                    SCM variant,
74                                    SCM weight,
75                                    SCM stretch);
76
77 Font_metric *
78 select_pango_font (Output_def *layout, SCM chain);
79
80 const int PANGO_RESOLUTION = 1200;
81 PangoFontDescription *properties_to_pango_description (SCM chain, Real text_size);
82
83 #endif /* HAVE_PANGO16 */
84 #endif /* PANGO_FONT_HH */
85