aboutsummaryrefslogtreecommitdiff
path: root/font/src/ft
Commit message (Collapse)AuthorAge
...
* Fix linux symbol sizeChristian Duerr2017-12-24
| | | | | | | | | With linux every box, line or underline should now have the pixel-perfect size with any font at any size. This uses the default font to get the size of the monospace box. It assumes that the face 0 is always the primary font, if this is not the case, this will probably break.
* Add custom box cursor for unfocused windowChristian Duerr2017-12-24
|
* Format cursor code and add documentationChristian Duerr2017-12-24
| | | | | | | | | | | | 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.
* Add custom beam cursorChristian Duerr2017-12-24
| | | | | | | | | | | | | | | | | | | | | | | | | | In issue jwilm/asacritty#31 a few people complained about Beam cursor being weird with their fonts, so to make all cursors uniform in alacritty, a custom cursor has been added for the Beam too. The beam cursor's height is always the full height of the monospace font glyph bounding box. The width depends on the font size. It is calculated using the width of the cell and dividing it by two. The block is always aligned at the far-left of the cell. The implementation is identical to the one of the underline cursor, but it has been refactored so the glyphs are created in `lib.rs`, which can be used by darwin/macos to implement these features too. A small bug in the underline cursor has also been fixed, until now the width was just using the width of the unicode character. Now it should be using the full width of the monospace glyph bounding box with every font. Here are some screenshots for the Beam cursor: ![Small](https://u.teknik.io/v1QH3.png) ![Normal](https://u.teknik.io/RTlp2.png) ![Big](https://u.teknik.io/DLu2M.png) ![Huge](https://u.teknik.io/pSAFX.png)
* Revert to old system for macosChristian Duerr2017-12-24
| | | | | | Because rendering with macos works differently, the old underline cursor is used for that. The cursor symbol has also been setup as a constant in the font project.
* Add custom underline cursorChristian Duerr2017-12-24
| | | | | | | | | | | | | | | As mentioned in jwilm/alacritty#931, it can be troublesome if a font has an underline symbol outside of the glyph's bounding box. This can lead to the underline disappearing at the bottom of the terminal. As a solution a symbol from the private use area was used as the character code for the underline symbol. Whenever this symbol is encountered, instead of rendering it, a custom block is rendered. In this implementation the block has the full character as width and sits flush with the bottom of the glyph's bounding box. The height is half the distance between the baseline and the bottom of the bounding box.
* fix some typos in commentsMartin Lindhe2017-10-30
|
* config_subsitute(): fix typo by renaming to config_substitute()Martin Lindhe2017-10-30
|
* Fix memory leak from font resizingJoe Wilm2017-10-14
| | | | | | | | | | | The source of the leak was loading up multiple copies of the FT_face even when not necessary. Fonts are now appropriately cached for FreeType when going through the `Rasterize::load_font` API. Additionally, textures in the glyph cache are now reused. The result of this is that resizing to already loaded fonts is free from a memory consumption perspective.
* Scale all fonts based on device-pixel-ratioJoe Wilm2017-10-08
| | | | | | 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.
* Support bitmap fontsDan Aloni2017-10-08
| | | | | | | | | | | | | | | | | | | | | | | | To allow FontConfig to work with Bitmap font, we shall pass the size we are interested in, and account for the size returned in the font matching process. This is, because we cannot scale those fonts. FontConfig will return the closest match, and we take its returned pixel size back when we are rendering the glyphs. There's an oddity when call set_char_size in TrueType - we need to behave as if the DPI is 72. It is due to the following macro: #define FT_REQUEST_HEIGHT( req ) \ ( (req)->vertResolution \ ? ( (req)->height * (FT_Pos)(req)->vertResolution + 36 ) / 72 \ : (req)->height ) Further work can allow for integer scaling of the largest bitmap font variant. Tested with Terminus PCF-type font under Linux. This addresses issue #582 .
* FreeType rasterizer respects some fontconfigJoe Wilm2017-10-08
| | | | | | | The FreeType rasterizer now reads settings like antialias, rgba, lcdfilter, and hintstyle and chooses FreeType settings accordingly. The result is that Alacritty fonts should look similar to the rest of the system.
* Improve glyph rasterization performanceJoe Wilm2017-10-08
| | | | | | | | | The hash map of key -> face was previouly cloned every time a glyph was rasterized. This refactored the rasterization path to be more borrowck friendly. Sadly, this implementation is not *that* clean, but once NLLs land, much of this can be cleaned up.
* Remove unused macrosJoe Wilm2017-10-08
|
* Extend and improve FcPattern bindingsJoe Wilm2017-10-08
| | | | | | | | | | | | | | | | | | | | The fontconfig `FcPattern` type is wrapped as `fc::Pattern` and `fc::Pattern` ref. All methods for accessing data on the pattern now return an `Iterator`. This API turns out to be much more ergonomic than providing an integer index. We also override the default `nth` implementation of `Iterator` on these accessors to allow random (incremental only) access. For instance, accessing `family` attributes from a pattern: let families = pattern.family(); let second = pattern.nth(1); Or printing available styles for style in pattern.style() { println!("style={}", style); }
* Organize fontconfig wrappersJoe Wilm2017-10-08
| | | | | Each Fc type is split into a separate file. This organization will help as features are added to the bindings.
* remove unused macrosJack O'Connor2017-08-08
| | | | This silences a couple of compiler warnings in the build.
* Use foreign-types from crates.ioJoe Wilm2017-06-27
| | | | | We had previously vendored a very early version of this package before it was ever published.
* Fixes font raster for mono, gray bitmaps (#590)Joe Wilm2017-05-28
| | | | | | | | | | | | | | As it turns out, FreeType does not always provide glyph data in LCD mode as we requested. We now correctly handle several common modes returned from FreeType including Lcd, Mono, and Gray. Note that we don't check number of grays at this time since it's 1. Almost always 256, according to FreeType docs 2. Not available in the Rust FreeType bindings being used Resolves #515 Resolves #185 Resolves #482
* Fix glyph offsets in cellJoe Wilm2017-05-06
| | | | | | 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.
* Remove unnecessary size argument to metrics functionAaron Williamson2017-05-01
| | | | | The changes to metric consumption rendered the size argument unnecessary, remove it.
* Improve freetype metric usageAaron Williamson2017-05-01
| | | | | | The font metrics function was using freetype metrics in an ineffective way, improve the use of those metrics and remove the now unnecessary separate default values for font offset in linux.
* font::fc: Remove unneeded cloneHarlan Lieberman-Berg2017-03-01
|
* font::ft: misc style cleanup.Harlan Lieberman-Berg2017-03-01
|
* Drop unnecessary unsafe on add_charsetHarlan Lieberman-Berg2017-03-01
|
* Switch over to using font_match everywhere.Harlan Lieberman-Berg2017-03-01
|
* Rework font cache to cache on pathsHarlan Lieberman-Berg2017-03-01
| | | | | | | This is done in order to help prevent us from loading the same font face over and over again under separate keys. We still incur the performance hit of doing the fontconfig search each new glyph, but that's unavoidable without more extensive refactoring.
* First pass of font fallback renderingHarlan Lieberman-Berg2017-03-01
|
* Fix fc::Pattern::add_charsetJoe Wilm2017-03-01
| | | | | The lifetime constraints didn't do what I thought, and such constraints turn out to be unnecessary anyhow.
* PoC find font with glyphJoe Wilm2017-03-01
|
* Use the log-crate instead of printing to stdoutLukas Lueg2017-01-23
|
* add suggestive fallback messages on unavailable fontsTom Crayford2017-01-12
| | | | as per https://github.com/jwilm/alacritty/issues/39
* make thin stroke rendering configurableTom Crayford2017-01-12
| | | | | | 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.
* Rework font loadingJoe Wilm2017-01-02
| | | | | | | | | | | | | | 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).
* Propagate font rasterizer errorsJoe Wilm2016-12-31
| | | | | This allows consumers of the font crate to handle errors instead of the library panicking.
* Add ffi-util crate and use in fontconfig wrapperJoe Wilm2016-12-30
| | | | This cleans up and fixes the C-type wrapping for fontconfig.
* Refactor FontConfig wrappersJoe Wilm2016-12-30
| | | | | | | | There's now a proper wrapper in place for working with the FontConfig library. This should help significantly with error handling with font loading; at least, the FontConfig code shouldn't panic. The FreeType rasterizer still needs to be updated to handle missing fonts, and a more sensible default font should be specified.
* Misc formatting fixesJoe Wilm2016-12-16
|
* Replace remaining use of `try!` with `?`Joe Wilm2016-12-16
|
* Add support for recording/running ref testsJoe Wilm2016-11-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* Support bold/italic font rendering on LinuxJoe Wilm2016-08-14
| | | | | | The FreeType font Rasterizer API is updated to match the CoreText Rasterizer. This enabled bold/italic fonts since the rest of the codebase has already been updated.
* Add license headers to source filesJoe Wilm2016-06-29
|
* Add support for macOSJoe Wilm2016-06-14
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!.