[librsvg: 5/18] Set a pango::Layout's font description as an attribute
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 5/18] Set a pango::Layout's font description as an attribute
- Date: Tue, 26 Oct 2021 02:33:04 +0000 (UTC)
commit 7fdc264973990f2785ba4f653300abd1875af144
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Oct 25 18:17:28 2021 -0500
Set a pango::Layout's font description as an attribute
Instead of using layout.set_font_descrption(). This is in preparation
of generating a long string out of all the character content in a
<text> element's children, and setting Pango attributes with ranges
within that string.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/621>
src/text.rs | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index 00258def..29253090 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -1192,22 +1192,8 @@ fn create_pango_layout(draw_ctx: &DrawingCtx, props: &FontProperties, text: &str
}
}
- let mut font_desc = pango_context.font_description().unwrap();
- font_desc.set_family(props.font_family.as_str());
- font_desc.set_style(pango::Style::from(props.font_style));
-
- // PANGO_VARIANT_SMALL_CAPS does nothing: https://gitlab.gnome.org/GNOME/pango/-/issues/566
- // see below for using the "smcp" OpenType feature for fonts that support it.
- // font_desc.set_variant(pango::Variant::from(props.font_variant));
-
- font_desc.set_weight(pango::Weight::from(props.font_weight));
- font_desc.set_stretch(pango::Stretch::from(props.font_stretch));
-
- font_desc.set_size(to_pango_units(props.font_size));
-
let layout = pango::Layout::new(&pango_context);
layout.set_auto_dir(false);
- layout.set_font_description(Some(&font_desc));
// FIXME: For now we ignore the `line-height` property, even though we parse it.
// We would need to do something like this:
@@ -1223,6 +1209,20 @@ fn create_pango_layout(draw_ctx: &DrawingCtx, props: &FontProperties, text: &str
let attr_list = pango::AttrList::new();
+ let mut font_desc = pango_context.font_description().unwrap();
+ font_desc.set_family(props.font_family.as_str());
+ font_desc.set_style(pango::Style::from(props.font_style));
+
+ // PANGO_VARIANT_SMALL_CAPS does nothing: https://gitlab.gnome.org/GNOME/pango/-/issues/566
+ // see below for using the "smcp" OpenType feature for fonts that support it.
+ // font_desc.set_variant(pango::Variant::from(props.font_variant));
+
+ font_desc.set_weight(pango::Weight::from(props.font_weight));
+ font_desc.set_stretch(pango::Stretch::from(props.font_stretch));
+
+ font_desc.set_size(to_pango_units(props.font_size));
+ attr_list.insert(pango::Attribute::new_font_desc(&font_desc));
+
attr_list.insert(pango::Attribute::new_letter_spacing(to_pango_units(
props.letter_spacing,
)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]