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"
18 enumerate_glyphs (FT_Face face)
21 FT_ULong char_code = FT_Get_First_Char (face, &glyph_index);
24 // ... do something with (charcode,gindex) pair ...
26 charcode = FT_Get_Next_Char( face, charcode, &gindex );
33 Open_type_font::make_otf (String str)
35 Open_type_font * otf = new Open_type_font;
36 int error_code = FT_New_Face(freetype2_library, str.to_str0(),
39 // int code = FT_Set_Charmap (otf->face_, );
42 if (error_code == FT_Err_Unknown_File_Format)
44 error("Unsupported font format");
48 error ("Unknown error reading font file.");
51 return otf->self_scm ();
54 Open_type_font::~Open_type_font()
61 Open_type_font::get_indexed_char (int signed_idx)
63 FT_UInt idx = signed_idx;
69 FT_Glyph_Metrics m = face->glyph->metrics;
70 Box b (Interval (0, m->width) - m->horiBearingX,
71 Interval (0, m->height) - m->horiBearingY);
77 Open_type_font::name_to_index (String nm)
79 FT_String * nm_str = nm.to_str0 ();
80 int idx = FT_Get_Name_Index (face_, nm_str);
90 Open_type_font::get_design_size () const