Add x- and cap height to metrics_t

This is to allow potential background bezels, images, and similar to be aligned with the text.
This commit is contained in:
Allan Odgaard
2012-09-09 11:15:38 +02:00
parent 732f486187
commit 92a058b0dd
2 changed files with 6 additions and 0 deletions

View File

@@ -33,6 +33,8 @@ namespace ct
_ascent = CTFontGetAscent(font);
_descent = CTFontGetDescent(font);
_leading = CTFontGetLeading(font);
_x_height = CTFontGetXHeight(font);
_cap_height = CTFontGetCapHeight(font);
_column_width = CTLineGetTypographicBounds(line, NULL, NULL, NULL);
_ascent_delta = read_double_from_defaults(CFSTR("fontAscentDelta"), 1);

View File

@@ -25,6 +25,8 @@ namespace ct
CGFloat ascent () const { return _ascent; }
CGFloat descent () const { return _descent; }
CGFloat leading () const { return _leading; }
CGFloat x_height () const { return _x_height; }
CGFloat cap_height () const { return _cap_height; }
CGFloat column_width () const { return _column_width; }
CGFloat baseline (CGFloat minAscent = 0) const { return round(std::max(minAscent, _ascent) + _ascent_delta); }
@@ -35,6 +37,8 @@ namespace ct
CGFloat _ascent;
CGFloat _descent;
CGFloat _leading;
CGFloat _x_height;
CGFloat _cap_height;
CGFloat _column_width;
CGFloat _ascent_delta = 1;