[librsvg: 16/18] Don't put the writing-mode in FontProperties
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 16/18] Don't put the writing-mode in FontProperties
- Date: Tue, 26 Oct 2021 02:33:05 +0000 (UTC)
commit 1e53e859ff15531bf2bd820d2f7504eb062047af
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Oct 25 20:49:17 2021 -0500
Don't put the writing-mode in FontProperties
writing-mode is valid only for <text>, not for individual spans.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/621>
src/layout.rs | 10 ++--------
src/text.rs | 20 +++++++++++++++-----
2 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/src/layout.rs b/src/layout.rs
index 19ebd63b..c259e910 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -18,7 +18,7 @@ use crate::properties::{
ClipRule, ComputedValues, Direction, FillRule, Filter, FontFamily, FontStretch, FontStyle,
FontVariant, FontWeight, MixBlendMode, Opacity, Overflow, PaintOrder, ShapeRendering,
StrokeDasharray, StrokeLinecap, StrokeLinejoin, StrokeMiterlimit, TextDecoration,
- TextRendering, UnicodeBidi, WritingMode, XmlLang,
+ TextRendering, UnicodeBidi, XmlLang,
};
use crate::rect::Rect;
use crate::surface_utils::shared_surface::SharedImageSurface;
@@ -121,7 +121,6 @@ pub struct Text {
/// Font-related properties extracted from `ComputedValues`.
pub struct FontProperties {
pub xml_lang: XmlLang,
- pub writing_mode: WritingMode,
pub unicode_bidi: UnicodeBidi,
pub direction: Direction,
pub font_family: FontFamily,
@@ -268,14 +267,9 @@ impl FontProperties {
///
/// The `writing-mode` property is passed separately, as it must come from the `<text>` element,
/// not the `<tspan>` whose computed values are being passed.
- pub fn new(
- values: &ComputedValues,
- writing_mode: WritingMode,
- params: &NormalizeParams,
- ) -> FontProperties {
+ pub fn new(values: &ComputedValues, params: &NormalizeParams) -> FontProperties {
FontProperties {
xml_lang: values.xml_lang(),
- writing_mode,
unicode_bidi: values.unicode_bidi(),
direction: values.direction(),
font_family: values.font_family(),
diff --git a/src/text.rs b/src/text.rs
index fcff557d..6ec88ce9 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -334,7 +334,7 @@ impl MeasuredSpan {
let view_params = draw_ctx.get_view_params();
let params = NormalizeParams::new(&values, &view_params);
- let properties = FontProperties::new(&values, text_writing_mode, ¶ms);
+ let properties = FontProperties::new(&values, ¶ms);
let bidi_control = BidiControl::from_unicode_bidi_and_direction(
properties.unicode_bidi,
@@ -342,7 +342,12 @@ impl MeasuredSpan {
);
let with_control_chars = wrap_with_direction_control_chars(&span.text, &bidi_control);
- let layout = create_pango_layout(draw_ctx, &properties, &with_control_chars);
+ let layout = create_pango_layout(
+ draw_ctx,
+ text_writing_mode,
+ &properties,
+ &with_control_chars,
+ );
let (w, h) = layout.size();
let w = f64::from(w) / f64::from(pango::SCALE);
@@ -1166,14 +1171,19 @@ fn wrap_with_direction_control_chars(s: &str, bidi_control: &BidiControl) -> Str
res
}
-fn create_pango_layout(draw_ctx: &DrawingCtx, props: &FontProperties, text: &str) -> pango::Layout {
+fn create_pango_layout(
+ draw_ctx: &DrawingCtx,
+ writing_mode: WritingMode,
+ props: &FontProperties,
+ text: &str,
+) -> pango::Layout {
let pango_context = draw_ctx.create_pango_context();
if let XmlLang(Some(ref lang)) = props.xml_lang {
pango_context.set_language(&pango::Language::from_string(lang.as_str()));
}
- pango_context.set_base_gravity(pango::Gravity::from(props.writing_mode));
+ pango_context.set_base_gravity(pango::Gravity::from(writing_mode));
match (props.unicode_bidi, props.direction) {
(UnicodeBidi::BidiOverride, _) | (UnicodeBidi::Embed, _) => {
@@ -1185,7 +1195,7 @@ fn create_pango_layout(draw_ctx: &DrawingCtx, props: &FontProperties, text: &str
}
(_, _) => {
- pango_context.set_base_dir(pango::Direction::from(props.writing_mode));
+ pango_context.set_base_dir(pango::Direction::from(writing_mode));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]