mirror of
https://github.com/penpot/penpot.git
synced 2026-08-15 01:08:45 +00:00
🐛 Fix text layer bounds clipping glyph (#11141)
This commit is contained in:
parent
9f17aa6216
commit
868340dfba
@ -1071,10 +1071,15 @@ impl Shape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn own_extrect_bounds(&self) -> Bounds {
|
fn own_extrect_bounds(&self) -> Bounds {
|
||||||
|
self.expand_own_bounds(self.own_base_bounds())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The shape's own geometry bounds, before stroke/shadow/blur margins.
|
||||||
|
fn own_base_bounds(&self) -> Bounds {
|
||||||
let shape = self;
|
let shape = self;
|
||||||
let max_stroke = Stroke::max_bounds_width(shape.strokes.iter(), shape.is_open());
|
let max_stroke = Stroke::max_bounds_width(shape.strokes.iter(), shape.is_open());
|
||||||
|
|
||||||
let mut bounds = match &shape.shape_type {
|
match &shape.shape_type {
|
||||||
Type::Path(_) | Type::Bool(_) => {
|
Type::Path(_) | Type::Bool(_) => {
|
||||||
if let Some(path) = shape.get_skia_path() {
|
if let Some(path) = shape.get_skia_path() {
|
||||||
let cap_margin = shape.cap_bounds_margin();
|
let cap_margin = shape.cap_bounds_margin();
|
||||||
@ -1091,9 +1096,12 @@ impl Shape {
|
|||||||
text_content.calculate_bounds(shape, false)
|
text_content.calculate_bounds(shape, false)
|
||||||
}
|
}
|
||||||
_ => shape.calculate_bounds(false),
|
_ => shape.calculate_bounds(false),
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bounds = self.apply_stroke_bounds(bounds, max_stroke);
|
fn expand_own_bounds(&self, bounds: Bounds) -> Bounds {
|
||||||
|
let max_stroke = Stroke::max_bounds_width(self.strokes.iter(), self.is_open());
|
||||||
|
let mut bounds = self.apply_stroke_bounds(bounds, max_stroke);
|
||||||
bounds = self.apply_shadow_bounds(bounds);
|
bounds = self.apply_shadow_bounds(bounds);
|
||||||
bounds = self.apply_blur_bounds(bounds);
|
bounds = self.apply_blur_bounds(bounds);
|
||||||
bounds
|
bounds
|
||||||
@ -1104,7 +1112,15 @@ impl Shape {
|
|||||||
/// first). Includes shadow/blur margins, so it is also a valid input bound
|
/// first). Includes shadow/blur margins, so it is also a valid input bound
|
||||||
/// for a layer whose paint carries an image filter.
|
/// for a layer whose paint carries an image filter.
|
||||||
pub fn layer_bounds(&self) -> math::Rect {
|
pub fn layer_bounds(&self) -> math::Rect {
|
||||||
self.own_extrect_bounds().to_rect()
|
let mut bounds = self.own_base_bounds();
|
||||||
|
|
||||||
|
if matches!(self.shape_type, Type::Text(_)) {
|
||||||
|
let mut rect = bounds.to_rect();
|
||||||
|
rect.join(self.selrect);
|
||||||
|
bounds = Bounds::from_rect(&rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.expand_own_bounds(bounds).to_rect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_extrect_uncached(&self, shapes_pool: ShapesPoolRef, scale: f32) -> math::Rect {
|
fn calculate_extrect_uncached(&self, shapes_pool: ShapesPoolRef, scale: f32) -> math::Rect {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user