Use Core Text on macOS, remove runtime dependencies for linux release binary
I hope issue #10 will disappear after finish this.
This PR need two part of work:
1. For macOS: Use Core Text API to match and render font
Due to servo-fontconfig-sys do not compile static library itselfs on macOS.(servo/libfontconfig#53)
TODO List for this goal:
- [x] Extract font match logic as a trait
- [x] fontconfig impl the matcher trait
- [x] Make a core-text font match api wrapper
- [x] Adjust Font/Family struct to use
Cowto support owned string type - [x] fontconfig matcher trait impl update as Font/Family struct has changed
- [x] core-text api impl the matcher trait
- [x] diff with fontconfig result
- [x] ~~figure out how to get font face index(opend question in Apple Developer Forum)~~
- [x] Extract font render logic as a trait
- [x] FreeType impl render trait
- [ ] Make a core-text font render api wrapper
- [ ] core-text api impl the render trait
Now the list font and preview in browser should works fine in macOS without fontconfig installed.
freetype-sys support static link, so manual install from brew is not required too.
The only missing part is: freetype needs index to load font from file, but Core Text API seems do not provide this attribute, So tui preview not work for now.
Maybe we need adjust render logic to support Core Text Glyph Renderer too...... I'm not sure for now. I will pause work on this part before I figure out how to get index or have enough time to do a renderer refactor.
2020/05/31: I decide to use Core Text as Render Engine in macOS. I just recently made a abstract layer to support different engines and adapted FreeType to this layer, it works well. I think I will implement Core Text Render logic in next weekends.
2. For Linux: Static link to fontconfig and freetype
TODO List for this goal:
- [x] waiting for servo/rust-freetype#60 be merged
- [x] waiting for servo/rust-freetype#60 be published (0.6.0 is pushed, but not be published to crates.io)
- [x] update freetype version
- [x] make a patch(7sDream/libfontconfig@0582646d66f2470b04c1ab513dd33feb7049ebf2) to make servo/libfontconfig use dep built static library
- [ ] waiting for servo/libfontconfig#54 be merged
- [ ] waiting for servo/libfontconfig#54 be published
- [ ] update servo-fontconfig-sys version
Now this goal works well by using ~~deps' git master version and~~ my patched fork.
But I think we need to wait for upstream merge/publish those change and upgrade deps to that official version to make a stable release.