Add letter spacing and text transforms to GPUI (#111)
* Add text spacing and transform style plumbing * Apply byte-stable transforms and spacing-aware truncation * Add platform letter spacing support * Fix scheduler clippy warning * Refresh dependency lockfile * Fix CI for text spacing changes * Add text transform preview example
This commit is contained in:
@@ -551,12 +551,10 @@ impl DirectWriteState {
|
||||
format.SetFontFallback(fallbacks)?;
|
||||
}
|
||||
|
||||
let layout = components.factory.CreateTextLayout(
|
||||
text_wide,
|
||||
&format,
|
||||
f32::INFINITY,
|
||||
f32::INFINITY,
|
||||
)?;
|
||||
let layout: IDWriteTextLayout1 = components
|
||||
.factory
|
||||
.CreateTextLayout(text_wide, &format, f32::INFINITY, f32::INFINITY)?
|
||||
.cast()?;
|
||||
let current_text = &text[utf8_offset..(utf8_offset + first_run.len)];
|
||||
utf8_offset += first_run.len;
|
||||
let current_text_utf16_length = current_text.encode_utf16().count() as u32;
|
||||
@@ -565,6 +563,9 @@ impl DirectWriteState {
|
||||
length: current_text_utf16_length,
|
||||
};
|
||||
layout.SetTypography(&font_info.features, text_range)?;
|
||||
if let Some(spacing) = first_run.letter_spacing {
|
||||
layout.SetCharacterSpacing(0.0, spacing.as_f32(), 0.0, text_range)?;
|
||||
}
|
||||
utf16_offset += current_text_utf16_length;
|
||||
|
||||
layout
|
||||
@@ -603,6 +604,9 @@ impl DirectWriteState {
|
||||
text_layout.SetFontStyle(font_info.font_face.GetStyle(), text_range)?;
|
||||
text_layout.SetFontWeight(font_info.font_face.GetWeight(), text_range)?;
|
||||
text_layout.SetTypography(&font_info.features, text_range)?;
|
||||
if let Some(spacing) = run.letter_spacing {
|
||||
text_layout.SetCharacterSpacing(0.0, spacing.as_f32(), 0.0, text_range)?;
|
||||
}
|
||||
|
||||
break_ligatures = !break_ligatures;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user