summaryrefslogtreecommitdiff
path: root/src/renderer
AgeCommit message (Collapse)Author
2025-10-06fix custom-shader writergate breakageJeffrey C. Ollie
Fixes: #9060
2025-10-03Fix typosAndreas Deininger
2025-10-03Zig 0.15: zig build GTK exeMitchell Hashimoto
2025-10-03Zig 0.15: zig build test Mitchell Hashimoto
2025-10-02fix(font): Let powerline glyphs be wideDaniel Wennberg
2025-09-30Revert "renderer: slightly optimize screen copy"Jeffrey C. Ollie
This reverts commit fcea09e413a55c677dca377f716aa9bc6465306b.
2025-09-30renderer: slightly optimize screen copyQwerasd
Changes it so that the renderer retains its own MemoryPool for PageList pages so that new pages rarely need to be allocated when cloning the screen. Also switches to using an arena allocator in `updateFrame` to avoid having to deinit the cloned screen since instead we can just throw out the memory.
2025-09-29move test out of terminal to avoid lib-vt catchMitchell Hashimoto
2025-09-29fix(font): Treat Powerline glyphs as normal characters for constraint width ↵Mitchell Hashimoto
purposes (#8829) Powerline glyphs were treated as whitespace, giving the preceding cell a constraint width of 2 and cutting off icons in people's prompts and statuslines. It is however correct to not treat Powerline glyphs like other Nerd Font symbols; they should simply be treated as normal characters, just like their relatives in the block elements unicode block. This resolves https://discord.com/channels/1005603569187160125/1417236683266592798 (never promoted to an issue, but real and easy to reproduce). **Tip** <img width="215" height="63" alt="Screenshot 2025-09-21 at 16 57 58" src="https://github.com/user-attachments/assets/81e770c5-d688-4d8e-839c-1f4288703c06" /> **This PR** <img width="215" height="63" alt="Screenshot 2025-09-21 at 16 58 42" src="https://github.com/user-attachments/assets/5d2dd770-0314-46f6-99b5-237a0933998e" /> The constraint width logic was untested but contains some quite subtle interactions, so I wrote a suite of tests covering the cases I'm aware of. While working on this code I also resolved a TODO comment to add all the box drawing/block element type characters to the set of codepoints excluded from the minimum contrast settings.
2025-09-29Rewrite constraint code for improved icon scaling/alignmentDaniel Wennberg
2025-09-21Add missing codepoints to isPowerline predicateDaniel Wennberg
e0d6 and e0d7 were left out. Also collapsed everything to a single range; unlikely that the unused gaps (e0c9, e0cb, e0d3, e0d5) would be used for something else in any font that ships Powerline glyphs.
2025-09-21Add box drawing characters to the min contrast exclusionDaniel Wennberg
2025-09-21Treat Powerline glyphs like normal charactersDaniel Wennberg
...not whitespace. Powerline glyphs can be considered an extension of the Block Elements unicode block, which is neither whitespace nor symbols (icons). This ensures that characters immediately followed by a powerline glyph are constrained to a single cell (unlike the current behavior where a PL glyph is considered whitespace), while symbols (icons) immediately preceded by a powerline glyph are not (unlike if a PL glyph were considered a symbol). This resolves https://discord.com/channels/1005603569187160125/1417236683266592798
2025-09-20unicode: delete props.zig and clean up symbols deps tooMitchell Hashimoto
Follow up to #8810 Same reasoning.
2025-09-19build: move apprt, font, renderer enums to dedicated filesMitchell Hashimoto
This reduces the surface area of files we depend on for builds.
2025-09-19renderer/opengl: minimum contrast for black sets proper color Mitchell Hashimoto
Fixes #8745 When rendering black for minimum contrast we were setting opacity to 0 making it invisible.
2025-09-18renderer: create explicit sampler state for custom shadersMitchell Hashimoto
The GLSL to MSL conversion process uses a passed-in sampler state for the `iChannel0` parameter and we weren't providing it. This magically worked on Apple Silicon for unknown reasons but failed on Intel GPUs. In normal, hand-written MSL, we'd explicitly create the sampler state as a normal variable (we do this in `shaders.metal` already!), but the Shadertoy conversion stuff doesn't do this, probably because the exact sampler parameters can't be safely known. This fixes a Metal validation error when using custom shaders: ``` -[MTLDebugRenderCommandEncoder validateCommonDrawErrors:]:5970: failed assertion `Draw Errors Validation Fragment Function(main0): missing Sampler binding at index 0 for iChannel0Smplr[0]. ```
2025-09-18renderer/metal: provide MTLTextureUsage render target for custom shadersMitchell Hashimoto
This fixes a Metal validation error in Xcode when using custom shaders. I suspect this is one part of custom shaders not working properly on Intel macs (probably anything with a discrete GPU). This happens to work on Apple Silicon but this is undefined behavior and we're just getting lucky. There is one more issue I'm chasing down that I think is also still blocking custom shaders working on Intel macs.
2025-09-08comment + style changesQwerasd
2025-09-07Position-independent font shaper cachingJesse Miller
Use relative cluster positioning to allow identical texts runs in different row positions to share the same cache entry.
2025-09-05renderer: add LUT-based implementation of isSymbol (#8528)Jeffrey C. Ollie
The LUT-based lookup gives a ~20%-30% speedup over the "naive" isSymbol implementation. <img width="1206" height="730" alt="Screenshot From 2025-09-04 22-45-10" src="https://github.com/user-attachments/assets/09a8ef3a-8b4b-43ba-963a-849338307251" /> <img width="1206" height="730" alt="Screenshot From 2025-09-04 22-41-54" src="https://github.com/user-attachments/assets/27962a88-f99c-446d-b986-30f526239ba3" /> Fixes #8523
2025-09-05gtk: the Future is Now (#8531)Mitchell Hashimoto
2025-09-05drop the new LUT type as no performance advantage detectedJeffrey C. Ollie
2025-09-05add two LUT-based implementations of isSymbolJeffrey C. Ollie
2025-09-05gtk: the Future is NowLeah Amelia Chen
2025-09-04gtk: nuke the legacy apprt from orbit (#8520)Mitchell Hashimoto
We don't really have any large outstanding regressions on -ng to warrant keeping this alive anymore. ¡Adiós!
2025-09-05gtk: nuke the legacy apprt from orbitLeah Amelia Chen
We don't really have any large outstanding regressions on -ng to warrant keeping this alive anymore. ¡Adiós!
2025-09-03font: expand set of characters considered symbolsQwerasd
Low hanging fruit of some Unicode blocks that are full of very symbol-y characters.
2025-09-03font: constrain dingbatsQwerasd
This was a regression, we were giving dingbats an extra cell of constraint width but not actually applying constraints to them.
2025-09-02fix(renderer): kitty images should all be processedQwerasd
When processing kitty images in a loop in a few places we were returning under certain conditions where we should instead have just continued the loop. This caused serious problems for kitty images, especially for apps that used multiple images on screen at once. ... I have no clue how I originally wrote this code and didn't see such a trivial mistake, I think I was sleep deprived or something.
2025-08-31feat: added faint-opacity option (#8472)Mitchell Hashimoto
This pull request adds the `--faint-opacity` option, as discussed in #7637. The default value of the option is also changed from `0.68` to `0.5` for greater consistency with other popular terminal emulators.
2025-08-31renderer: clarify and correct custom shader cursor position mathQwerasd
This math was incorrect from the start, the previous fix helped OpenGL but broke positioning under Metal; this commit fixes the math to be correct under both backends and adds comments explaining exactly what's going on.
2025-08-31refactor: move faint-opacity clamping to config finalizationPavel Ivanov
2025-08-31feat: added faint-opacity optionPavel Ivanov
2025-08-21fix: correct the cursor Y position value exposed to shader uniformsClearAspect
Fix for discussion #8113 The cursor Y position value exposed to the shader uniforms was incorrectly calculated. As per the doc in cell_text.v.glsl: In order to get the top left of the glyph, we compute an offset based on the bearings. The Y bearing is the distance from the bottom of the cell to the top of the glyph, so we subtract it from the cell height to get the y offset. This calculation was mistakenly left out of the original code. This will ensure that the custom shaders using iCurrentCursor/iPreviousCursor get the correct Y coordinate representing the top-left corner of the cursor rectangle, matching the documented uniform behavior
2025-08-15renderer: don't assume non-zero sized grid Mitchell Hashimoto
Fixes #8243 This adds a check for a zero-sized grid in cursor-related functions. As an alternate approach, I did look into simply skipping a bunch of work on zero-sized grids, but that looked like a scarier change to make now. That may be the better long-term solution but this was an easily unit testable, focused fix on the crash to start.
2025-08-14fix(renderer/generic): deinit render targets with framestateQwerasd
This was a memory leak under Metal, leaked 1 swapchain worth of targets every time a surface was closed. Under OpenGL I think it was all cleaned up when the GL context was destroyed.
2025-08-10renderer: clean up, improve constraintWidth functionQwerasd
2025-07-21slow down our cursor timer under valgrindMitchell Hashimoto
2025-07-18apprt/gtk-ng: hook up surface initializationMitchell Hashimoto
2025-07-11renderer: Allow the renderer to draw transparent cellsnferhat
Co-authored-by: Kat <65649991+00-kat@users.noreply.github.com>
2025-07-10Add tests for getCursorGlyph() helper functionClearAspect
2025-07-10Fix custom shader cursor uniforms not set for non-block cursors (#7893)ClearAspect
Fixes #7893 Previously, custom shader cursor uniforms were only updated when the cursor glyph was in the front (block) cursor list. This caused non-block cursors (such as bar, underline, hollow block, and lock) to be missing from custom shader effects. This commit adds a helper to the cell contents struct to retrieve the current cursor glyph from either the front or back cursor lists, and updates the renderer to use this helper when setting custom shader uniforms. As a result, custom shaders now receive correct cursor information for all supported cursor styles.
2025-07-06Added bold-color optionRobert Ian Hawdon
2025-07-05renderer/opengl: explicit texture optionsQwerasd
This sets up for a couple improvments (see TODO comments) and also sets the glyph atlas textures to nearest neighbor sampling since we can do that now that we never scale glyphs.
2025-07-05Better Glyph Constraint Logic (#7809)Mitchell Hashimoto
This is a big'un. - **Glyph constraint logic is now done fully on the CPU** at the rasterization stage, so it only needs to be done once per glyph instead of every frame. This also lets us eliminate padding between glyphs on the atlas because we're doing nearest-neighbor sampling instead of interpolating-- which ever so slightly increases our packing efficiency. - **Special constraints for nerd font glyphs** are applied based roughly on the constraints they use in their patcher. It's a simplification of what they do, the largest difference being that they scale groups of glyphs based on a shared bounding box so that they maintain relative size to one another, but that would require loading all glyphs on the group and I'd want to do that on font load TBH and at that point I'd basically be re-implementing the nerd fonts patcher in Zig to patch fonts at load time which is way beyond the scope I want to have. (Fixes #7069) - These constraints allow for **perfectly sized and centered emojis**, this is very nice. - **Changed the default embedded fonts** from 4 copies (regular, italic, bold, bold italic) of a patched (and outdated) JetBrains Mono to a single JetBrains Mono variable font and a single Nerd Fonts Symbols Only font. This cuts the weight of those down from 9MB to 3MB! - **FreeType's `renderGlyph` is significantly reworked**, and the new code is, IMO, much cleaner- although there are probably some edge case behavior differences I've introduced. > [!NOTE] > One breaking change I definitely introduced is changing the `monochrome` freetype load flag config from its previous completely backwards meaning to instead the correct one (I also changed the default, so this won't affect any user who hasn't touched it, but users who set the `monochrome` flag will find their fonts quite crispy after this change because they will have no anti-aliasing anymore) ### Future work Following this change I want to get to work on automatic font size matching (a la CSS [`font-size-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size-adjust)). I set the stage for that quite some time ago so it shouldn't be too much work and it will be a big benefit for users who regularly use multiple writing systems and so have multiple fonts for them that aren't necessarily size-compatible.
2025-07-05Nuke GLFW, make `zig build run` on macOS build the Xcode project (#7815)Mitchell Hashimoto
This PR does two things. 1. Build system improvements to make developing on macOS more enjoyable 2. Delete the GLFW apprt ## Build System Improvements (macOS) On macOS, there are a few major improvements: * `zig build` now produces a full macOS app bundle and copies it into `zig-out` * `zig build run` now builds the macOS app and runs it, streaming logs directly into the terminal * `-Demit-macos-app` can control whether app bundle is created * `-Dxcframework-target` can be set to one of `native` or `universal` to control whether the xcframework uses only your target machines arch or creates a universal one with macOS and iOS. This defaults to `native` for the `run` command and `universal` for all others. * The general flow of the `build.zig` file was improved to be more declarative ## Nuke GLFW > This deletes the GLFW apprt from the Ghostty codebase. > > The GLFW apprt was the original apprt used by Ghostty (well, before > Ghostty even had the concept of an "apprt" -- it was all just a single > application then). It let me iterate on the core terminal features, > rendering, etc. without bothering about the UI. It was a good way to get > started. But it has long since outlived its usefulness. > > We've had a stable GTK apprt for Linux (and Windows via WSL) and a > native macOS app via libghostty for awhile now. The GLFW apprt only > remained within the tree for a few reasons: > > 1. Primarily, it provided a faster feedback loop on macOS because > building the macOS app historically required us to hop out of the > zig build system and into Xcode, which is slow and cumbersome. > > 2. It was a convenient way to narrow whether a bug was in the > core Ghostty codebase or in the apprt itself. If a bug was in both > the glfw and macOS app then it was likely in the core. > > 3. It provided us a way on macOS to test OpenGL. > > All of these reasons are no longer valid. Respectively: > > 1. Our Zig build scripts now execute the `xcodebuild` CLI directly and > can open the resulting app, stream logs, etc. This is the same > experience we have on Linux. (Xcode has always been a dependency of > building on macOS in general, so this is not cumbersome.) > > 2. We have a healthy group of maintainers, many of which have access > to both macOS and Linux, so we can quickly narrow down bugs > regardless of the apprt. > > 3. Our OpenGL renderer hasn't been compatible with macOS for some time > now, so this is no longer a useful feature. > > At this point, the GLFW apprt is just a burden. It adds complexity > across the board, and some people try to run Ghostty with it in the real > world and get confused when it doesn't work (it's always been lacking in > features and buggy compared to the other apprts). > > So, it's time to say goodbye. Its bittersweet because it is a big part > of Ghostty's history, but we've grown up now and it's time to move on. > Thank you, goodbye. > > (NOTE: If you are a user of the GLFW apprt, then please fork the project > prior to this commit or start a new project based on it. We've warned > against using it for a very, very long time now.)
2025-07-04replace nested if for readabilityDaniel
2025-07-04added test for other cursor styleDaniel
2025-07-04enable drawing cursor on top or bottom based on styleDaniel