[librsvg: 10/18] Do not modify the font description from the pango::Context




commit a77f1754854f53f14b1495f1878ec574fed61025
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Oct 25 18:43:26 2021 -0500

    Do not modify the font description from the pango::Context
    
    Create a new pango::FontDescription every time.  Per Pango's docs, the
    context's font description should not be modified.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/621>

 src/text.rs | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index 66e478a9..d76d4b20 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -1186,7 +1186,7 @@ fn create_pango_layout(draw_ctx: &DrawingCtx, props: &FontProperties, text: &str
     let layout = pango::Layout::new(&pango_context);
 
     let attr_list = pango::AttrList::new();
-    add_pango_attributes(&attr_list, &pango_context, props);
+    add_pango_attributes(&attr_list, props);
 
     layout.set_attributes(Some(&attr_list));
     layout.set_text(text);
@@ -1196,12 +1196,8 @@ fn create_pango_layout(draw_ctx: &DrawingCtx, props: &FontProperties, text: &str
 }
 
 /// Adds Pango attributes, suitable for a span of text, to an `AttrList`.
-fn add_pango_attributes(
-    attr_list: &pango::AttrList,
-    context: &pango::Context,
-    props: &FontProperties,
-) {
-    let mut font_desc = context.font_description().unwrap();
+fn add_pango_attributes(attr_list: &pango::AttrList, props: &FontProperties) {
+    let mut font_desc = pango::FontDescription::new();
     font_desc.set_family(props.font_family.as_str());
     font_desc.set_style(pango::Style::from(props.font_style));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]