support undercurl

macos-click-through
Keith Simmons 5 years ago
parent 703087fd88
commit 33c68d38b9

@ -29,7 +29,7 @@ const SYSTEM_EMOJI_FONT: &str = "Noto Color Emoji";
#[folder = "assets/fonts/"]
struct Asset;
const DEFAULT_FONT_SIZE: f32 = 14.0;
const DEFAULT_FONT_SIZE: f32 = 24.0;
#[derive(new, Clone, Hash, PartialEq, Eq, Debug)]
struct ShapeKey {

@ -1,7 +1,7 @@
use std::sync::Arc;
use skulpin::CoordinateSystemHelper;
use skulpin::skia_safe::{Canvas, Paint, Surface, Budgeted, Rect, colors};
use skulpin::skia_safe::{Canvas, Paint, Surface, Budgeted, Rect, colors, dash_path_effect};
use skulpin::skia_safe::gpu::SurfaceOrigin;
use log::trace;
@ -77,7 +77,16 @@ impl Renderer {
if style.underline || style.undercurl {
let line_position = self.shaper.underline_position();
let stroke_width = self.shaper.base_size / 10.0;
self.paint.set_color(style.special(&default_style.colors).to_color());
self.paint.set_stroke_width(stroke_width);
if style.undercurl {
self.paint.set_path_effect(dash_path_effect::new(&[stroke_width * 2.0, stroke_width * 2.0], 0.0));
} else {
self.paint.set_path_effect(None);
}
canvas.draw_line((x, y - line_position + self.font_height), (x + width, y - line_position + self.font_height), &self.paint);
}

Loading…
Cancel
Save