1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 22:01:47 +03:00
Commit Graph

345 Commits

Author SHA1 Message Date
Pi-Cla
ee61e61e4f
[PATCH] Fix various cargo audit errors
closes: https://github.com/wez/wezterm/pull/5206
2024-05-04 22:47:57 -07:00
Wez Furlong
67d4ba9f76
fix when running on rust 1.78
std::slice::from_raw_parts will now panic if the ptr is null.
Resolve this by adding our own wrapper that translates that
case to an empty slice.
2024-05-04 15:53:28 -07:00
Wez Furlong
a77ff4b846
fix some warnings with newer rust
The warning is that some of the variants are never read.
In the case of ftwrap, they are referenced via ffi.
For the other locations, we want them for debug purposes.
2024-04-28 19:54:54 -07:00
Wez Furlong
21af10e0f6
be smarter about NO_HINTING
Only use it when we think the dpi is high, otherwise use the
default freetype parameters.

refs: https://github.com/wez/wezterm/issues/4908
refs: https://github.com/wez/wezterm/issues/4902
2024-01-31 07:55:10 -07:00
Wez Furlong
c4f16fe339
macos: constrain fallback to normal attributes
refs: https://github.com/wez/wezterm/issues/4808
2024-01-29 20:02:54 -07:00
Wez Furlong
c75c15b9ca
macos: fall back to old font fallback approach
In https://github.com/wez/wezterm/issues/4877 it became clear that
the newer approach for finding fallback fonts is only better than
the old approach in some cases, so this commit adds a fallback
to the old approach if the new one didn't yield any usable results
for a given codepoint.

refs: #4099
2024-01-28 16:19:58 -07:00
Wez Furlong
e23ab47239
macos: ignore LastResort font in fallback suggestions
refs: https://github.com/wez/wezterm/issues/4877
2024-01-27 23:28:20 -07:00
Xiaopeng Li
a84e5fedb1 impl FT_PIXEL_MODE_LCD_V 2024-01-23 06:26:28 -07:00
Wez Furlong
ba85958a61
deps: update env-logger
Note that we are pinned on 0.10 for env-bootstrap, where we use it
only for its module filter parser.
2024-01-20 16:01:10 -07:00
Daniel Koukola
9a5af15323 Fix freetype_load_target 2024-01-11 06:54:51 -07:00
Wez Furlong
c75f20f21c
deps: ordered-float -> 4.1.0
closes: https://github.com/wez/wezterm/pull/4338
2023-09-28 14:39:22 -07:00
Wez Furlong
50cc44a53a
font-config: failed to resolve clusters like 3065,2686
Root cause is that font-config will try to find a single font that
satisfies a query like `fc-list ':charset=2686 3065'`, but if that
is impossible, there are no results.

The resolution is to split the query up and look for each individual
codepoint.

refs: #4310
2023-09-20 18:54:17 -07:00
Wez Furlong
70931f58f1
fonts: improve categorization, selection of pcf fonts
Match out bold, semicondensed etc. from the full name.

Allow matching a font based on the full path to the font as
an alternative, because pcf fonts tend to have terrible
metadata and many pixel variants.

refs: https://github.com/wez/wezterm/issues/4256
2023-09-11 07:58:10 -07:00
Wez Furlong
d35f067deb
hbwrap: fix compilation on aarch64
refs: https://github.com/wez/wezterm/issues/4213
2023-08-28 06:39:14 -07:00
Wez Furlong
551af58637
font: refactor: extract ClusterResolver to file scope 2023-08-28 06:39:14 -07:00
Wez Furlong
ce7e5a2799
font: hbwrap: add harfbuzz caret API 2023-08-28 06:39:14 -07:00
Wez Furlong
c91e124f41
fonts: fix potential panic for bitmap space glyphs with 0 size 2023-08-22 23:34:08 -07:00
Wez Furlong
e4ea6a6c4b
fonts: capture palette info when parsing fonts 2023-08-22 19:12:47 -07:00
Wez Furlong
67f4450d8f
fonts: detect colr glyphs better
Freetype's support for colr is relatively rudimentary, which is fine,
but we want more control, so we probe a bit harder to figure out
whether a glyph has colr information before allowing freetype
to rasterize it, so that we have the opportunity to reroute
that rendering to our own logic.
2023-08-22 07:35:55 -07:00
Wez Furlong
7af61159a8
font: port over radial gradient fills 2023-08-22 06:43:58 -07:00
Wez Furlong
85bb023295
font: refactor: extract common function 2023-08-21 09:40:24 -07:00
Wez Furlong
dd6f2a4d7f
fonts: stub out sweep gradient 2023-08-21 09:38:18 -07:00
Wez Furlong
40083f55b8
font: refactor: reuse ColorLine and gradient structs 2023-08-21 09:30:40 -07:00
Wez Furlong
01fd28fc02
refactor: extract colr from freetype -> colr.rs 2023-08-21 09:19:22 -07:00
Wez Furlong
64dd96917d
fonts: repurpose experimental_svg_fonts -> ignore_svg_fonts
Now we can optionally skip loading svg fonts, making our default
to continue to try to use them.

