aboutsummaryrefslogtreecommitdiff
path: root/font/src/darwin/mod.rs
AgeCommit message (Collapse)Author
2018-11-10Upgrade Glutin to v0.19.0Matt Keeler
Some changes include: • Use the with_hardware_acceleration function on the ContextBuilder to not require the discrete GPU • Remove the LMenu and RMenu virtual key codes (winit 0.16.0 removed these because Windows now generates LAlt and RAlt instead • Replace set_cursor_state with hide_cursor (winit 0.16.0 removed the set_cursor_state function) • Replace GlWindow::hidpi_factor with GlWindow::get_hidpi_factor and change to expecting an f64 • Use the glutin/winit dpi size and position types where possible Glutin's dpi change event has been implemented. All size events now return logical sizes. As a result of that, the logical sizes are translated in the `display::handle_rezize` method so DPI scaling works correctly. When the DPI is changed, the glyph cache is updated to make use of the correct font size again. Moving a window to a different screen which is a different DPI caused a racing condition where the logical size of the event was sent to the `handle_resize` method in `src/display.rs`, however if there was a DPI change event before `handle_resize` is able to process this message, it would incorrectly use the new DPI to scale the resize event. To solve this issue instead of sending the logical size to the `handle_resize` method and then converting it to a physical size in there, the `LogicalSize` of the resize event is transformed into a `PhysicalSize` as soon as it's received. This fixes potential racing conditions since all events are processed in order. The padding has been changed so it's also scaled by DPR. The `scale_with_dpi` config option has been removed. If it's not present a warning will be emitted. The `winit` dependency on Windows has been removed. All interactions with winit in Alacritty are handled through glutin.
2018-10-16Add support for Windows (#1374)Zac Pullar-Strecker
Initial support for Windows is implemented using the winpty translation layer. Clipboard support for Windows is provided through the `clipboard` crate, and font rasterization is provided by RustType. The tty.rs file has been split into OS-specific files to separate standard pty handling from the winpty implementation. Several binary components are fetched via build script on windows including libclang and winpty. These could be integrated more directly in the future either by building those dependencies as part of the Alacritty build process or by leveraging git lfs to store the artifacts. Fixes #28.
2018-09-19Update core-* dependenciesJeff Muizelaar
The core-* dependencies have been updated and every breaking change has been resolved. These are the main changes which required adaption: - font_path() returns a PathBuf now - get_descriptors() returns an Option<CFArray> - get_advances_for_glyphs and get_glyphs_for_characters are now unsafe. All packages which did not have breaking updates have also been updated.
2018-09-17Fix style issuesMatthias Krüger
2018-07-25Fix clippy lints and run font tests on travisMatthias Krüger
This fixes some existing clippy issues and runs the `font` tests through travis. Testing of copypasta crate was omitted due to problens when running on headless travis-ci environment (x11 clipboard would fail).
2018-07-01Fix clippy issuesChristian Duerr
2018-06-17Move to cargo clippyChristian Duerr
Using clippy as a library has been deprecated, instead the `cargo clippy` command should be used instead. To comply with this change clippy has been removed from the `Cargo.toml` and is now installed with cargo when building in CI. This has also lead to a few new clippy issues to show up, this includes everything in the `font` subdirectory. This has been fixed and `font` should now be covered by clippy CI too. This also upgrades all dependencies, as a result this fixes #1341 and this fixes #1344.
2018-02-07fix fallbacks in macos (#1099)Joe Moon
fixes #1086
2018-01-31Update core-text (#1061)Jeff Muizelaar
This cleans up a bunch of code.
2017-12-24Refactor darwin codeChristian Duerr
The ascent calculation on darwin was more complicated than it needed to be. By running a `.ceil()` instead of adding one, checking if it's 0, substracting if it is, and then flooring it, a few instructions could be shaved off.
2017-12-24Add custom box cursor for unfocused windowChristian Duerr
2017-12-24Format cursor code and add documentationChristian Duerr
As requested a few comments have been added to the darwin code. There also was an off by one error in the ascent calculation which has been corrected. The beam cursor width has also been tweaked to be slightly slimmer in general. All code added in this PR has also been run through the default rustfmt to make sure the formatting is okay.
2017-12-24Add custom cursors for macosChristian Duerr
The macos target now also supports the custom beam and underline cursors. The only thing left for this is now is testing and making sure it works with tiny fonts.
2017-12-23Update euclid to v16Chet Gurevitch
2017-12-22Remove debug printJoe Wilm
2017-12-22Fix macOS fallbacks (#956)Joe Wilm
The cascade list is now generated from Menlo for all fonts. This doesn't feel correct to me, but it seems to give the expected behavior on macOS. One of the problems cited was that certain glyphs like ❯ would not be rendered with default cascade lists for some fonts.
2017-10-08Scale all fonts based on device-pixel-ratioJoe Wilm
Rather than use DPI from config, use device-pixel-ratio from winit. This is computed using the display DPI anyhow, so it should have the same effect.
2017-07-28font: update macOS core-text dependency to 6.1.0, fixes #685 (#692)Martin Lindhe
2017-06-06changes osx fallback symbol font styleJames A Keene
Previously, the fallback symbol font copied the style of the font from the config. However, the only available style for the fallback symbol font is Normal slant, Normal weight.
2017-06-06macOS use system font fallbackMartin Algesten
2017-06-01final core-graphics extensions moved upstreamMartin Algesten
2017-05-31remove code that has been upstreamedMartin Algesten
2017-05-31updated some font depsMartin Algesten
2017-05-06Fix sign error in CoreText font rasterizerJoe Wilm
Descent was being reported as a positive value instead of negative. This caused the background and text alignment to be off dramatically. Resolves #545
2017-05-06Fix glyph offsets in cellJoe Wilm
We previously had a hard-coded value for aligning glyphs within cells. The font descent is now used, and the offset should be correct by default.
2017-05-01Remove unnecessary size argument to metrics functionAaron Williamson
The changes to metric consumption rendered the size argument unnecessary, remove it.
2017-01-23Use the log-crate instead of printing to stdoutLukas Lueg
2017-01-12add suggestive fallback messages on unavailable fontsTom Crayford
as per https://github.com/jwilm/alacritty/issues/39
2017-01-12make thin stroke rendering configurableTom Crayford
Makes thin stroke rendering for darwin configurable by a new toplevel key under `font:` in the config file. Defaults to false, has no impact on non macos.
2017-01-02Rework font loadingJoe Wilm
This work started because we wanted to be able to simply say "monospace" on Linux and have it give us some sort of font. The config format for fonts changed to accomodate this new paradigm. As a result, italic and bold can have different families from the normal (roman) face. The fontconfig based font resolution probably works a lot better than the CoreText version at this point. With CoreText, we simply iterate over fonts and check it they match the requested properties. What's worse is that the CoreText version requires a valid family. With fontconfig, it will just provide the closest matching thing and use it (unless a specific style is requested).
2016-12-31Propagate font rasterizer errorsJoe Wilm
This allows consumers of the font crate to handle errors instead of the library panicking.
2016-12-16Misc formatting fixesJoe Wilm
2016-11-19Add support for recording/running ref testsJoe Wilm
Ref tests use a recording of the terminal protocol and a serialization of the grid state to check that the parsing and action handling systems produce the correct result. Ref tests may be recorded by running alacritty with `--ref-test` and closing the terminal by using the window "X" button. At that point, the recording is fully written to disk, and a serialization of important state is recorded. Those files should be moved to an appropriate folder in the `tests/ref/` tree, and the `ref_test!` macro invocation should be updated accordingly. A couple of changes were necessary to make this work: * Ref tests shouldn't create a pty; the pty was refactored out of the `Term` type. * Repeatable lines/cols were needed; on startup, the terminal is resized * by default to 80x24 though that may be changed by passing `--dimensions w h`. * Calculating window size based on desired rows/columns and font metrics required making load_font callable multiple times. * Refactor types into library crate so they may be imported in an integration test. * A whole bunch of types needed symmetric serialization and deserialization. Mostly this was just adding derives, but the custom deserialization of Rgb had to change to a deserialize_with function. This initially adds one ref test as a sanity check, and more will be added in subsequent commits. This initial ref tests just starts the terminal and runs `ll`.
2016-08-12Support bold/italic font rendering on macOSJoe Wilm
This patch adds support for rendering italic fonts and bold fonts. The `font` crate has a couple of new paradigms to support this: font keys and glyph keys. `FontKey` is a lightweight (4 byte) identifier for a font loaded out of the rasterizer. This replaces `FontDesc` for rasterizing glyphs from a loaded font. `FontDesc` had the problem that it contained two strings, and the glyph cache needs to store a copy of the font key for every loaded glyph. `GlyphKey` is now passed to the glyph rasterization method instead of a simple `char`. `GlyphKey` contains information including font, size, and the character. The rasterizer APIs do not define what happens when loading the same font from a `FontDesc` more than once. It is assumed that the application will track the resulting `FontKey` instead of asking the font to be loaded multiple times.
2016-08-03Add support for CGContextSetFontSmoothingStyleJoe Wilm
This enables narrower rendering of glyphs and it tends to look a bit better. iTerm2 and Terminal both do this.
2016-07-12Remove noisey printing on macOSJoe Wilm
2016-06-29Add license headers to source filesJoe Wilm
2016-06-24Fix subpixel rendering for macOSJoe Wilm
This adds a bunch of APIs to CGContext (and supporting types) that aren't actually necessary to turn on subpixel rendering. The key for subpixel rendering were the options passed to bitmap_context_create(). Specifically, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host are necessary to enable it.
2016-06-14Add support for macOSJoe Wilm
Alacritty now runs on macOS using CoreText for font rendering. The font rendering subsystems were moved into a separate crate called `font`. The font crate provides a unified (albeit limited) API which wraps CoreText on macOS and FreeType/FontConfig on other platforms. The unified API differed slightly from what the original Rasterizer for freetype implemented, and it was updated accordingly. The cell separation properties (sep_x and sep_y) are now premultiplied into the cell width and height. They were previously passed through as uniforms to the shaders; removing them prevents a lot of redundant work. `libc` has some differences between Linux and macOS. `__errno_location` is not available on macOS, and the `errno` crate was brought in to provide a cross-platform API for dealing with errno. Differences in `openpty` were handled by implementing a macOS specific version. It would be worth investigating a way to unify the implementations at some point. A type mismatch with TIOCSCTTY was resolved with a cast. Differences in libc::passwd struct fields were resolved by using std::mem::uninitialized instead of zeroing the struct ourselves. This has the benefit of being much cleaner. The thread setup had to be changed to support both macOS and Linux. macOS requires that events from the window be handled on the main thread. Failure to do so will prevent the glutin window from even showing up! For this reason, the renderer and parser were moved to their own thread, and the input is received on the main thread. This is essentially reverse the setup prior to this commit. Renderer initialization (and thus font cache initialization) had to be moved to the rendering thread as well since there's no way to make_context(null) with glx on Linux. Trying to just call make_context a second time on the rendering thread had resulted in a panic!.