From d2727b1f5cd3167fd1781ea3e7bbde78304df1be Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 25 Nov 2022 15:18:36 -0800 Subject: [PATCH] more wedges --- src/font/BoxFont.zig | 42 ++++++++++++++++++++++++++++++++++++++++++ src/font/Group.zig | 8 ++++++++ 2 files changed, 50 insertions(+) diff --git a/src/font/BoxFont.zig b/src/font/BoxFont.zig index d055c196b..91001ffb2 100644 --- a/src/font/BoxFont.zig +++ b/src/font/BoxFont.zig @@ -316,6 +316,22 @@ fn draw(self: BoxFont, alloc: Allocator, img: *pixman.Image, cp: u32) !void { 0x1FB68...0x1FB6B, => try self.draw_wedge_triangle_inverted(img, cp), + 0x1FB46, + 0x1FB51, + 0x1FB5C, + 0x1FB67, + => try self.draw_wedge_triangle_and_box(img, cp), + + 0x1FB9A => { + try self.draw_wedge_triangle(img, 0x1fb6d); + try self.draw_wedge_triangle(img, 0x1fb6f); + }, + + 0x1FB9B => { + try self.draw_wedge_triangle(img, 0x1fb6c); + try self.draw_wedge_triangle(img, 0x1fb6e); + }, + else => return error.InvalidCodepoint, } } @@ -2078,6 +2094,32 @@ fn draw_wedge_triangle_inverted(self: BoxFont, img: *pixman.Image, cp: u32) !voi ); } +fn draw_wedge_triangle_and_box(self: BoxFont, img: *pixman.Image, cp: u32) !void { + try self.draw_wedge_triangle(img, cp); + + const y_thirds = self.yThirds(); + const box: pixman.Box32 = switch (cp) { + 0x1fb46, 0x1fb51 => .{ + .x1 = 0, + .y1 = @intCast(i32, y_thirds[1]), + .x2 = @intCast(i32, self.width), + .y2 = @intCast(i32, self.height), + }, + + 0x1fb5c, 0x1fb67 => .{ + .x1 = 0, + .y1 = 0, + .x2 = @intCast(i32, self.width), + .y2 = @intCast(i32, y_thirds[0]), + }, + + else => unreachable, + }; + + const boxes = &[_]pixman.Box32{box}; + img.fillBoxes(.src, white, boxes) catch {}; +} + fn draw_light_arc( self: BoxFont, alloc: Allocator, diff --git a/src/font/Group.zig b/src/font/Group.zig index 60d9ab845..13f2190b3 100644 --- a/src/font/Group.zig +++ b/src/font/Group.zig @@ -209,6 +209,14 @@ pub fn indexForCodepoint( 0x1FB68...0x1FB6B, => true, + 0x1FB46, + 0x1FB51, + 0x1FB5C, + 0x1FB67, + 0x1FB9A, + 0x1FB9B, + => true, + else => false, }) { return FontIndex.initSpecial(.box);