69 Commits

Author SHA1 Message Date
Mitchell Hashimoto
7995d44cfb font: render sprites with a configurable grid cell width
Fixes #666
2023-10-13 14:31:55 -07:00
Mitchell Hashimoto
1411015038 font: fallback search should search full discovery chain
Fixes #668

We were previously only checking the first font result in the search.
This also fixes our CoreText scoring algorithm to prioritize faces that
have the codepoint we're searching for.
2023-10-13 12:25:27 -07:00
Mitchell Hashimoto
2563a195a1 font: wire up all the metric modifiers 2023-10-04 21:42:03 -07:00
Mitchell Hashimoto
54b9b45a7f font: rework font init to use a struct with modifiersets everywhere 2023-10-04 17:23:57 -07:00
Mitchell Hashimoto
15e6c07bd9 font/fontconfig: adhere to correct function signature 2023-10-03 09:26:14 -07:00
Mitchell Hashimoto
1127330b3a font/coretext: score discovered fonts 2023-10-03 09:17:41 -07:00
Mitchell Hashimoto
b1389cbbfe renderer: support font style changing at runtime 2023-09-26 08:51:04 -07:00
Mitchell Hashimoto
6b913bc6bb font: Group can enable/disable styles 2023-09-26 08:37:07 -07:00
Mitchell Hashimoto
6ac4cc9671 font: debug log for overide 2023-09-24 20:40:36 -07:00
Mitchell Hashimoto
abd3e16ebd font: Group will use the codepoint map for codepoint overrides 2023-09-24 19:44:06 -07:00
Mitchell Hashimoto
5c1c090f39 font: change FontIndex to a u16 since we can expect more fonts with maps 2023-09-24 15:53:39 -07:00
Mitchell Hashimoto
9e2e3acecf font: add codepoint map and descriptor cache to Group, not used yet 2023-09-24 11:50:03 -07:00
Mitchell Hashimoto
4e54c5389e font: CodepointMap 2023-09-24 11:10:20 -07:00
Mitchell Hashimoto
16cecc082a font: fallback should not restrict to only monospace 2023-09-24 09:05:40 -07:00
Mitchell Hashimoto
3c7ba634d2 font: remove excess debugging code 2023-09-13 14:41:43 -07:00
Mitchell Hashimoto
a2236d1ceb font: fallback search must verify presentation 2023-09-13 14:27:04 -07:00
Mitchell Hashimoto
3bd77259bf font: don't use intCast on index
This is a weird one. By using intCast on the `idx` I am periodically
getting a panic on index out of bounds where the index is larger than
FontIndex can possibly be. Very strange!

I tried to just remove intCasts and believe it or not that worked.
Previously, `cat /dev/urandom` would trigger the issue in seconds and
now I've had it running 20+ minutes without the issue.

The additional `if` check is just a safety mechanism
2023-08-31 21:16:56 -07:00
Mitchell Hashimoto
e6edf3105e font: grapheme clusters need to find a single font for all codepoints
When font shaping grapheme clusters, we erroneously used the font index
of a font that only matches the first codepoint in the cell. This led to the
combining characters being [usually] unknown and rendering as boxes.

For a grapheme, we must find a font face that has a glyph for _all codepoints_
in the grapheme.

This also fixes an issue where we now properly render the unicode replacement
character if we can't find a font satisfying a codepoint.
2023-08-26 09:35:56 -07:00
Mitchell Hashimoto
c15cf6d9f1 font: fontconfig adaptations to new api 2023-08-25 14:57:05 -07:00
Mitchell Hashimoto
b51ef704f4 font: DeferredFace.name takes a buffer 2023-08-25 14:40:59 -07:00
Mitchell Hashimoto
167bf6f098 font: DeferredFace can no longer represent a loaded face 2023-08-25 13:28:46 -07:00
Mitchell Hashimoto
ad6c2b6cc8 font: move auto-italicization to Group 2023-08-25 13:16:42 -07:00
Mitchell Hashimoto
1dcf921ed9 font: Group maintains face ownership 2023-08-25 13:00:04 -07:00
Mitchell Hashimoto
0af6edc25b only the app should own the font discovery instance 2023-08-13 11:51:24 -07:00
Kevin Hovsäter
22b8173164 Fix typos 2023-08-08 14:27:34 +02:00
Mitchell Hashimoto
c90a52ee50 font: don't fallback styles when searching for a codepoint
see comment
2023-07-03 15:55:01 -07:00
Mitchell Hashimoto
4bf8a0d149 font: support skew transform for auto-italics 2023-07-03 15:54:50 -07:00
Mitchell Hashimoto
0faf6097d0 Change font metrics to all be integers, not floats.
Font metrics realistically should be integral. Cell widths, cell
heights, etc. do not make sense to be floats, since our grid is
integral. There is no such thing as a "half cell" (or any point).

