Commit 3ac389e bjn
committed
1 parent 721ecc1 commit 3ac389e Copy full SHA for 3ac389e
File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,13 @@ namespace cycfi { namespace elements
163
163
point size;
164
164
};
165
165
166
+ struct font_metrics
167
+ {
168
+ float ascent;
169
+ float descent;
170
+ float height;
171
+ };
172
+
166
173
[[deprecated(" Use fill_text(utf8, p) instead following artist API." )]]
167
174
void fill_text (point p, char const * utf8);
168
175
void fill_text (std::string_view utf8, point p);
@@ -174,6 +181,8 @@ namespace cycfi { namespace elements
174
181
text_metrics measure_text (char const * utf8);
175
182
void text_align (int align);
176
183
184
+ font_metrics measure_font ();
185
+
177
186
// /////////////////////////////////////////////////////////////////////////////////
178
187
// Pixmaps
179
188
Original file line number Diff line number Diff line change @@ -417,6 +417,13 @@ namespace cycfi { namespace elements
417
417
};
418
418
}
419
419
420
+ canvas::font_metrics canvas::measure_font ()
421
+ {
422
+ cairo_font_extents_t font_extents;
423
+ cairo_scaled_font_extents (cairo_get_scaled_font (&_context), &font_extents);
424
+ return font_extents;
425
+ }
426
+
420
427
void canvas::draw (pixmap const & pm, elements::rect src, elements::rect dest)
421
428
{
422
429
auto state = new_state ();
@@ -443,4 +450,3 @@ namespace cycfi { namespace elements
443
450
cairo_restore (&_context);
444
451
}
445
452
}}
446
-
You can’t perform that action at this time.
0 commit comments