InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SLCLineMetrics.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Adobe Developer Technologies
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __SLCLineMetrics_h__
25 #define __SLCLineMetrics_h__
26 
27 #include "Trace.h"
28 #include "IParcel.h"
29 
54 {
55 public:
59  {
60  SetLeading(0.0);
61  SetAscent(0.0);
62  SetCapHeight(0.0);
63  SetXHeight(0.0);
64  };
65 
69  {
71  SetAscent(h.GetAscent());
74  };
75 
79  {
80  if (this != &h)
81  {
83  SetAscent(h.GetAscent());
86  }
87  return *this;
88  };
89 
93  void SetLeading(const PMReal& leading)
94  {
95  fLineHeightMetricValues [Text::kFLOLeading] = leading;
96  };
97 
100  const PMReal& GetLeading(void) const
101  {
102  return fLineHeightMetricValues [Text::kFLOLeading];
103  };
104 
108  void SetAscent(const PMReal& ascent)
109  {
110  fLineHeightMetricValues [Text::kFLOAscent] = ascent;
111  // kFLOFixedHeight note: Fudge to ensure we pass
112  // in a non zero value for the top of frame height when asking for tiles.
113  // FixedHeight is a property of the parcel that is not affected by the
114  // metrics of the text in the parcel.
115  fLineHeightMetricValues [Text::kFLOFixedHeight] = ascent;
116  };
117 
120  const PMReal& GetAscent(void) const
121  {
122  return fLineHeightMetricValues [Text::kFLOAscent];
123  };
124 
128  void SetCapHeight(const PMReal& capHeight)
129  {
130  fLineHeightMetricValues [Text::kFLOCapHeight] = capHeight;
131  };
132 
135  const PMReal& GetCapHeight(void) const
136  {
137  return fLineHeightMetricValues [Text::kFLOCapHeight];
138  };
139 
143  void SetXHeight(const PMReal& xHeight)
144  {
145  fLineHeightMetricValues [Text::kFLOxHeight] = xHeight;
146  };
147 
150  const PMReal& GetXHeight(void) const
151  {
152  return fLineHeightMetricValues [Text::kFLOxHeight];
153  };
154 
159  const PMReal& GetValue(const Text::FirstLineOffsetMetric& metric) const
160  {
161  ASSERT_MSG(metric <= Text::kFLOFixedHeight, "Invalid metric");
162  if (metric <= Text::kFLOFixedHeight)
163  {
164  return fLineHeightMetricValues [metric];
165  }
166  return fLineHeightMetricValues [Text::kFLOLeading];
167  };
168 
171  void Dump(const char* category, const char* msg)
172  {
173  TRACEFLOW(category, "%s leading %f, ascent %f, capHeight %f, xHeight %f\n",
174  msg,
175  ::ToDouble(GetLeading()),
176  ::ToDouble(GetAscent()),
177  ::ToDouble(GetCapHeight()),
178  ::ToDouble(GetXHeight())
179  );
180  };
181 private:
184  PMReal fLineHeightMetricValues [Text::kFLOCount];
185 };
186 
187 #endif // __SLCLineMetrics__
188 
189 // End of File SLCLineMetrics.h
190