From 10b8ca3c694aa5e0b5cf7eaaae79a4990e3774c3 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Sun, 11 Aug 2024 18:02:12 -0400 Subject: [PATCH] spelling: normalize grey -> gray --- example/app.ts | 6 ++--- example/index.html | 2 +- src/font/Atlas.zig | 20 +++++++-------- src/font/CodepointResolver.zig | 4 +-- src/font/SharedGrid.zig | 12 ++++----- src/font/face/coretext.zig | 8 +++--- src/font/face/freetype.zig | 6 ++--- src/font/face/freetype_convert.zig | 8 +++--- src/font/face/web_canvas.zig | 2 +- src/font/sprite/Box.zig | 6 ++--- src/font/sprite/Powerline.zig | 6 ++--- src/font/sprite/canvas.zig | 4 +-- src/font/sprite/underline.zig | 24 ++++++++--------- src/renderer/Metal.zig | 34 ++++++++++++------------- src/renderer/OpenGL.zig | 30 +++++++++++----------- src/renderer/metal/image.zig | 22 ++++++++-------- src/renderer/opengl/image.zig | 24 ++++++++--------- src/renderer/shaders/cell.metal | 4 +-- src/terminal/color.zig | 2 +- src/terminal/kitty/graphics_command.zig | 4 +-- src/terminal/kitty/graphics_image.zig | 4 +-- typos.toml | 4 +++ 22 files changed, 120 insertions(+), 116 deletions(-) diff --git a/example/app.ts b/example/app.ts index b42870a50..bb85d5aaa 100644 --- a/example/app.ts +++ b/example/app.ts @@ -51,7 +51,7 @@ fetch(url.href) group_cache_free, group_cache_index_for_codepoint, group_cache_render_glyph, - group_cache_atlas_greyscale, + group_cache_atlas_grayscale, group_cache_atlas_color, atlas_new, atlas_free, @@ -83,7 +83,7 @@ fetch(url.href) free(config_str.ptr); // Create our atlas - // const atlas = atlas_new(512, 0 /* greyscale */); + // const atlas = atlas_new(512, 0 /* grayscale */); // Create some memory for our string const font_name = makeStr("monospace"); @@ -174,7 +174,7 @@ fetch(url.href) // Debug our atlas canvas { - const atlas = group_cache_atlas_greyscale(group_cache); + const atlas = group_cache_atlas_grayscale(group_cache); const id = atlas_debug_canvas(atlas); document.getElementById("atlas-canvas").append(zjs.deleteValue(id)); } diff --git a/example/index.html b/example/index.html index a5fddff0d..2e66f92d1 100644 --- a/example/index.html +++ b/example/index.html @@ -7,7 +7,7 @@

Open your console, we are just debugging here.

-

The current greyscale font atlas is rendered below.

+

The current grayscale font atlas is rendered below.

The current color font atlas is rendered below.

