mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
font/underline: some additional type annotations
This commit is contained in:
@ -714,7 +714,6 @@ fn addDeps(
|
||||
step.addModule("freetype", freetype_dep.module("freetype"));
|
||||
step.addModule("harfbuzz", harfbuzz_dep.module("harfbuzz"));
|
||||
step.addModule("xev", libxev_dep.module("xev"));
|
||||
step.addModule("zig-js", js_dep.module("zig-js"));
|
||||
step.addModule("pixman", pixman_dep.module("pixman"));
|
||||
step.addModule("utf8proc", utf8proc_dep.module("utf8proc"));
|
||||
|
||||
|
@ -174,7 +174,7 @@ const Draw = struct {
|
||||
// Some fonts put the underline too close to the bottom of the
|
||||
// cell height and this doesn't allow us to make a high enough
|
||||
// wave. This constant is arbitrary, change it for aesthetics.
|
||||
const pos = pos: {
|
||||
const pos: u32 = pos: {
|
||||
const MIN_HEIGHT = 5;
|
||||
const clamped_pos = @min(y_max, self.pos);
|
||||
const height = y_max - clamped_pos;
|
||||
@ -184,8 +184,8 @@ const Draw = struct {
|
||||
// The full height of the wave can be from the bottom to the
|
||||
// underline position. We also calculate our starting y which is
|
||||
// slightly below our descender since our wave will move about that.
|
||||
const wave_height = @as(f64, @floatFromInt(y_max - pos));
|
||||
const half_height = @max(1, wave_height / 4);
|
||||
const wave_height: f64 = @floatFromInt(y_max - pos);
|
||||
const half_height: f64 = @max(1, wave_height / 4);
|
||||
const y_pos = @as(i32, @intCast(pos)) + @as(i32, @intFromFloat(2 * half_height));
|
||||
|
||||
// follow Xiaolin Wu's antialias algorithm to draw the curve
|
||||
@ -194,7 +194,7 @@ const Draw = struct {
|
||||
const y0 = half_height * @cos(@as(f64, @floatFromInt(x)) * x_factor);
|
||||
const y1 = y_pos + @as(i32, @intFromFloat(@floor(y0)));
|
||||
const y3 = y1 - 1 + @as(i32, @intCast(self.thickness));
|
||||
const alpha = @as(u8, @intFromFloat(255 * @abs(y0 - @floor(y0))));
|
||||
const alpha: u8 = @intFromFloat(255 * @abs(y0 - @floor(y0)));
|
||||
|
||||
// upper and lower bounds
|
||||
canvas.pixel(x, @min(@as(u32, @intCast(y1)), y_max), @enumFromInt(255 - alpha));
|
||||
|
Reference in New Issue
Block a user