summaryrefslogtreecommitdiff
path: root/src/font/Collection.zig
AgeCommit message (Collapse)Author
2025-10-03ci: cleanupMitchell Hashimoto
2025-09-30Implement and use generic approx equality testerDaniel Wennberg
2025-09-29fix(font): Improve FreeType glyph measurements and add unit tests for face ↵Mitchell Hashimoto
metrics (#8738) Follow-up to #8720 adding * Two improvements to FreeType glyph measurements: - Ensuring that glyphs are measured with the same hinting as they are rendered, ref [#8720#issuecomment-3305408157](https://github.com/ghostty-org/ghostty/pull/8720#issuecomment-3305408157); - For outline glyphs, using the outline bbox instead of the built-in metrics, like `renderGlyph()`. * Basic unit tests for face metrics and their estimators, using the narrowest and widest fonts from the resource directory, Cozette Vector and Geist Mono. --- I also made one unrelated change to `freetype.zig`, replacing `@alignCast(@ptrCast(...))` with `@ptrCast(@alignCast(...))` on line 173. Autoformatting has been making this change on every save for weeks, and reverting the hunk before each commit is getting old, so I hope it's OK that I use this PR to upstream this decree from the formatter.
2025-09-29Rewrite constraint code for improved icon scaling/alignmentDaniel Wennberg
2025-09-18Drop the nan sentinel; just fall through insteadDaniel Wennberg
2025-09-18Use approximate equality for float comparisonsDaniel Wennberg
2025-09-17Add tests for font metrics and their estimatorsDaniel Wennberg
2025-09-03fix(font): make `face.getMetrics()` infallibleQwerasd
Before we had a bad day if we tried to get the metrics of a bitmap font, which would happen if we ever used one as fallback because we started doing it for all fonts when we added fallback font scaling. This is a pretty easy fix and finally allows users to configure true bitmap fonts as their primary font as long as FreeType/CoreText can handle it.
2025-08-20terminal: fix undefined memory in Tabstops codeMitchell Hashimoto
2025-07-25font: clean up Collection api somewhatQwerasd
Move size adjustment logic out of `Entry`, I understand the impulse to put it there but it results in passing a lot of stuff around which isn't great. Rework `add(...)` in to `add(...)` and `addDeferred(...)`, faces are passed directly now instead of passing an entry, and an options struct is used instead of positional arguments for things like style, fallback, and size adjustment. Change size adjustment test back to a half pixel tolerance instead of 5% because the previous commit (allowing fractional pixel sizes) fixed the root cause of large differences.
2025-07-24cleanupQwerasd
A variety of naming, commenting, and formatting improvements + a few explicit error sets. This commit has no functional changes, though it does remove a couple functions that didn't really need to exist.
2025-07-18Update a straggling name and signatureDaniel Wennberg
2025-07-18Calculate scaled size directly, eliminate redundant resizesDaniel Wennberg
2025-07-17Add unwrapConst, avoid constCastDaniel Wennberg
2025-07-17Make size normalization reference customizable per faceDaniel Wennberg
2025-07-17Move face metric fallback estimates to the FaceMetric structDaniel Wennberg
2025-07-07font: add icon height to nerd font constraintsQwerasd
Icons were often WAY too big before because they were filling the whole cell in height, which isn't great lol. This commit adds an `icon_height` metric which is used to constrain glyphs that shouldn't be the size of the entire cell.
2025-07-06font: add test for size adjustment, fix small bug in resizeQwerasd
Previously produced very wrong values when calling Collection.setSize, since it was assuming that the provided face had the same point size as the primary face, which isn't true during resize-- so instead we just have faces keep track of their set size, this is generally useful.
2025-07-06font: adjust fallback font sizes to match primary metricsQwerasd
This better harmonizes fallback fonts with the primary font by matching the heights of lowercase letters. This should be a big improvement for users who use mixed scripts and so rely heavily on fallback fonts.
2025-05-26style: use decl literalsQwerasd
This commit changes a LOT of areas of the code to use decl literals instead of redundantly referring to the type. These changes were mostly driven by some regex searches and then manual adjustment on a case-by-case basis. I almost certainly missed quite a few places where decl literals could be used, but this is a good first step in converting things, and other instances can be addressed when they're discovered. I tested GLFW+Metal and building the framework on macOS and tested a GTK build on Linux, so I'm 99% sure I didn't introduce any syntax errors or other problems with this. (fingers crossed)
2025-05-01fix(tests): correctly deinit font facesQwerasd
2025-05-01font/freetype: introduce mutexes to ensure thread safety of Library and FaceQwerasd
For details see comments and FreeType docs @ https://freetype.org/freetype2/docs/reference/ft2-library_setup.html#ft_library https://freetype.org/freetype2/docs/reference/ft2-face_creation.html#ft_face tl;dr: FT_New_Face and FT_Done_Face require the Library to be locked for thread safety, and FT_Load_Glyph and FT_Render_Glyph and friends need the face to be locked for thread safety, since we're sharing faces across threads.
2025-03-12Lots of 0.14 changesMitchell Hashimoto
2025-01-06refactor(font): move ownership of `Metrics` to `Collection`Qwerasd
This sets the stage for dynamically adjusting the sizes of fallback fonts based on the primary font's face metrics. It also removes a lot of unnecessary work when loading fallback fonts, since we only actually use the metrics based on the parimary font.
2025-01-06refactor(font): move `Metrics` out of `face`Qwerasd
in preparation to move ownership of metrics from faces to collections
2024-11-09docs: write documentation for `freetype_load_flags` fieldNadir Fejzic
2024-11-09refactor: define `FreetypeLoadFlags` struct and default in `font.face`Nadir Fejzic
2024-11-09refactor: make freetype flags void for non-freetype backendNadir Fejzic
This is an attempt to use `void` as type for Freetype Load Flags when backend does not use these flags.
2024-11-09refactor: handle freetype load flags in face instead of rendererNadir Fejzic
2024-10-18expand explicit error set usageMitchell Hashimoto
This continues our work to improve the amount of explicit error sets we use in the codebase. Explicit error sets make it easier to understand possible failure scenarios, allow us to use exhaustive matching, create compiler errors if errors are unexpectedly added or removed, etc. The goal eventually is 100% coverage but we're not even close yet. This just moves us a little closer.
2024-10-02font: add stylistic variants for built-in font, fix naming conventionMitchell Hashimoto
Fixes #2364 This adds the bold, italic, and bold italic variants of JB Mono so it is built-in. This also fixes up the naming convention for the embedded font files across tests and removes redundant embedded font files.
2024-08-26config: font-synthetic-style to enable/disable synthetic stylesMitchell Hashimoto
This adds a new configuration "font-synthetic-style" to enable or disable synthetic styles. This is different from "font-style-*" which specifies a named style or disables a style completely. Instead, "font-synthetic-style" will disable only the creation of synthetic styles in the case a font does not support a given style. This is useful for users who want to obviously know when a font doesn't support a given style or a user who wants to explicitly only use the styles that were designed by the font designer. The default value is to enable all synthetic styles.
2024-08-24typosMitchell Hashimoto
2024-08-23font: synthesize bold italicMitchell Hashimoto
2024-08-23font/coretext: support synthetic boldMitchell Hashimoto
2024-08-23font: rename auto-italicize to synthetic italicMitchell Hashimoto
2024-08-23font: bold italic fallback has to avoid nested alias entryMitchell Hashimoto
2024-08-23font: Collection can't use segmentedlist preallocMitchell Hashimoto
2024-08-23font: completeStylesMitchell Hashimoto
2024-08-23font: Collection uses SegmentedList for styles for pointer stabilityMitchell Hashimoto
2024-08-23font: support aliased entries in the font collection style tableMitchell Hashimoto
2024-05-28font: handle presentation at glyph layerMitchell Hashimoto
2024-04-05font/harfbuzz: work with new font structuresMitchell Hashimoto
2024-04-05font: SharedGridSet clarify memory ownershipMitchell Hashimoto
2024-04-05font: CodepointResolver style disabling testMitchell Hashimoto
2024-04-05font: CodepointResolver beginningsMitchell Hashimoto
2024-04-05font: Collection setSizeMitchell Hashimoto
2024-04-05font: Collection autoItalicizeMitchell Hashimoto
2024-04-05font: Collection deinitMitchell Hashimoto
2024-04-05font: Collection.getIndexMitchell Hashimoto