diff --git a/src/font/Atlas.zig b/src/font/Atlas.zig index fcdf6ec53..0c4b816f6 100644 --- a/src/font/Atlas.zig +++ b/src/font/Atlas.zig @@ -36,7 +36,7 @@ nodes: std.ArrayListUnmanaged(Node) = .{}, /// The format of the texture data being written into the Atlas. This must be /// uniform for all textures in the Atlas. If you have some textures with /// different formats, you must use multiple atlases or convert the textures. -format: Format = .greyscale, +format: Format = .grayscale, /// This will be incremented every time the atlas is modified. This is useful /// for knowing if the texture data has changed since the last time it was @@ -50,13 +50,13 @@ modified: std.atomic.Value(usize) = .{ .raw = 0 }, resized: std.atomic.Value(usize) = .{ .raw = 0 }, pub const Format = enum(u8) { - greyscale = 0, + grayscale = 0, rgb = 1, rgba = 2, pub fn depth(self: Format) u8 { return switch (self) { - .greyscale => 1, + .grayscale => 1, .rgb => 3, .rgba => 4, }; @@ -396,7 +396,7 @@ pub const Wasm = struct { // RGBA is the native ImageData format .rgba => self.data, - .greyscale => buf: { + .grayscale => buf: { // Convert from A8 to RGBA so every 4th byte is set to a value. var buf: []u8 = try alloc.alloc(u8, self.data.len * 4); errdefer alloc.free(buf); @@ -451,7 +451,7 @@ pub const Wasm = struct { } test "happy path" { - const atlas = atlas_new(512, @intFromEnum(Format.greyscale)).?; + const atlas = atlas_new(512, @intFromEnum(Format.grayscale)).?; defer atlas_free(atlas); const reg = atlas_reserve(atlas, 2, 2).?; @@ -469,7 +469,7 @@ pub const Wasm = struct { test "exact fit" { const alloc = testing.allocator; - var atlas = try init(alloc, 34, .greyscale); // +2 for 1px border + var atlas = try init(alloc, 34, .grayscale); // +2 for 1px border defer atlas.deinit(alloc); const modified = atlas.modified.load(.monotonic); @@ -480,7 +480,7 @@ test "exact fit" { test "doesnt fit" { const alloc = testing.allocator; - var atlas = try init(alloc, 32, .greyscale); + var atlas = try init(alloc, 32, .grayscale); defer atlas.deinit(alloc); // doesn't fit due to border @@ -489,7 +489,7 @@ test "doesnt fit" { test "fit multiple" { const alloc = testing.allocator; - var atlas = try init(alloc, 32, .greyscale); + var atlas = try init(alloc, 32, .grayscale); defer atlas.deinit(alloc); _ = try atlas.reserve(alloc, 15, 30); @@ -499,7 +499,7 @@ test "fit multiple" { test "writing data" { const alloc = testing.allocator; - var atlas = try init(alloc, 32, .greyscale); + var atlas = try init(alloc, 32, .grayscale); defer atlas.deinit(alloc); const reg = try atlas.reserve(alloc, 2, 2); @@ -517,7 +517,7 @@ test "writing data" { test "grow" { const alloc = testing.allocator; - var atlas = try init(alloc, 4, .greyscale); // +2 for 1px border + var atlas = try init(alloc, 4, .grayscale); // +2 for 1px border defer atlas.deinit(alloc); const reg = try atlas.reserve(alloc, 2, 2); diff --git a/src/font/CodepointResolver.zig b/src/font/CodepointResolver.zig index 8196d270e..5caeb728f 100644 --- a/src/font/CodepointResolver.zig +++ b/src/font/CodepointResolver.zig @@ -458,8 +458,8 @@ test "getIndex disabled font style" { const alloc = testing.allocator; const testFont = @import("test.zig").fontRegular; - var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); - defer atlas_greyscale.deinit(alloc); + var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale); + defer atlas_grayscale.deinit(alloc); var lib = try Library.init(); defer lib.deinit(); diff --git a/src/font/SharedGrid.zig b/src/font/SharedGrid.zig index 8ebbc1710..c11c8a4ae 100644 --- a/src/font/SharedGrid.zig +++ b/src/font/SharedGrid.zig @@ -44,7 +44,7 @@ glyphs: std.AutoHashMapUnmanaged(GlyphKey, Render) = .{}, /// The texture atlas to store renders in. The Glyph data in the glyphs /// cache is dependent on the atlas matching. -atlas_greyscale: Atlas, +atlas_grayscale: Atlas, atlas_color: Atlas, /// The underlying resolver for font data, fallbacks, etc. The shared @@ -77,14 +77,14 @@ pub fn init( // We need to support loading options since we use the size data assert(resolver.collection.load_options != null); - var atlas_greyscale = try Atlas.init(alloc, 512, .greyscale); - errdefer atlas_greyscale.deinit(alloc); + var atlas_grayscale = try Atlas.init(alloc, 512, .grayscale); + errdefer atlas_grayscale.deinit(alloc); var atlas_color = try Atlas.init(alloc, 512, .rgba); errdefer atlas_color.deinit(alloc); var result: SharedGrid = .{ .resolver = resolver, - .atlas_greyscale = atlas_greyscale, + .atlas_grayscale = atlas_grayscale, .atlas_color = atlas_color, .lock = .{}, .metrics = undefined, // Loaded below @@ -105,7 +105,7 @@ pub fn init( pub fn deinit(self: *SharedGrid, alloc: Allocator) void { self.codepoints.deinit(alloc); self.glyphs.deinit(alloc); - self.atlas_greyscale.deinit(alloc); + self.atlas_grayscale.deinit(alloc); self.atlas_color.deinit(alloc); self.resolver.deinit(alloc); } @@ -272,7 +272,7 @@ pub fn renderGlyph( // Get the presentation to determine what atlas to use const p = try self.resolver.getPresentation(index, glyph_index); const atlas: *font.Atlas = switch (p) { - .text => &self.atlas_greyscale, + .text => &self.atlas_grayscale, .emoji => &self.atlas_color, }; diff --git a/src/font/face/coretext.zig b/src/font/face/coretext.zig index 6d07f1fa4..7b0e1e9bf 100644 --- a/src/font/face/coretext.zig +++ b/src/font/face/coretext.zig @@ -671,7 +671,7 @@ test { const testing = std.testing; const alloc = testing.allocator; - var atlas = try font.Atlas.init(alloc, 512, .greyscale); + var atlas = try font.Atlas.init(alloc, 512, .grayscale); defer atlas.deinit(alloc); const name = try macos.foundation.String.createWithBytes("Monaco", .utf8, false); @@ -735,7 +735,7 @@ test "in-memory" { const alloc = testing.allocator; const testFont = @import("../test.zig").fontRegular; - var atlas = try font.Atlas.init(alloc, 512, .greyscale); + var atlas = try font.Atlas.init(alloc, 512, .grayscale); defer atlas.deinit(alloc); var lib = try font.Library.init(); @@ -757,7 +757,7 @@ test "variable" { const alloc = testing.allocator; const testFont = @import("../test.zig").fontVariable; - var atlas = try font.Atlas.init(alloc, 512, .greyscale); + var atlas = try font.Atlas.init(alloc, 512, .grayscale); defer atlas.deinit(alloc); var lib = try font.Library.init(); @@ -779,7 +779,7 @@ test "variable set variation" { const alloc = testing.allocator; const testFont = @import("../test.zig").fontVariable; - var atlas = try font.Atlas.init(alloc, 512, .greyscale); + var atlas = try font.Atlas.init(alloc, 512, .grayscale); defer atlas.deinit(alloc); var lib = try font.Library.init(); diff --git a/src/font/face/freetype.zig b/src/font/face/freetype.zig index 346d8aa8d..a182f1657 100644 --- a/src/font/face/freetype.zig +++ b/src/font/face/freetype.zig @@ -281,7 +281,7 @@ pub const Face = struct { // conversion. const format: ?font.Atlas.Format = switch (bitmap_ft.pixel_mode) { freetype.c.FT_PIXEL_MODE_MONO => null, - freetype.c.FT_PIXEL_MODE_GRAY => .greyscale, + freetype.c.FT_PIXEL_MODE_GRAY => .grayscale, freetype.c.FT_PIXEL_MODE_BGRA => .rgba, else => { log.warn("glyph={} pixel mode={}", .{ glyph_index, bitmap_ft.pixel_mode }); @@ -657,7 +657,7 @@ test { var lib = try Library.init(); defer lib.deinit(); - var atlas = try font.Atlas.init(alloc, 512, .greyscale); + var atlas = try font.Atlas.init(alloc, 512, .grayscale); defer atlas.deinit(alloc); var ft_font = try Face.init( @@ -734,7 +734,7 @@ test "metrics" { var lib = try Library.init(); defer lib.deinit(); - var atlas = try font.Atlas.init(alloc, 512, .greyscale); + var atlas = try font.Atlas.init(alloc, 512, .grayscale); defer atlas.deinit(alloc); var ft_font = try Face.init( diff --git a/src/font/face/freetype_convert.zig b/src/font/face/freetype_convert.zig index 7686ad425..298aad8a0 100644 --- a/src/font/face/freetype_convert.zig +++ b/src/font/face/freetype_convert.zig @@ -34,12 +34,12 @@ fn genMap() Map { } // Map our converters - result[freetype.c.FT_PIXEL_MODE_MONO].set(.greyscale, monoToGreyscale); + result[freetype.c.FT_PIXEL_MODE_MONO].set(.grayscale, monoToGrayscale); return result; } -pub fn monoToGreyscale(alloc: Allocator, bm: Bitmap) Allocator.Error!Bitmap { +pub fn monoToGrayscale(alloc: Allocator, bm: Bitmap) Allocator.Error!Bitmap { var buf = try alloc.alloc(u8, bm.width * bm.rows); errdefer alloc.free(buf); @@ -77,7 +77,7 @@ test { _ = map; } -test "mono to greyscale" { +test "mono to grayscale" { const testing = std.testing; const alloc = testing.allocator; @@ -93,7 +93,7 @@ test "mono to greyscale" { .palette = null, }; - const result = try monoToGreyscale(alloc, source); + const result = try monoToGrayscale(alloc, source); defer alloc.free(result.buffer[0..(result.width * result.rows)]); try testing.expect(result.pixel_mode == freetype.c.FT_PIXEL_MODE_GRAY); try testing.expectEqual(@as(u8, 255), result.buffer[0]); diff --git a/src/font/face/web_canvas.zig b/src/font/face/web_canvas.zig index 036dfa921..60846f350 100644 --- a/src/font/face/web_canvas.zig +++ b/src/font/face/web_canvas.zig @@ -203,7 +203,7 @@ pub const Face = struct { .rgba => render.bitmap, // Convert down to A8 - .greyscale => a8: { + .grayscale => a8: { assert(@mod(render.bitmap.len, 4) == 0); var bitmap_a8 = try alloc.alloc(u8, render.bitmap.len / 4); errdefer alloc.free(bitmap_a8); diff --git a/src/font/sprite/Box.zig b/src/font/sprite/Box.zig index c5064b44a..07a830a96 100644 --- a/src/font/sprite/Box.zig +++ b/src/font/sprite/Box.zig @@ -2726,13 +2726,13 @@ test "all" { var cp: u32 = 0x2500; const end = 0x2570; while (cp <= end) : (cp += 1) { - var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); - defer atlas_greyscale.deinit(alloc); + var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale); + defer atlas_grayscale.deinit(alloc); const face: Box = .{ .width = 18, .height = 36, .thickness = 2 }; const glyph = try face.renderGlyph( alloc, - &atlas_greyscale, + &atlas_grayscale, cp, ); try testing.expectEqual(@as(u32, face.width), glyph.width); diff --git a/src/font/sprite/Powerline.zig b/src/font/sprite/Powerline.zig index a6551b5f3..f32fdb01b 100644 --- a/src/font/sprite/Powerline.zig +++ b/src/font/sprite/Powerline.zig @@ -527,13 +527,13 @@ test "all" { 0xE0D4, }; for (cps) |cp| { - var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); - defer atlas_greyscale.deinit(alloc); + var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale); + defer atlas_grayscale.deinit(alloc); const face: Powerline = .{ .width = 18, .height = 36, .thickness = 2 }; const glyph = try face.renderGlyph( alloc, - &atlas_greyscale, + &atlas_grayscale, cp, ); try testing.expectEqual(@as(u32, face.width), glyph.width); diff --git a/src/font/sprite/canvas.zig b/src/font/sprite/canvas.zig index e7072f56a..10699615b 100644 --- a/src/font/sprite/canvas.zig +++ b/src/font/sprite/canvas.zig @@ -220,7 +220,7 @@ const WebCanvasImpl = struct { } pub fn writeAtlas(self: *WebCanvasImpl, alloc: Allocator, atlas: *font.Atlas) !font.Atlas.Region { - assert(atlas.format == .greyscale); + assert(atlas.format == .grayscale); // Reload our context since we resized the canvas const ctx = try self.context(null); @@ -342,7 +342,7 @@ const PixmanImpl = struct { /// Write the data in this drawing to the atlas. pub fn writeAtlas(self: *Canvas, alloc: Allocator, atlas: *font.Atlas) !font.Atlas.Region { - assert(atlas.format == .greyscale); + assert(atlas.format == .grayscale); const width = @as(u32, @intCast(self.image.getWidth())); const height = @as(u32, @intCast(self.image.getHeight())); diff --git a/src/font/sprite/underline.zig b/src/font/sprite/underline.zig index 668b168d6..b22db4f52 100644 --- a/src/font/sprite/underline.zig +++ b/src/font/sprite/underline.zig @@ -215,12 +215,12 @@ test "single" { const testing = std.testing; const alloc = testing.allocator; - var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); - defer atlas_greyscale.deinit(alloc); + var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale); + defer atlas_grayscale.deinit(alloc); _ = try renderGlyph( alloc, - &atlas_greyscale, + &atlas_grayscale, .underline, 36, 18, @@ -233,12 +233,12 @@ test "strikethrough" { const testing = std.testing; const alloc = testing.allocator; - var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); - defer atlas_greyscale.deinit(alloc); + var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale); + defer atlas_grayscale.deinit(alloc); _ = try renderGlyph( alloc, - &atlas_greyscale, + &atlas_grayscale, .strikethrough, 36, 18, @@ -251,14 +251,14 @@ test "single large thickness" { const testing = std.testing; const alloc = testing.allocator; - var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); - defer atlas_greyscale.deinit(alloc); + var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale); + defer atlas_grayscale.deinit(alloc); // unrealistic thickness but used to cause a crash // https://github.com/mitchellh/ghostty/pull/1548 _ = try renderGlyph( alloc, - &atlas_greyscale, + &atlas_grayscale, .underline, 36, 18, @@ -271,12 +271,12 @@ test "curly" { const testing = std.testing; const alloc = testing.allocator; - var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); - defer atlas_greyscale.deinit(alloc); + var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale); + defer atlas_grayscale.deinit(alloc); _ = try renderGlyph( alloc, - &atlas_greyscale, + &atlas_grayscale, .underline_curly, 36, 18, diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index f50de2f6a..ebd5d9b0d 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -238,8 +238,8 @@ pub const FrameState = struct { cells: CellTextBuffer, cells_bg: CellBgBuffer, - greyscale: objc.Object, // MTLTexture - greyscale_modified: usize = 0, + grayscale: objc.Object, // MTLTexture + grayscale_modified: usize = 0, color: objc.Object, // MTLTexture color_modified: usize = 0, @@ -263,12 +263,12 @@ pub const FrameState = struct { errdefer cells_bg.deinit(); // Initialize our textures for our font atlas. - const greyscale = try initAtlasTexture(device, &.{ + const grayscale = try initAtlasTexture(device, &.{ .data = undefined, .size = 8, - .format = .greyscale, + .format = .grayscale, }); - errdefer deinitMTLResource(greyscale); + errdefer deinitMTLResource(grayscale); const color = try initAtlasTexture(device, &.{ .data = undefined, .size = 8, @@ -280,7 +280,7 @@ pub const FrameState = struct { .uniforms = uniforms, .cells = cells, .cells_bg = cells_bg, - .greyscale = greyscale, + .grayscale = grayscale, .color = color, }; } @@ -289,7 +289,7 @@ pub const FrameState = struct { self.uniforms.deinit(); self.cells.deinit(); self.cells_bg.deinit(); - deinitMTLResource(self.greyscale); + deinitMTLResource(self.grayscale); deinitMTLResource(self.color); } }; @@ -827,7 +827,7 @@ pub fn setFontGrid(self: *Metal, grid: *font.SharedGrid) void { // We can modify this without a lock because the GPU does not // touch this data. for (&self.gpu_state.frames) |*frame| { - frame.greyscale_modified = 0; + frame.grayscale_modified = 0; frame.color_modified = 0; } @@ -1045,10 +1045,10 @@ pub fn updateFrame( switch (kv.value_ptr.image) { .ready => {}, - .pending_grey_alpha, + .pending_gray_alpha, .pending_rgb, .pending_rgba, - .replace_grey_alpha, + .replace_gray_alpha, .replace_rgb, .replace_rgba, => try kv.value_ptr.image.upload(self.alloc, self.gpu_state.device), @@ -1114,12 +1114,12 @@ pub fn drawFrame(self: *Metal, surface: *apprt.Surface) !void { // If our font atlas changed, sync the texture data texture: { - const modified = self.font_grid.atlas_greyscale.modified.load(.monotonic); - if (modified <= frame.greyscale_modified) break :texture; + const modified = self.font_grid.atlas_grayscale.modified.load(.monotonic); + if (modified <= frame.grayscale_modified) break :texture; self.font_grid.lock.lockShared(); defer self.font_grid.lock.unlockShared(); - frame.greyscale_modified = self.font_grid.atlas_greyscale.modified.load(.monotonic); - try syncAtlasTexture(self.gpu_state.device, &self.font_grid.atlas_greyscale, &frame.greyscale); + frame.grayscale_modified = self.font_grid.atlas_grayscale.modified.load(.monotonic); + try syncAtlasTexture(self.gpu_state.device, &self.font_grid.atlas_grayscale, &frame.grayscale); } texture: { const modified = self.font_grid.atlas_color.modified.load(.monotonic); @@ -1571,7 +1571,7 @@ fn drawCellFgs( void, objc.sel("setFragmentTexture:atIndex:"), .{ - frame.greyscale.value, + frame.grayscale.value, @as(c_ulong, 0), }, ); @@ -1861,7 +1861,7 @@ fn prepKittyImage( }; const new_image: Image = switch (image.format) { - .grey_alpha => .{ .pending_grey_alpha = pending }, + .gray_alpha => .{ .pending_gray_alpha = pending }, .rgb => .{ .pending_rgb = pending }, .rgba => .{ .pending_rgba = pending }, .png => unreachable, // should be decoded by now @@ -2733,7 +2733,7 @@ fn syncAtlasTexture(device: objc.Object, atlas: *const font.Atlas, texture: *obj fn initAtlasTexture(device: objc.Object, atlas: *const font.Atlas) !objc.Object { // Determine our pixel format const pixel_format: mtl.MTLPixelFormat = switch (atlas.format) { - .greyscale => .r8unorm, + .grayscale => .r8unorm, .rgba => .bgra8unorm, else => @panic("unsupported atlas format for Metal texture"), }; diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 2b6ed82a8..a8d0198e2 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -82,8 +82,8 @@ gl_state: ?GLState = null, font_grid: *font.SharedGrid, font_shaper: font.Shaper, font_shaper_cache: font.ShaperCache, -texture_greyscale_modified: usize = 0, -texture_greyscale_resized: usize = 0, +texture_grayscale_modified: usize = 0, +texture_grayscale_resized: usize = 0, texture_color_modified: usize = 0, texture_color_resized: usize = 0, @@ -551,9 +551,9 @@ pub fn displayRealize(self: *OpenGL) !void { // reflush everything self.gl_cells_size = 0; self.gl_cells_written = 0; - self.texture_greyscale_modified = 0; + self.texture_grayscale_modified = 0; self.texture_color_modified = 0; - self.texture_greyscale_resized = 0; + self.texture_grayscale_resized = 0; self.texture_color_resized = 0; // We need to reset our uniforms @@ -669,8 +669,8 @@ pub fn setFontGrid(self: *OpenGL, grid: *font.SharedGrid) void { // Reset our font grid self.font_grid = grid; self.grid_metrics = grid.metrics; - self.texture_greyscale_modified = 0; - self.texture_greyscale_resized = 0; + self.texture_grayscale_modified = 0; + self.texture_grayscale_resized = 0; self.texture_color_modified = 0; self.texture_color_resized = 0; @@ -1134,7 +1134,7 @@ fn prepKittyImage( }; const new_image: Image = switch (image.format) { - .grey_alpha => .{ .pending_grey_alpha = pending }, + .gray_alpha => .{ .pending_gray_alpha = pending }, .rgb => .{ .pending_rgb = pending }, .rgba => .{ .pending_rgba = pending }, .png => unreachable, // should be decoded by now @@ -1912,9 +1912,9 @@ fn flushAtlas(self: *OpenGL) !void { try flushAtlasSingle( &self.font_grid.lock, gl_state.texture, - &self.font_grid.atlas_greyscale, - &self.texture_greyscale_modified, - &self.texture_greyscale_resized, + &self.font_grid.atlas_grayscale, + &self.texture_grayscale_modified, + &self.texture_grayscale_resized, .red, .red, ); @@ -1998,10 +1998,10 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void { switch (kv.value_ptr.image) { .ready => {}, - .pending_grey_alpha, + .pending_gray_alpha, .pending_rgb, .pending_rgba, - .replace_grey_alpha, + .replace_gray_alpha, .replace_rgb, .replace_rgba, => try kv.value_ptr.image.upload(self.alloc), @@ -2317,12 +2317,12 @@ const GLState = struct { try texbind.image2D( 0, .red, - @intCast(font_grid.atlas_greyscale.size), - @intCast(font_grid.atlas_greyscale.size), + @intCast(font_grid.atlas_grayscale.size), + @intCast(font_grid.atlas_grayscale.size), 0, .red, .UnsignedByte, - font_grid.atlas_greyscale.data.ptr, + font_grid.atlas_grayscale.data.ptr, ); } diff --git a/src/renderer/metal/image.zig b/src/renderer/metal/image.zig index c6a82236c..2693a48e1 100644 --- a/src/renderer/metal/image.zig +++ b/src/renderer/metal/image.zig @@ -47,13 +47,13 @@ pub const Image = union(enum) { /// /// This data is owned by this union so it must be freed once the /// image is uploaded. - pending_grey_alpha: Pending, + pending_gray_alpha: Pending, pending_rgb: Pending, pending_rgba: Pending, /// This is the same as the pending states but there is a texture /// already allocated that we want to replace. - replace_grey_alpha: Replace, + replace_gray_alpha: Replace, replace_rgb: Replace, replace_rgba: Replace, @@ -90,12 +90,12 @@ pub const Image = union(enum) { pub fn deinit(self: Image, alloc: Allocator) void { switch (self) { - .pending_grey_alpha => |p| alloc.free(p.dataSlice(2)), + .pending_gray_alpha => |p| alloc.free(p.dataSlice(2)), .pending_rgb => |p| alloc.free(p.dataSlice(3)), .pending_rgba => |p| alloc.free(p.dataSlice(4)), .unload_pending => |data| alloc.free(data), - .replace_grey_alpha => |r| { + .replace_gray_alpha => |r| { alloc.free(r.pending.dataSlice(2)); r.texture.msgSend(void, objc.sel("release"), .{}); }, @@ -130,10 +130,10 @@ pub const Image = union(enum) { => return, .ready => |obj| .{ .unload_ready = obj }, - .pending_grey_alpha => |p| .{ .unload_pending = p.dataSlice(2) }, + .pending_gray_alpha => |p| .{ .unload_pending = p.dataSlice(2) }, .pending_rgb => |p| .{ .unload_pending = p.dataSlice(3) }, .pending_rgba => |p| .{ .unload_pending = p.dataSlice(4) }, - .replace_grey_alpha => |r| .{ .unload_replace = .{ + .replace_gray_alpha => |r| .{ .unload_replace = .{ r.pending.dataSlice(2), r.texture, } }, .replace_rgb => |r| .{ .unload_replace = .{ @@ -160,7 +160,7 @@ pub const Image = union(enum) { const existing: objc.Object = switch (self.*) { // For pending, we can free the old data and become pending // ourselves. - .pending_grey_alpha => |p| { + .pending_gray_alpha => |p| { alloc.free(p.dataSlice(2)); self.* = img; return; @@ -194,7 +194,7 @@ pub const Image = union(enum) { // If we were already pending a replacement, then we free our // existing pending data and use the same texture. - .replace_grey_alpha => |r| existing: { + .replace_gray_alpha => |r| existing: { alloc.free(r.pending.dataSlice(2)); break :existing r.texture; }, @@ -217,7 +217,7 @@ pub const Image = union(enum) { // We now have an existing texture, so set the proper replace key. self.* = switch (img) { - .pending_grey_alpha => |p| .{ .replace_grey_alpha = .{ + .pending_gray_alpha => |p| .{ .replace_gray_alpha = .{ .texture = existing, .pending = p, } }, @@ -290,7 +290,7 @@ pub const Image = union(enum) { }, // GA needs to be converted to RGBA, too. - .pending_grey_alpha => |*p| { + .pending_gray_alpha => |*p| { const data = p.dataSlice(2); const rgba = try gaToRgba(alloc, data); alloc.free(data); @@ -298,7 +298,7 @@ pub const Image = union(enum) { self.* = .{ .pending_rgba = p.* }; }, - .replace_grey_alpha => |*r| { + .replace_gray_alpha => |*r| { const data = r.pending.dataSlice(2); const rgba = try gaToRgba(alloc, data); alloc.free(data); diff --git a/src/renderer/opengl/image.zig b/src/renderer/opengl/image.zig index 63af81390..a67d8920f 100644 --- a/src/renderer/opengl/image.zig +++ b/src/renderer/opengl/image.zig @@ -45,13 +45,13 @@ pub const Image = union(enum) { /// /// This data is owned by this union so it must be freed once the /// image is uploaded. - pending_grey_alpha: Pending, + pending_gray_alpha: Pending, pending_rgb: Pending, pending_rgba: Pending, /// This is the same as the pending states but there is a texture /// already allocated that we want to replace. - replace_grey_alpha: Replace, + replace_gray_alpha: Replace, replace_rgb: Replace, replace_rgba: Replace, @@ -88,12 +88,12 @@ pub const Image = union(enum) { pub fn deinit(self: Image, alloc: Allocator) void { switch (self) { - .pending_grey_alpha => |p| alloc.free(p.dataSlice(2)), + .pending_gray_alpha => |p| alloc.free(p.dataSlice(2)), .pending_rgb => |p| alloc.free(p.dataSlice(3)), .pending_rgba => |p| alloc.free(p.dataSlice(4)), .unload_pending => |data| alloc.free(data), - .replace_grey_alpha => |r| { + .replace_gray_alpha => |r| { alloc.free(r.pending.dataSlice(2)); r.texture.destroy(); }, @@ -128,10 +128,10 @@ pub const Image = union(enum) { => return, .ready => |obj| .{ .unload_ready = obj }, - .pending_grey_alpha => |p| .{ .unload_pending = p.dataSlice(2) }, + .pending_gray_alpha => |p| .{ .unload_pending = p.dataSlice(2) }, .pending_rgb => |p| .{ .unload_pending = p.dataSlice(3) }, .pending_rgba => |p| .{ .unload_pending = p.dataSlice(4) }, - .replace_grey_alpha => |r| .{ .unload_replace = .{ + .replace_gray_alpha => |r| .{ .unload_replace = .{ r.pending.dataSlice(2), r.texture, } }, .replace_rgb => |r| .{ .unload_replace = .{ @@ -157,7 +157,7 @@ pub const Image = union(enum) { // the self pointer directly. const existing: gl.Texture = switch (self.*) { // For pending, we can free the old data and become pending ourselves. - .pending_grey_alpha => |p| { + .pending_gray_alpha => |p| { alloc.free(p.dataSlice(2)); self.* = img; return; @@ -191,7 +191,7 @@ pub const Image = union(enum) { // If we were already pending a replacement, then we free our // existing pending data and use the same texture. - .replace_grey_alpha => |r| existing: { + .replace_gray_alpha => |r| existing: { alloc.free(r.pending.dataSlice(2)); break :existing r.texture; }, @@ -214,7 +214,7 @@ pub const Image = union(enum) { // We now have an existing texture, so set the proper replace key. self.* = switch (img) { - .pending_grey_alpha => |p| .{ .replace_grey_alpha = .{ + .pending_gray_alpha => |p| .{ .replace_gray_alpha = .{ .texture = existing, .pending = p, } }, @@ -246,7 +246,7 @@ pub const Image = union(enum) { => true, .ready, - .pending_grey_alpha, + .pending_gray_alpha, .pending_rgb, .pending_rgba, => false, @@ -288,7 +288,7 @@ pub const Image = union(enum) { }, // GA needs to be converted to RGBA, too. - .pending_grey_alpha => |*p| { + .pending_gray_alpha => |*p| { const data = p.dataSlice(2); const rgba = try gaToRgba(alloc, data); alloc.free(data); @@ -296,7 +296,7 @@ pub const Image = union(enum) { self.* = .{ .pending_rgba = p.* }; }, - .replace_grey_alpha => |*r| { + .replace_gray_alpha => |*r| { const data = r.pending.dataSlice(2); const rgba = try gaToRgba(alloc, data); alloc.free(data); diff --git a/src/renderer/shaders/cell.metal b/src/renderer/shaders/cell.metal index b58e6600e..734608c76 100644 --- a/src/renderer/shaders/cell.metal +++ b/src/renderer/shaders/cell.metal @@ -304,7 +304,7 @@ vertex CellTextVertexOut cell_text_vertex( fragment float4 cell_text_fragment( CellTextVertexOut in [[stage_in]], - texture2d textureGreyscale [[texture(0)]], + texture2d textureGrayscale [[texture(0)]], texture2d textureColor [[texture(1)]] ) { constexpr sampler textureSampler( @@ -325,7 +325,7 @@ fragment float4 cell_text_fragment( float4 premult = float4(in.color.rgb * in.color.a, in.color.a); // Then premult the texture color - float a = textureGreyscale.sample(textureSampler, in.tex_coord).r; + float a = textureGrayscale.sample(textureSampler, in.tex_coord).r; premult = premult * a; return premult; diff --git a/src/terminal/color.zig b/src/terminal/color.zig index 194cee8b1..ed6d0be3d 100644 --- a/src/terminal/color.zig +++ b/src/terminal/color.zig @@ -31,7 +31,7 @@ pub const default: Palette = default: { } } - // Grey ramp + // Gray ramp assert(i == 232); assert(@TypeOf(i) == u8); while (i > 0) : (i +%= 1) { diff --git a/src/terminal/kitty/graphics_command.zig b/src/terminal/kitty/graphics_command.zig index d4da1da9b..cec5a2a64 100644 --- a/src/terminal/kitty/graphics_command.zig +++ b/src/terminal/kitty/graphics_command.zig @@ -367,11 +367,11 @@ pub const Transmission = struct { // The following are not supported directly via the protocol // but they are formats that a png may decode to that we // support. - grey_alpha, + gray_alpha, pub fn bpp(self: Format) u8 { return switch (self) { - .grey_alpha => 2, + .gray_alpha => 2, .rgb => 3, .rgba => 4, .png => unreachable, // Must be validated before diff --git a/src/terminal/kitty/graphics_image.zig b/src/terminal/kitty/graphics_image.zig index 9e0a0ef45..a4941dbb2 100644 --- a/src/terminal/kitty/graphics_image.zig +++ b/src/terminal/kitty/graphics_image.zig @@ -145,7 +145,7 @@ pub const LoadingImage = struct { .png => stat_size, // For these formats we have a size we must have. - .grey_alpha, .rgb, .rgba => |f| size: { + .gray_alpha, .rgb, .rgba => |f| size: { const bpp = f.bpp(); break :size self.image.width * self.image.height * bpp; }, @@ -447,7 +447,7 @@ pub const LoadingImage = struct { self.image.width = @intCast(width); self.image.height = @intCast(height); self.image.format = switch (bpp) { - 2 => .grey_alpha, + 2 => .gray_alpha, 3 => .rgb, 4 => .rgba, else => unreachable, // validated above diff --git a/typos.toml b/typos.toml index 2d2813d4c..9f2c96f11 100644 --- a/typos.toml +++ b/typos.toml @@ -4,6 +4,8 @@ extend-exclude = [ "pkg/*", "src/stb/*", "*.xib", + # "grey" color names are valid + "src/terminal/res/rgb.txt", # Do not self-check "typos.toml", # Fonts @@ -36,6 +38,8 @@ iterm = "iterm" ACCES = "ACCES" wdth = "wdth" Strat = "Strat" +grey = "gray" +greyscale = "grayscale" [type.swift.extend-words] inout = "inout"