We don't actually support interpreting svg data, but we do now
support COLR v1 data which is found in some of those same fonts.

refs: https://github.com/wez/wezterm/issues/4148
2023-08-20 22:59:22 -07:00
Wez Furlong
e1044a6d5f
font: colr: add font_colr_rasterizer option
The harfbuzz driven rasterization of COLR glyphs is superior to
my attept at a freetype driven rasterizer, so let's default to
the harfbuzz version.

This change means that the default for most regular glyphs is
freetype, but we'll use harfbuzz for COLR glyphs.
2023-08-20 22:55:02 -07:00
Wez Furlong
017432d0cf
freetype: colr: fixup crazy scaling issue in char selector
Popping open the char selector could result in comedy-sized emoji
that dramatically overflow the bounds.

The reason for that is that glyphcache isn't smart enough to notice
when the glyph.height exceeds the cell_height and allows the glyph
bitmap to be rendered at the rasterized size.

The reason for that glyph being so huge is that freetype is producing
outlines that are too large.  The font metrics have the requested
x and y ppem values (eg: the nominal font size in pixels), but also
x and y scaling values that are not set to 1.  The result is that
the produced extents are too large by those x and y scaling values.

I'm not sure why that is, but it is simplest and most self-contained
to adjust for that scale factor when we rasterize via cairo, so that
is what we do here.
2023-08-20 19:55:56 -07:00
Wez Furlong
b6ba87ad3c
fonts: tidy up some warnings 2023-08-20 17:46:34 -07:00
Wez Furlong
8f4f9653c5
font: adjust metrics for pre-scaled bitmap glyphs
When using the harfbuzz rasterizer with a bitmap glyph, the result
is a rasterized glyph that is pre-scaled to the cell dimensions.

We need to tell glyphcache that that has happened, otherwise it
will apply the same scale factor again.
2023-08-20 17:32:42 -07:00
Wez Furlong
84720a18f0
fonts: stick with ft based metrics for now
I think I've got the right values going in and out, so I think
it's ok to turn this on, but I'm worried about legacy non-opentype
formats that freetype supports but harfbuzz doesn't.

Let's stick with ft's metrics until I find time to validate
the behavior.
2023-08-20 16:52:33 -07:00
Wez Furlong
536c3fa4da
rasterizer/freetype: tune debug logging 2023-08-20 15:31:33 -07:00
Wez Furlong
7264030a28
fonts: adopt fixed crate for freetype fixed-point math
This found at least one bug and should prevent future bugs.
2023-08-20 15:19:30 -07:00
Wez Furlong
1ed4058741
fonts: add freetype COLR 1 raster impl
This isn't fully baked, but it looks mostly ok.
The ghost emoji has a weirdly positioned white patch; there's
something funky with its positioning that needs to be investigated.

There's some copypasta here; a bunch of the cairo related stuff
was copied and adapted from the harfbuzz impl.

I plan to refactor the latter in terms of the former to reduce
the amount of code overall.
2023-08-20 15:19:30 -07:00
Wez Furlong
44e9e09273
font: remove half-baked attempt at rendering svg fonts
It's just too complex. Will focus on COLR 1 instead.
2023-08-20 15:19:30 -07:00
Wez Furlong
6b7ba71f32
fonts: harfbuzz raster: add linear and radial gradients
fixup colors and excessive clipping.

This now looks decent. Still don't support sweep gradients;
those look complex and I'm not sure that I have a font to
test that against.
2023-08-20 15:19:30 -07:00
Wez Furlong
f1c82e8894
fonts: harfbuzz raster: use cairo
This meshes well with the sequence of instructions that we
get from harfbuzz.

This will need some vendoring to integrate with wezterm's build
on all platforms; that can come later.

Still need to hook up gradients.
2023-08-20 15:19:27 -07:00
Wez Furlong
4ddcad7ef6
fonts: harfbuzz raster: rejigger
We need to make a couple of passes over the paint instructions,
and making a nice interface around FontFuncs and DrawFuncs was
taking up a lot of boilerplate.

