diff options
author | Minijackson <minijackson@riseup.net> | 2023-01-25 16:02:26 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2023-01-25 16:02:26 +0100 |
commit | e5dede2ad50b13d37031b29c6e28868851b77d37 (patch) | |
tree | 780e79e7da3a66476e0099a49376071240eee6d2 /cairo-renderer/src/lib.rs | |
parent | 5d9e2b87d68c2db57f7851e0e321ded41deceffe (diff) | |
download | diaphragm-e5dede2ad50b13d37031b29c6e28868851b77d37.tar.gz diaphragm-e5dede2ad50b13d37031b29c6e28868851b77d37.zip |
cairo: have proper font size
Diffstat (limited to 'cairo-renderer/src/lib.rs')
-rw-r--r-- | cairo-renderer/src/lib.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/cairo-renderer/src/lib.rs b/cairo-renderer/src/lib.rs index 2a88379..40d24d1 100644 --- a/cairo-renderer/src/lib.rs +++ b/cairo-renderer/src/lib.rs | |||
@@ -80,11 +80,11 @@ impl Renderer for CairoRenderer { | |||
80 | 80 | ||
81 | fn text_extents(&self, text: &str, font: &FontDescription) -> (f64, f64) { | 81 | fn text_extents(&self, text: &str, font: &FontDescription) -> (f64, f64) { |
82 | // Pango gives us integer back, so we lose some precision. We use this for that. | 82 | // Pango gives us integer back, so we lose some precision. We use this for that. |
83 | const TEST_ABSOLUTE_SIZE: f64 = 1_000_000.; | 83 | const TEST_ABSOLUTE_SIZE: f64 = 10_000.; |
84 | 84 | ||
85 | let layout = pangocairo::create_layout(&self.ctx); | 85 | let layout = pangocairo::create_layout(&self.ctx); |
86 | let mut font_desc = pango::FontDescription::from_string(&font.family); | 86 | let mut font_desc = pango::FontDescription::from_string(&font.family); |
87 | font_desc.set_absolute_size(TEST_ABSOLUTE_SIZE); | 87 | font_desc.set_absolute_size(TEST_ABSOLUTE_SIZE * pango::SCALE as f64); |
88 | layout.set_font_description(Some(&font_desc)); | 88 | layout.set_font_description(Some(&font_desc)); |
89 | layout.set_markup(text); | 89 | layout.set_markup(text); |
90 | 90 | ||
@@ -111,7 +111,7 @@ impl Renderer for CairoRenderer { | |||
111 | let layout = pangocairo::create_layout(&self.ctx); | 111 | let layout = pangocairo::create_layout(&self.ctx); |
112 | let mut font_desc = pango::FontDescription::from_string(&font.family); | 112 | let mut font_desc = pango::FontDescription::from_string(&font.family); |
113 | 113 | ||
114 | font_desc.set_absolute_size(font.size as _); | 114 | font_desc.set_absolute_size(font.size * pango::SCALE as f64); |
115 | layout.set_font_description(Some(&font_desc)); | 115 | layout.set_font_description(Some(&font_desc)); |
116 | layout.set_markup(text); | 116 | layout.set_markup(text); |
117 | 117 | ||