You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Text{/// The contents of the textcontent:String,/// The bounds of the textbounds:Rectangle,/// The color of the textcolor:Color,/// The size of the textsize: f32,/// The font of the textfont:Font,/// The horizontal alignment of the texthorizontal_alignment:HorizontalAlignment,/// The vertical alignment of the textvertical_alignment:VerticalAlignment,},
Based on the doc comments, I would assume that bounds.x & bounds.y refer to the bounding box top-left, and width+x + height+y refer to the bottom right.
This is only true if alignment is set to Left & Top:
let x = match horizontal_alignment {
iced_native::HorizontalAlignment::Left => bounds.x,
iced_native::HorizontalAlignment::Center => bounds.center_x(),
iced_native::HorizontalAlignment::Right => bounds.x + bounds.width,};let y = match vertical_alignment {
iced_native::VerticalAlignment::Top => bounds.y,
iced_native::VerticalAlignment::Center => bounds.center_y(),
iced_native::VerticalAlignment::Bottom => bounds.y + bounds.height,};
Hence, the bounds X/Y change, mapping to the input X/Y position that the wgpu backend expects for text of that alignment.
This has proven very challenging to work around for the raqote backend, which always needs the top-left X/Y position.
Could we either:
Change the semantics so bounds is always the bounding box, or
Provide the information from TextBackend::measure() in the primitive, so its easier to recompute the correct position (rather than either caching text runs in the backend or re-adding all the glyph sizes)
The text was updated successfully, but these errors were encountered:
For a raqote backend, I believe it may be interesting to not use Primitive at all and instead implement the widget Renderer traits directly. We can find and discuss any similarities later.
Primitive::Text is defined as:
Based on the doc comments, I would assume that
bounds.x
&bounds.y
refer to the bounding box top-left, andwidth+x
+height+y
refer to the bottom right.This is only true if alignment is set to
Left
&Top
:Hence, the
bounds
X/Y change, mapping to the input X/Y position that the wgpu backend expects for text of that alignment.This has proven very challenging to work around for the
raqote
backend, which always needs the top-left X/Y position.Could we either:
bounds
is always the bounding box, orTextBackend::measure()
in the primitive, so its easier to recompute the correct position (rather than either caching text runs in the backend or re-adding all the glyph sizes)The text was updated successfully, but these errors were encountered: