58 Commits

Author SHA1 Message Date
Qwerasd
e441094af0 font: add constraint logic to rasterizers
This is in preparation to move constraint off the GPU to simplify our
shaders, instead we only need to constrain once at raster time and never
again.

This also significantly reworks the freetype renderGlyph function to be
generally much cleaner and more straightforward.

This commit doesn't actually apply the constraints to anything yet, that
will be in following commits.
2025-07-04 15:47:28 -06:00
Mitchell Hashimoto
0f1860f066 build: use a libc txt file to point to correct Apple SDK
This fixes an issue where Ghostty would not build against the macOS 15.5 SDK.

What was happening was that Zig was adding its embedded libc paths to
the clang command line, which included old headers that were
incompatible with the latest (macOS 15.5) SDK. Ghostty was adding the
newer paths but they were being overridden by the embedded libc paths.

The reason this was happening is because Zig was using its own logic to
find the libc paths and this was colliding with the paths we were
setting manually. To fix this, we now use a `libc.txt` file that
explicitly tells Zig where to find libc, and we base this on our own SDK
search logic.
2025-05-29 15:04:05 -07:00
Qwerasd
6f84a5d682 font/freetype: disable SVG glyphs, simplify color check
We don't currently support rendering SVG glyphs so they should be
ignored when loading. Additionally, the check for whether a glyph is
colored has been simplified by just checking the pixel mode of the
rendered bitmap.

This commit also fixes a bug caused by calling the color check inside of
`renderGlyph`, which caused the bitmap to be freed creating a chance for
memory corruption and garbled glyphs.
2025-03-19 12:43:18 -06:00
Mitchell Hashimoto
cfea2ea12c build: mark most dependencies as lazy
Lazy dependencies are only fetched if the build script would actually
reach a usage of that dependency at runtime (when the `lazyDependency`
function is called). This can save a lot of network traffic, disk uage,
and time because we don't have to fetch and build dependencies that we
don't actually need.

Prior to this commit, Ghostty fetched almost everything for all
platforms and configurations all the time. This commit reverses that to
fetching almost nothing until it's actually needed.

There are very little downsides to doing this[1]. One downside is `zig
build --fetch` doesn't fetch lazy dependencies, but we don't rely on
this command for packaging and suggest using our custom shell script
that downloads a cached list of URLs (`build.zig.zon.txt`).

This commit doesn't cover 100% of dependencies, since some provide no
benefit to make lazy while the complexity to make them lazy is higher
(in code style typically).

Conversely, some simple dependencies are marked lazy even if they're
almost always needed if they don't introduce any real complexity to the
code, because there is very little downside to do so.

[1]: https://ziggit.dev/t/lazy-dependencies-best-dependencies/5509/5
2025-03-14 13:32:19 -07:00
Mitchell Hashimoto
2466de4556 pkg: update to new build.zig.zon format and hash values 2025-03-11 15:00:47 -07:00
Mitchell Hashimoto
7e2286eb8c Zig 0.14 2025-03-11 14:39:04 -07:00
Mitchell Hashimoto
8231ebb770 build: mirror most of our direct dependencies
This adds a new script `update-mirror.sh` which generates the proper
blob format for R2 (or any blob storage) to mirror all of our
dependencies.

It doesn't automate updating build.zig.zon but on an ongoing basis this
should be easy to do manually, and we can strive to automate it in the
future.

I omitted iTerm2 color themes because we auto-update that via CI and
updating all of the machinery to send it to our mirror and so on is a
pain. Additionally, this doesn't mirror transitive dependencies because
Zig doesn't have a way to fetch those from a mirror instead (unless you
pre-generate a full cache like packagers but that's not practical for
day to day development).

It's hugely beneficial just to get most of our dependencies mirrored.
2025-02-14 10:06:15 -08:00
Jan200101
72e0fb14fe don't build freetype2 when system integration is enabled 2025-01-03 22:41:15 +01:00
Qwerasd
8a5d484729 font: more robust extraction of vertical metrics from tables
Previously always assuming the typo metrics were good caused some fonts
to have abnormally short cell heights.
2024-12-13 13:00:03 -05:00
Qwerasd
bd18452310 font: unify metrics calculations & separate sprite metrics
Unify grid metrics calculations by relying on shared logic mostly based
on values directly from the font tables, this deduplicates a lot of code
and gives us more control over how we interpret various metrics.

Also separate metrics for underlined, strikethrough, and overline
thickness and position, and box drawing thickness, so that they can
individually be adjusted as the user desires.
2024-12-11 16:55:52 -05:00
Mitchell Hashimoto
8bb8b01e54 build: use Zig system packaging options
This allows dynamically linking against system libraries, which is
particularly useful for packaging.
2024-10-24 14:46:37 -07:00
Mitchell Hashimoto
915ec029ee font/freetype: synthetic bold 2024-08-25 09:51:09 -07:00
Mitchell Hashimoto
5f0daa23b9 font/freetype: synthetic italic 2024-08-24 21:03:54 -07:00
Mitchell Hashimoto
91431a90a1 pkg/freetype: remove usingns 2024-08-16 15:34:46 -07:00
Mitchell Hashimoto
a30e791c85 begin 0.13 update process -- very broken 2024-06-24 15:16:22 -07:00
Mitchell Hashimoto
a205e1e2c1 pkg/freetype: use c_ulong which isn't 64-bit on windows 2024-05-28 20:49:21 -07:00
Mitchell Hashimoto
adaeffb2b5 font/freetype: CBDT/CBLC tables imply color 2024-05-28 20:40:46 -07:00
Mitchell Hashimoto
4daa49fe27 font/freetype: update to new presentation APIs 2024-05-28 20:25:49 -07:00
Mitchell Hashimoto
8920f45fd8 font/freetype: API to load font table 2024-05-28 09:48:01 -07:00
Mitchell Hashimoto
595f24585e working on more zig breaking changes 2024-04-17 20:50:50 -07:00
Krzysztof Wolicki
edaafdf57a build API change: update usage of addCSourceFiles 2024-02-26 18:00:43 +01:00
Mitchell Hashimoto
3360a008cd build: build produces a broken object file for iOS
This gets `zig build -Dtarget=aarch64-ios` working. By "working" I mean
it produces an object file without compiler errors. However, the object
file certainly isn't useful since it uses a number of features that will
not work in the iOS sandbox.

This is just an experiment more than anything to see how hard it would be to
get libghostty working within iOS to render a terminal. Note iOS doesn't
support ptys so this wouldn't be a true on-device terminal. The
challenge right now is to just get a terminal rendering (not usable).
2024-01-13 21:38:58 -08:00
Krzysztof Wolicki
f917be968d Merge branch 'mitchellh:main' into main 2024-01-07 19:13:06 +01:00
Krzysztof Wolicki
6c7c5eecce Add include paths to freetype module 2024-01-07 18:45:07 +01:00
Mitchell Hashimoto
efd196e5c9 pkg/freetype: unknown errors should be reported, not unreachable 2024-01-05 21:08:39 -08:00
Krzysztof Wolicki
1913243c35 WIP: Update to new build module API after Zig PR #18160
Temporarily change dependency sources to forks until they update
2024-01-03 21:50:32 +01:00
Carlos Alexandro Becker
25856d62aa Remove FiraCode leftovers
from #993

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2023-12-06 13:36:05 -03:00
Mitchell Hashimoto
0021b290cf pkg: add test targets 2023-10-01 18:43:25 -07:00
Mitchell Hashimoto
f0d4e9c7c3 pkg: remove all old build.zig files 2023-10-01 18:35:31 -07:00
Mitchell Hashimoto
2237b43df0 pkg/freetype, harfbuzz modules 2023-10-01 16:57:45 -07:00
Mitchell Hashimoto
7dc3fcc41e pkg/freetype 2023-10-01 12:12:05 -07:00
Jonathan Marler
a2e881ff4e windows: initial support for zig build test
Makes progress getting "zig build test" to work on windows.  Mostly
fixed issues around build configuration and added some branches throughout
the Zig code to return/throw errors for unimplemented parts.

I also added an initial implementation for getting the home dir.
2023-09-14 03:15:40 -06:00
Mitchell Hashimoto
1ee5b7f91c font: freetype supports font variation settings 2023-08-28 07:25:09 -07:00
Mitchell Hashimoto
ea3b957bc7 quirks: Menlo/Monaco should disable ligatures by default (#331)
* font: disable default font features for Menlo and Monaco

Both of these fonts have a default ligature on "fi" which makes terminal
rendering super ugly. The easiest thing to do is special-case these
fonts and disable ligatures. It appears other terminals do the same
thing.
2023-08-25 09:29:15 -07:00
Kevin Hovsäter
22b8173164 Fix typos 2023-08-08 14:27:34 +02:00
Mitchell Hashimoto
d649b3f6d4 update zig 2023-08-02 14:39:19 -07:00
Mitchell Hashimoto
314f9287b1 Update Zig (#164)
* update zig

* pkg/fontconfig: clean up @as

* pkg/freetype,harfbuzz: clean up @as

* pkg/imgui: clean up @as

* pkg/macos: clean up @as

* pkg/pixman,utf8proc: clean up @as

* clean up @as

* lots more @as cleanup

* undo flatpak changes

* clean up @as
2023-06-30 12:15:31 -07:00
Mitchell Hashimoto
56f8e39e5b Update zig, mach, fmt 2023-06-25 11:08:20 -07:00
Mitchell Hashimoto
be75109a1d new build system 2023-02-14 20:58:33 -08:00
Mitchell Hashimoto
15a57983a6 pkg/freetype: remove unused API 2022-10-16 21:03:17 -07:00
Mitchell Hashimoto
2e1bc7bb01 Bring back freetype font bitmap conversion
Monaco on Mac is mono
2022-10-16 20:47:21 -07:00
Mitchell Hashimoto
e493a722a3 fix some issues that fail nightly stage2 compiler 2022-10-13 10:54:30 -07:00
Mitchell Hashimoto
b18309187e Strikethrough (#19)
Not as straightforward as it sounds, but not hard either:

* Read OS/2 sfnt tables from TrueType fonts
* Calculate strikethrough position/thickness (prefer font-advertised if possible, calculate if not)
* Plumb the SGR code through the terminal state -- does not increase cell memory size
* Modify the shader to support it

The shaders are getting pretty nasty after this... there's tons of room for improvement. I chose to follow the existing shader style for this to keep it straightforward but will likely soon refactor the shaders.
2022-10-06 15:03:19 -07:00
Mitchell Hashimoto
c149696f61 redoing some of the baseline calcs, remove from shader 2022-10-04 10:00:32 -07:00
Mitchell Hashimoto
fdbf40d3ee pkg/freetype: disable ubsan 2022-09-29 11:39:09 -07:00
Mitchell Hashimoto
88a4cb65f3 src/font: working on initiaizing deferred fonts from fc 2022-09-23 14:12:38 -07:00
Mitchell Hashimoto
b4d571e018 pkg/fontconfig: disable ubsan (reported upstream) 2022-09-14 09:23:02 -07:00
Mitchell Hashimoto
f1abca51f7 convert src/font to use new pkg/freetype 2022-08-28 22:22:16 -07:00
Mitchell Hashimoto
672f6e720c pkg/freetype: finish APIs we need 2022-08-28 21:06:36 -07:00
Mitchell Hashimoto
8ef3018189 pkg/freetype: loading glyphs 2022-08-28 21:02:39 -07:00