aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/quirks.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/src/quirks.zig
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/src/quirks.zig')
-rw-r--r--vendor/libghostty-vt/src/quirks.zig57
1 files changed, 57 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/quirks.zig b/vendor/libghostty-vt/src/quirks.zig
new file mode 100644
index 00000000..ecef7460
--- /dev/null
+++ b/vendor/libghostty-vt/src/quirks.zig
@@ -0,0 +1,57 @@
+//! Inspired by WebKit's quirks.cpp[1], this file centralizes all our
+//! sad environment-specific hacks that we have to do to make things work.
+//! This is a last resort; if we can find a general solution to a problem,
+//! we of course prefer that, but sometimes other software, fonts, etc. are
+//! just broken or weird and we have to work around it.
+//!
+//! [1]: https://github.com/WebKit/WebKit/blob/main/Source/WebCore/page/Quirks.cpp
+
+const std = @import("std");
+const builtin = @import("builtin");
+
+const font = @import("font/main.zig");
+
+/// If true, the default font features should be disabled for the given face.
+pub fn disableDefaultFontFeatures(face: *const font.Face) bool {
+ _ = face;
+
+ // This function used to do something, but we integrated the logic
+ // we checked for directly into our shaping algorithm. It's likely
+ // there are other broken fonts for other reasons so I'm keeping this
+ // around so its easy to add more checks in the future.
+ return false;
+
+ // var buf: [64]u8 = undefined;
+ // const name = face.name(&buf) catch |err| switch (err) {
+ // // If the name doesn't fit in buf we know this will be false
+ // // because we have no quirks fonts that are longer than buf!
+ // error.OutOfMemory => return false,
+ // };
+}
+
+/// We use our own assert function instead of `std.debug.assert`.
+///
+/// The only difference between this and the one in
+/// the stdlib is that this version is marked inline.
+///
+/// The reason for this is that, despite the promises of the doc comment
+/// on the stdlib function, the function call to `std.debug.assert` isn't
+/// always optimized away in `ReleaseFast` mode, at least in Zig 0.15.2.
+///
+/// In the majority of places, the overhead from calling an empty function
+/// is negligible, but we have some asserts inside tight loops and hotpaths
+/// that cause significant overhead (as much as 15-20%) when they don't get
+/// optimized out.
+pub const inlineAssert = switch (builtin.mode) {
+ // In debug builds we just use std.debug.assert because this
+ // fixes up stack traces. `inline` causes broken stack traces. This
+ // is probably a Zig compiler bug but until it is fixed we have to
+ // do this for development sanity.
+ .Debug => std.debug.assert,
+
+ .ReleaseSmall, .ReleaseSafe, .ReleaseFast => (struct {
+ inline fn assert(ok: bool) void {
+ if (!ok) unreachable;
+ }
+ }).assert,
+};