]> git.donarmstrong.com Git - lilypond.git/blob - lily/open-type-font.cc
new file.
[lilypond.git] / lily / open-type-font.cc
1 /*
2   open-type-font.cc --  implement Open_type_font
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #include "warn.hh"
11 #include "open-type-font.hh"
12
13 SCM
14 Open_type_font::make_otf (String str)
15 {
16   Open_type_font * otf = new Open_type_font;
17   int error_code = FT_New_Face( freetype2_library, str.to_str0(),
18                        0, &(otf->face_));
19
20   //  int code = FT_Set_Charmap (otf->face_, );   
21
22   
23   if (error_code == FT_Err_Unknown_File_Format)
24     {
25       error("Unsupported font format");
26     }
27   else if (error_code)
28     {
29       error ("Unknown error reading font file.");
30     }
31
32   return otf->self_scm ();
33 }
34
35 Open_type_font::~Open_type_font()
36 {
37   FT_Done_Face (face_);
38 }
39
40
41 Box
42 Open_type_font::get_indexed_char (int signed_idx)
43 {
44   FT_UInt idx = signed_idx;
45   int code = 
46     FT_Load_Glyph (face_,
47                    idx,
48                    FT_LOAD_NO_SCALE);
49
50   FT_Glyph_Metrics m = face->glyph->metrics;
51   Box b (Interval (0, m->width) - m->horiBearingX,
52          Interval (0, m->height) - m->horiBearingY);
53   
54   return b;
55 }
56
57 int
58 Open_type_font::name_to_index (String nm)
59 {
60   
61 }
62
63
64 Real
65 Open_type_font::get_design_size () const
66 {
67   return 20.0;
68 }