mirror of
https://github.com/penpot/penpot.git
synced 2026-09-12 15:09:38 +00:00
🐛 Use SrcIn only when there is only one inner stroke, otherwise use erode filter
This commit is contained in:
parent
96a91dc710
commit
0b7444e8ff
@ -520,6 +520,7 @@ impl RenderState {
|
|||||||
shadows::render_text_drop_shadows(self, &shape, &mut paragraphs, antialias);
|
shadows::render_text_drop_shadows(self, &shape, &mut paragraphs, antialias);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let count_inner_strokes = shape.count_visible_inner_strokes();
|
||||||
text::render(self, &shape, &mut paragraphs, None, None);
|
text::render(self, &shape, &mut paragraphs, None, None);
|
||||||
|
|
||||||
for stroke in shape.visible_strokes().rev() {
|
for stroke in shape.visible_strokes().rev() {
|
||||||
@ -528,6 +529,7 @@ impl RenderState {
|
|||||||
&shape.selrect(),
|
&shape.selrect(),
|
||||||
shape.image_filter(1.).as_ref(),
|
shape.image_filter(1.).as_ref(),
|
||||||
shape.mask_filter(1.).as_ref(),
|
shape.mask_filter(1.).as_ref(),
|
||||||
|
count_inner_strokes,
|
||||||
);
|
);
|
||||||
shadows::render_text_drop_shadows(
|
shadows::render_text_drop_shadows(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@ -1109,6 +1109,13 @@ impl Shape {
|
|||||||
pub fn has_visible_inner_strokes(&self) -> bool {
|
pub fn has_visible_inner_strokes(&self) -> bool {
|
||||||
self.visible_strokes().any(|s| s.kind == StrokeKind::Inner)
|
self.visible_strokes().any(|s| s.kind == StrokeKind::Inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn count_visible_inner_strokes(&self) -> usize {
|
||||||
|
self.visible_strokes()
|
||||||
|
.filter(|s| s.kind == StrokeKind::Inner)
|
||||||
|
.count()
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns the list of children taking into account the structure modifiers
|
Returns the list of children taking into account the structure modifiers
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -124,6 +124,7 @@ impl TextContent {
|
|||||||
bounds: &Rect,
|
bounds: &Rect,
|
||||||
blur: Option<&ImageFilter>,
|
blur: Option<&ImageFilter>,
|
||||||
blur_mask: Option<&MaskFilter>,
|
blur_mask: Option<&MaskFilter>,
|
||||||
|
count_inner_strokes: usize,
|
||||||
) -> Vec<Vec<ParagraphBuilder>> {
|
) -> Vec<Vec<ParagraphBuilder>> {
|
||||||
let fallback_fonts = get_fallback_fonts();
|
let fallback_fonts = get_fallback_fonts();
|
||||||
let fonts = get_font_collection();
|
let fonts = get_font_collection();
|
||||||
@ -138,8 +139,14 @@ impl TextContent {
|
|||||||
if let Some(blur_mask) = blur_mask {
|
if let Some(blur_mask) = blur_mask {
|
||||||
text_paint.set_mask_filter(blur_mask.clone());
|
text_paint.set_mask_filter(blur_mask.clone());
|
||||||
}
|
}
|
||||||
let stroke_paints =
|
let stroke_paints = get_text_stroke_paints(
|
||||||
get_text_stroke_paints(stroke, bounds, &text_paint, blur, blur_mask);
|
stroke,
|
||||||
|
bounds,
|
||||||
|
&text_paint,
|
||||||
|
blur,
|
||||||
|
blur_mask,
|
||||||
|
count_inner_strokes,
|
||||||
|
);
|
||||||
let text: String = leaf.apply_text_transform();
|
let text: String = leaf.apply_text_transform();
|
||||||
|
|
||||||
for (paint_idx, stroke_paint) in stroke_paints.iter().enumerate() {
|
for (paint_idx, stroke_paint) in stroke_paints.iter().enumerate() {
|
||||||
@ -198,8 +205,15 @@ impl TextContent {
|
|||||||
bounds: &Rect,
|
bounds: &Rect,
|
||||||
blur: Option<&ImageFilter>,
|
blur: Option<&ImageFilter>,
|
||||||
blur_mask: Option<&MaskFilter>,
|
blur_mask: Option<&MaskFilter>,
|
||||||
|
count_inner_strokes: usize,
|
||||||
) -> Vec<Vec<ParagraphBuilder>> {
|
) -> Vec<Vec<ParagraphBuilder>> {
|
||||||
self.collect_paragraphs(self.to_stroke_paragraphs(stroke, bounds, blur, blur_mask))
|
self.collect_paragraphs(self.to_stroke_paragraphs(
|
||||||
|
stroke,
|
||||||
|
bounds,
|
||||||
|
blur,
|
||||||
|
blur_mask,
|
||||||
|
count_inner_strokes,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn grow_type(&self) -> GrowType {
|
pub fn grow_type(&self) -> GrowType {
|
||||||
@ -751,6 +765,7 @@ fn get_text_stroke_paints(
|
|||||||
text_paint: &Paint,
|
text_paint: &Paint,
|
||||||
blur: Option<&ImageFilter>,
|
blur: Option<&ImageFilter>,
|
||||||
blur_mask: Option<&MaskFilter>,
|
blur_mask: Option<&MaskFilter>,
|
||||||
|
count_inner_strokes: usize,
|
||||||
) -> Vec<Paint> {
|
) -> Vec<Paint> {
|
||||||
let mut paints = Vec::new();
|
let mut paints = Vec::new();
|
||||||
|
|
||||||
@ -763,7 +778,7 @@ fn get_text_stroke_paints(
|
|||||||
is_opaque = shader.unwrap().is_opaque();
|
is_opaque = shader.unwrap().is_opaque();
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_opaque {
|
if is_opaque && count_inner_strokes == 1 {
|
||||||
let mut paint = text_paint.clone();
|
let mut paint = text_paint.clone();
|
||||||
paint.set_style(skia::PaintStyle::Fill);
|
paint.set_style(skia::PaintStyle::Fill);
|
||||||
paint.set_anti_alias(true);
|
paint.set_anti_alias(true);
|
||||||
@ -771,7 +786,6 @@ fn get_text_stroke_paints(
|
|||||||
paint.set_image_filter(blur.clone());
|
paint.set_image_filter(blur.clone());
|
||||||
}
|
}
|
||||||
paints.push(paint);
|
paints.push(paint);
|
||||||
|
|
||||||
let mut paint = skia::Paint::default();
|
let mut paint = skia::Paint::default();
|
||||||
paint.set_style(skia::PaintStyle::Stroke);
|
paint.set_style(skia::PaintStyle::Stroke);
|
||||||
paint.set_blend_mode(skia::BlendMode::SrcIn);
|
paint.set_blend_mode(skia::BlendMode::SrcIn);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user