824 Commits

Author SHA1 Message Date
Mitchell Hashimoto
67bb68b39f pkg/macos: RGB color space 2022-10-07 21:07:11 -07:00
Mitchell Hashimoto
c48ddcecd7 pkg/macos: font draw glyphs 2022-10-07 21:04:30 -07:00
Mitchell Hashimoto
61955c5d8d pkg/macos: CGContext 2022-10-07 20:56:24 -07:00
Mitchell Hashimoto
ca7f3647ff pkg/macos: CGColorSpace 2022-10-07 17:59:52 -07:00
Mitchell Hashimoto
fd509a2cb4 TODO for colored and styled underlines 2022-10-06 16:07:48 -07:00
Mitchell Hashimoto
8edf52f832 Add some padding to emoji 2022-10-06 15:45:05 -07:00
Mitchell Hashimoto
a44d4ea33b Fix underline/strikeout position with larger fonts 2022-10-06 15:40:43 -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
4909e0117c Merge pull request #18 from mitchellh/font-metrics
This improves the way we calculate metrics based on fonts to be more accurate. Two practical impacts:

* We now position the underline and underline thickness based on the font metrics
* We now correctly position Apple Emoji font

And I'm going to follow this up with strikethrough since that should be possible now.
2022-10-06 14:14:31 -07:00
Mitchell Hashimoto
3a7e53e2e4 font: calculate correct offset for non-scalable emoji fonts 2022-10-06 14:12:03 -07:00
Mitchell Hashimoto
3b549e0709 more accurately compute font metrics 2022-10-06 11:07:49 -07:00
Mitchell Hashimoto
3d4aacd51d underline is derived from the primary font 2022-10-04 11:08:07 -07:00
Mitchell Hashimoto
c149696f61 redoing some of the baseline calcs, remove from shader 2022-10-04 10:00:32 -07:00
Mitchell Hashimoto
a4e8b5ae8c calculate font metrics per face 2022-10-03 12:31:07 -07:00
Mitchell Hashimoto
3d6ae99fe6 update TODO 2022-10-02 11:27:40 -07:00
Mitchell Hashimoto
c565c561fd Use Apple Emoji font on Mac 2022-10-02 11:20:55 -07:00
Mitchell Hashimoto
939e6e7a65 pkg/harfbuzz: add coretext compilation on macOS 2022-10-02 11:05:40 -07:00
Mitchell Hashimoto
f41cbf228b font: set "backend" enum vs booleans 2022-10-02 09:41:37 -07:00
Mitchell Hashimoto
12c9482d48 Mac Font Discovery with CoreText (#17)
This implements font discovery so the `--font-family` flag works for macOS. Fonts are looked up using the Core Text API so any installed font on the Mac system can be used. 

We still use FreeType for rendering, and CoreText doesn't _quite_ give us all the information we need to build the exact face in FreeType. So a TODO after this is to now implement glyph _rendering_ using Core Text and Core Graphics. Until then, a couple fonts don't quite work (i.e. Monaco, a big one!) but many do!
2022-10-01 22:21:30 -07:00
Mitchell Hashimoto
791739de9c pkg/macos: font initializes, get glyphs 2022-10-01 21:49:02 -07:00
Mitchell Hashimoto
0f34617eab pkg/macos: fix crash when no fonts are found 2022-10-01 21:20:15 -07:00
Mitchell Hashimoto
8292e925fc pkg/macos: fix invalid constant 2022-10-01 21:03:51 -07:00
Mitchell Hashimoto
decbaafc6a pkg/macos: add mutable dictionaries, flesh out font descriptor 2022-10-01 20:50:51 -07:00
Mitchell Hashimoto
20f80c4fb7 Merge pull request #16 from mitchellh/macos
Mac Core Foundation and Core Text Bindings
2022-10-01 16:17:22 -07:00
Mitchell Hashimoto
c6dc2a3529 macos/text: create collection from descriptors 2022-10-01 16:10:50 -07:00
Mitchell Hashimoto
623e7f5916 macos/text: FontTraits 2022-10-01 16:00:52 -07:00
Mitchell Hashimoto
7eb466959a macos/foundation: number, dict get value 2022-10-01 15:49:05 -07:00
Mitchell Hashimoto
3eeef74315 pkg/macos: import headers instead of doing externs manually 2022-10-01 15:24:22 -07:00
Mitchell Hashimoto
57c1d8d329 macos/text: more APIs 2022-10-01 11:25:21 -07:00
Mitchell Hashimoto
88ae3be9ef pkg/macos: CFURL 2022-10-01 11:13:44 -07:00
Mitchell Hashimoto
49c9c21d52 macos: test listing fonts 2022-10-01 11:06:07 -07:00
Mitchell Hashimoto
cb02bab89e macos/text: font descriptors 2022-10-01 10:50:09 -07:00
Mitchell Hashimoto
92d564a246 macos/foundation: more string funcs 2022-10-01 10:32:54 -07:00
Mitchell Hashimoto
2440b0ec67 pkg/macos: dictionary create 2022-10-01 09:53:48 -07:00
Mitchell Hashimoto
d79c8fab39 macos/text: matching font descriptors 2022-09-30 15:13:29 -07:00
Mitchell Hashimoto
93f2a99b64 macos: CFArray 2022-09-30 15:10:11 -07:00
Mitchell Hashimoto
f9e1127317 pkg/macos: add CoreText 2022-09-30 14:48:06 -07:00
Mitchell Hashimoto
b0d9933249 macos: add another string API to test it really works 2022-09-30 14:12:15 -07:00
Mitchell Hashimoto
ab4491a45d pkg/macos: start core foundation bindings 2022-09-30 14:03:37 -07:00
Mitchell Hashimoto
a3d9dad726 fix tests so they pass on mac 2022-09-30 13:24:54 -07:00
Mitchell Hashimoto
68786814f8 -Dtest-exe flag to build and install test executables
This will be used to copy tests to other platforms.
2022-09-30 13:05:23 -07:00
Mitchell Hashimoto
42210e18da update TODO 2022-09-29 15:07:32 -07:00
Mitchell Hashimoto
bf40e05a13 Font discovery on Linux via fontconfig
This adds the `--font-family` set of configuration flags to choose a font that is installed on the system rather than the embedded font in the binary. This uses fontconfig on Linux and only supports Linux at the moment.

Fontconfig is an optional dependency, building with `-Dfontconfig=false` will disable fontconfig and font discovery on all platforms. Fontconfig is only enabled by default on Linux.
2022-09-29 15:01:22 -07:00
Mitchell Hashimoto
53aab0a163 --font-family CLI config 2022-09-29 14:51:31 -07:00
Mitchell Hashimoto
7eac0afff2 cli args can parse null-terminated strings 2022-09-29 14:45:37 -07:00
Mitchell Hashimoto
5567564dd0 cli args fix stage1 miscompilation, add font families 2022-09-29 13:14:20 -07:00
Mitchell Hashimoto
7f45916b89 only discover if it is enabled 2022-09-29 11:58:00 -07:00
Mitchell Hashimoto
b6a4fff6d8 search for fonts on startup 2022-09-29 11:57:29 -07:00
Mitchell Hashimoto
fdbf40d3ee pkg/freetype: disable ubsan 2022-09-29 11:39:09 -07:00
Mitchell Hashimoto
30a5041a38 font Group has Lib, loads deferred faces when needed 2022-09-29 10:30:45 -07:00