From 57f3bd84a41038653471efcfaf5889289217c881 Mon Sep 17 00:00:00 2001 From: Matt Campbell Date: Sat, 20 Dec 2025 13:00:53 -0600 Subject: [PATCH] feat: Add simple text attributes on Windows --- platforms/windows/src/text.rs | 12 ++++++++++++ platforms/windows/src/util.rs | 13 ++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/platforms/windows/src/text.rs b/platforms/windows/src/text.rs index 39404936..96503b7f 100644 --- a/platforms/windows/src/text.rs +++ b/platforms/windows/src/text.rs @@ -446,6 +446,18 @@ impl ITextRangeProvider_Impl for PlatformRange_Impl { } Ok(value.0.into()) }), + UIA_CultureAttributeId => { + self.read(|range| Ok(Variant::from(range.language().map(LocaleName)).into())) + } + UIA_FontNameAttributeId => { + self.read(|range| Ok(Variant::from(range.font_family()).into())) + } + UIA_FontSizeAttributeId => { + self.read(|range| Ok(Variant::from(range.font_size()).into())) + } + UIA_FontWeightAttributeId => self.read(|range| { + Ok(Variant::from(range.font_weight().map(|value| value as i32)).into()) + }), // TODO: implement more attributes _ => { let value = unsafe { UiaGetReservedNotSupportedValue() }.unwrap(); diff --git a/platforms/windows/src/util.rs b/platforms/windows/src/util.rs index 1efeda9e..94cac694 100644 --- a/platforms/windows/src/util.rs +++ b/platforms/windows/src/util.rs @@ -4,7 +4,7 @@ // the LICENSE-MIT file), at your option. use accesskit::Point; -use accesskit_consumer::TreeState; +use accesskit_consumer::{TextRangePropertyValue, TreeState}; use std::{ fmt::{self, Write}, mem::ManuallyDrop, @@ -158,6 +158,17 @@ impl> From> for Variant { } } +impl + std::fmt::Debug + PartialEq> From> for Variant { + fn from(value: TextRangePropertyValue) -> Self { + match value { + TextRangePropertyValue::Single(value) => value.into(), + TextRangePropertyValue::Mixed => unsafe { UiaGetReservedMixedAttributeValue() } + .unwrap() + .into(), + } + } +} + impl From> for Variant { fn from(value: Vec) -> Self { if value.is_empty() {