2 open-type-font.cc -- implement Open_type_font
4 source file of the GNU LilyPond music typesetter
6 (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
13 #include "open-type-font.hh"
14 #include "dimensions.hh"
17 Open_type_font::make_otf (String str)
19 Open_type_font * otf = new Open_type_font;
20 int error_code = FT_New_Face(freetype2_library, str.to_str0(),
23 if (error_code == FT_Err_Unknown_File_Format)
25 error("Unsupported font format");
29 error ("Unknown error reading font file.");
32 return otf->self_scm ();
35 Open_type_font::~Open_type_font()
42 Open_type_font::get_indexed_char (int signed_idx) const
44 FT_UInt idx = signed_idx;
49 FT_Glyph_Metrics m = face_->glyph->metrics;
50 int hb = m.horiBearingX;
51 int vb = m.horiBearingY;
52 Box b (Interval (-hb, m.width - hb),
53 Interval (-vb, m.height - vb));
55 Real point_constant = 1 PT;
58 b.scale (design_size() * Real (point_constant) / face_->units_per_EM);
63 Open_type_font::name_to_index (String nm) const
65 char * nm_str = (char * )nm.to_str0 ();
66 int idx = FT_Get_Name_Index (face_, nm_str);
76 Open_type_font::design_size () const