Adjust so that we accumulate parsed PaintOps and DrawOps instead.

This makes the code smaller and easier to grok.

Still has trouble rasterizing the new noto color emoji font though.
2023-08-20 15:18:10 -07:00
Wez Furlong
75b72c9520
fonts: use harfbuzz ot funcs when shaping
I think this fixes up the discrepancy I had in metrics with images.
The "solution" is to tell harfbuzz to scale to the selected
bitmap strike size instead of the the computed pixel size for
the current settings.
2023-08-20 15:18:10 -07:00
Wez Furlong
25697d406e
font: add helper to swap red/blue channels in an image 2023-08-20 15:18:09 -07:00
Wez Furlong
847b1b7ab9
font: refactor: extract cropping helper 2023-08-20 15:18:09 -07:00
Wez Furlong
560fa1f552
fonts: harfbuzz raster: add basic glyph rendering 2023-08-20 15:18:09 -07:00
Wez Furlong
c7b689e369
fonts: starting building out harfbuzz rasterizer
This seems like it might be a way to get COLR support without
too much effort.

This commit just adds bitmap image support as a first step
2023-08-20 15:18:09 -07:00
Wez Furlong
58a2a30623
Add vendored cairo-sys-rs crate
I'm experimenting with using cairo's 2D graphics for glyph related
drawing operations, and perhaps more stuff in the UI in the future.

The challenge is that no one has yet encapsulated its build in a
cargo-friendly way.

This commit is that attempt.

The strategy is this:

* `deps/cairo` is ostensibly the same thing as https://github.com/gtk-rs/gtk-rs-core/tree/master/cairo/sys
  which is the cairo-sys-rs crate
* Its build.rs has been replaced with a version that builds from the C
  sources that are found in-tree; it will never look for the system
  cairo library
* A pair of scripts to import pixman (a required dep of cairo) and
  cairo itself in a repeatable way are include, for if/when we need
  to update the vendored sources
  Cairo is a mature library and doesn't release very often.
* The workspace sets a patch for crates.io so that cairo-rs has
  its cairo-sys-rs dep redirected to the local build.

I'm not planning to upstream this stuff to gtk-rs-core as full cairo
depends on a lot more things than are dealt with here, so it would be a
PITA to handle that generally.

This vendoring strips out things that are not used, so the cairo
library that remains:

* Is not internally thread safe; no TLS or mutex support is enabled
  in either of them. That's fine because the high level cairo-rs
  wrapper is not Send+Sync, which means that rust will only allow
  it to be used single threaded anyway.
* Only has the basic recording and image surfaces
* No platform support for win32/xlib/xcb and so on
2023-08-20 14:59:29 -07:00
Wez Furlong
b365225695
fonts: svg: half-assed attempt to set the y-bearing
This is not right, but better than not setting it.
2023-08-15 11:27:34 -07:00
Wez Furlong
edbf4ac1e4
add experiemental svg font support
The vertical alignment is wonky, and some glyphs have the wrong
aspect and are missig colors. eg: the watermelon glyph in Noto Color
Emoji (U+1f349).

Turn this off by default, and skip loading fonts that have svg by
default.
2023-08-15 10:33:45 -07:00
Wez Furlong
8c77ea1d9e
fonts: allow svg fonts to take precedence over bitmap versions
But note that we don't currently render svg

refs: https://github.com/wez/wezterm/issues/4148
2023-08-14 20:23:17 -07:00
Wez Furlong
085e8da478
macos: fonts: use alternative fallback approach
The approach we were using previously was to ask macOS for the fallback
font list, but it didn't include the correct fonts for certain
codepoints.

Switch to using an alternative API that asks macOS which font to use for
a specific codepoint.

refs: #4099
2023-08-05 18:15:08 -07:00
Wez Furlong
33187d0e79
macos: fonts: use full list of user fallback languages
The hope was that this would find more fonts, but it doesn't actually
help for this case.

refs: https://github.com/wez/wezterm/issues/4099
2023-08-05 17:33:59 -07:00
Wez Furlong
f5173c48a7
fonts: micro optimize by caching size calcs
Don't ask harfbuzz to recompute on every shaper call, just those
where the size has changed.
2023-05-29 10:36:59 -07:00
Wez Furlong
e4b96bd9bb
update Symbols Nerd Font Mono to v3.0.1 2023-05-21 09:34:10 -07:00