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>
11 #include "open-type-font.hh"
16 Open_type_font::make_otf (String str)
18 Open_type_font * otf = new Open_type_font;
19 int error_code = FT_New_Face(freetype2_library, str.to_str0(),
22 if (error_code == FT_Err_Unknown_File_Format)
24 error("Unsupported font format");
28 error ("Unknown error reading font file.");
31 return otf->self_scm ();
34 Open_type_font::~Open_type_font()
41 Open_type_font::get_indexed_char (int signed_idx) const
43 FT_UInt idx = signed_idx;
48 FT_Glyph_Metrics m = face_->glyph->metrics;
49 int hb = m.horiBearingX;
50 int vb = m.horiBearingY;
51 Box b (Interval (-hb, m.width - hb),
52 Interval (-vb, m.height - vb));
58 Open_type_font::name_to_index (String nm) const
60 char * nm_str = (char * )nm.to_str0 ();
61 int idx = FT_Get_Name_Index (face_, nm_str);
71 Open_type_font::design_size () const