The reason we historically had these all as f32 is simplicity mixed
with history. OpenGL APIs and shaders all use f32 for their values, we
originally only supported OpenGL, and all the font rendering used to be
directly in the renderer code (like... a year+ ago).

When we refactored the font metrics calculation to its own system and
also added additional renderers like Metal (which use f64, not f32), we
never updated anything. We just kept metrics as f32 and casted
everywhere.

With CoreText and #177 this finally reared its ugly head. By forgetting
a simple rounding on cell metric calculation, our integral renderers
(sprite fonts) were off by 1 pixel compared to the GPU renderers.
Insidious.

Let's represent font metrics with the types that actually make sense: a
cell width/height, etc. is _integral_. When we get to the GPU, we now
cast to floats. We also cast to floats whenever we're doing more precise
math (i.e. mouse offset calculation). In this case, we're only
converting to floats from a integral type which is going to be much
safer and less prone to uncertain rounding than converting to an int
from a float type.

Fixes #177
2023-07-03 11:23:20 -07:00
Mitchell Hashimoto
9968128da9 fix failing test on non-Mac 2023-07-01 15:17:50 -07:00
Mitchell Hashimoto
1d1b868958 font: do not use Noto on macOS for tests, it doesn't work 2023-07-01 13:51:31 -07:00
Mitchell Hashimoto
3795cd6c2d font: turn rasterization options into a struct, add thicken 2023-07-01 09:55:19 -07:00
Mitchell Hashimoto
d39e3f5428 coretext: improved baseline calculation 2023-07-01 09:23:40 -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
ce86c64b42 update zig, src for loops 2023-02-27 21:46:42 -08:00
Mitchell Hashimoto
bf054e5b44 font: web canvas sprite font can write to atlas 2022-12-13 22:01:13 -08:00
Mitchell Hashimoto
c9755f5fd1 font: mostly empty web canvas sprite renderer, but compiles 2022-12-13 21:19:40 -08:00
Mitchell Hashimoto
a1dda2c37f font: faceFromIndex returns a pointer to the face 2022-12-12 21:34:34 -08:00
Mitchell Hashimoto
62990bb33e font: Group is now wasm-compatible 2022-12-05 20:52:03 -08:00
Mitchell Hashimoto
2a74330911 font: begin making Group work with wasm 2022-12-05 16:08:20 -08:00
Mitchell Hashimoto
f871630fa4 move Atlas to font 2022-11-28 10:35:46 -08:00
Mitchell Hashimoto
b34e336c5c rearrange box rendering to prepare for more sprite drawing 2022-11-27 10:17:12 -08:00
Mitchell Hashimoto
4cac375fcf more 2022-11-25 15:22:59 -08:00
Mitchell Hashimoto
d2727b1f5c more wedges 2022-11-25 15:18:36 -08:00
Mitchell Hashimoto
120dfb4043 more wedges 2022-11-25 15:12:34 -08:00
Mitchell Hashimoto
2c9b3e2f9b wedge triangles 2022-11-25 15:02:12 -08:00
Mitchell Hashimoto
7676c1c52b sextants 2022-11-25 14:41:17 -08:00
Mitchell Hashimoto
781571d7fb braille 2022-11-25 14:26:19 -08:00
Mitchell Hashimoto
f727b30ca6 more box fonts 2022-11-25 13:36:26 -08:00
Mitchell Hashimoto
cb8f55229b remove test code 2022-11-24 10:21:27 -08:00