]> git.donarmstrong.com Git - lilypond.git/blob - lily/afm.cc
release: 1.0.13
[lilypond.git] / lily / afm.cc
1 /*   
2   afm.cc --  implement Adobe_font_metric
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "afm.hh"
11 #include "box.hh"
12 #include "direction.hh"
13 #include "debug.hh"
14
15 Box &
16 Adobe_font_char_metric::bbox ()
17 {
18   return B_;
19 }
20
21 String &
22 Adobe_font_char_metric::name ()
23 {
24   return N_;
25   
26 }
27
28 int &
29 Adobe_font_char_metric::code ()
30 {
31   return C_;
32 }
33
34 Real &
35 Adobe_font_char_metric::width ()
36 {
37   return WX_;
38 }
39
40 Adobe_font_char_metric::Adobe_font_char_metric ()
41 {
42   C_ = 0;
43 }
44
45 Adobe_font_metric::Adobe_font_metric ()
46 {
47   ItalicAngle_ = 0.0;
48   IsFixedPitch_ = false;
49   UnderlinePosition_ =0.;
50   UnderlineThickness_=0.;
51 }
52
53
54 #define APPEND_CHAR_METRIC_ELT(k)  outstr += to_str (#k) + " "  + to_str (k ## _)  + "; "
55
56 String
57 box_str (Box b)
58 {
59   return to_str (b[X_AXIS][SMALLER]) + " " +
60     to_str(b[Y_AXIS][SMALLER]) + " " +
61     to_str (b[X_AXIS][BIGGER]) + " "+
62     to_str (b[Y_AXIS][BIGGER]);
63 }
64
65 #define APPEND_BOX(k)  outstr += to_str (#k) + " "  + box_str (k ## _)  + ";"
66
67 String
68 Adobe_font_char_metric::str () const
69 {
70   String outstr ;
71
72   APPEND_CHAR_METRIC_ELT (C);
73   APPEND_CHAR_METRIC_ELT(N);
74   APPEND_CHAR_METRIC_ELT(WX);
75   
76   APPEND_BOX(B);
77   return outstr + "\n";
78 }
79
80 #define WRITESTRING(k)  outstr += String (#k) + " "  + to_str (k ## _)  + "\n"
81
82 String
83 Adobe_font_metric::str () const
84 {
85   String outstr;
86   WRITESTRING(FontName);
87   WRITESTRING(FullName);
88   WRITESTRING(FamilyName);
89   WRITESTRING(Weight);
90   WRITESTRING(Version);
91   WRITESTRING(Notice);
92   WRITESTRING(EncodingScheme);
93   WRITESTRING(ItalicAngle);
94   WRITESTRING(UnderlineThickness);
95   WRITESTRING(UnderlinePosition);
96   outstr += "FontBBox " +  box_str (FontBBox_) +  "\n";
97
98   for (int i=0; i < char_metrics_.size (); i++)
99     outstr += char_metrics_[i].str ();
100   
101   return outstr;
102 }
103
104 /*
105   UGH. should have hashtable.
106  */
107 Adobe_font_char_metric
108 Adobe_font_metric::find_char (String nm, bool warn) const
109 {
110   for (int i=0; i < char_metrics_.size (); i++)
111     if (char_metrics_[i].N_ == nm)
112       return char_metrics_[i];
113   if (warn)
114     warning (_f ("can't find character called `%s'", nm.ch_C()));
115
116  Adobe_font_char_metric a;
117  return a;
118 }