8000 Support for Font Ligatures using Harfbuzz on Linux by thunderseethe · Pull Request #2677 · alacritty/alacritty · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support for Font Ligatures using Harfbuzz on Linux #2677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 101 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
2d59156
Add harfbuzz-freetype support
Mar 16, 2019
ab620c9
Fix cargo.lock
anirudhb Mar 16, 2019
bc7d5e4
Refine harfbuzz shaping more, now vaguely resembles the real text.
anirudhb Mar 16, 2019
1218fab
Fix clippy errors
anirudhb Mar 16, 2019
a2ab0cc
Break everything
anirudhb Mar 31, 2019
f28f6fe
Rendering is normal but font ligatures still don't work
Jul 3, 2019
5df92b4
whitespace funky.
Jul 3, 2019
79facbc
Tried setting scale and ppem but it didn't change anything.
Jul 4, 2019
662fbe5
Switch to harfbuzz_rs and change GlyphKey to use a char or glyph_index
Jul 9, 2019
e1e33c8
Looking into why whitespace is rendering is incorrectly
Jul 9, 2019
a4084bc
Place holder commit to check something in master. Just more debugging…
Jul 9, 2019
146f824
Replace sequence of maps with an iterator that produces text runs.
Jul 10, 2019
a3f8d65
Created new TextRun struct to represent the idea of a run of text tha…
Jul 13, 2019
87df12b
Create render_text_run function on Renderer, this pushes call to hb s…
Jul 13, 2019
a54de7b
cache now exposes shape method that calls underlying rasterizer shape…
Jul 17, 2019
03daff8
Cleaned up opt_pair impl
Jul 24, 2019
dea2a41
Remove cloning of rc.inner by introducing RunStart struct that hold m…
Jul 24, 2019
09a6f9b
Store string of rendered chars and zero width chars in text run.
Jul 24, 2019
88f334d
Replace render_string's calls to render_cell with call to render_text…
Jul 24, 2019
09755da
Clean up warning and remove some code that is no longer used.
Jul 24, 2019
7c3896b
Clean up some of the code that is no longer needed and swap GlyphKey …
Jul 24, 2019
dd69ce6
Fix build with hb-ft feature turned off.
Jul 25, 2019
cf777a1
Clean up superfluous changes from rustfmt that clutter PR.
Jul 25, 2019
d3513f3
Continuing clean up of PR.
Jul 26, 2019
a32a835
Removed HbError and related code. Fixed errors were chars were being …
Jul 26, 2019
de83c0b
Added documentation to the text_run module.
Jul 26, 2019
4bfedf0
Further clean up to reduce code in PR.
Jul 26, 2019
54c3c97
Merge branch 'master' into font-ligatures
Jul 26, 2019
f1b5388
Fix build error in cursor.rs when hb-ft feautre is off
Jul 26, 2019
d970528
Merge branch 'font-ligatures' of https://github.com/thunderseethe/ala…
Jul 26, 2019
b3b8a40
Update Cargo.lock to 0.2.60 inline with main repo lock file
Jul 26, 2019
244a3a6
Remove hb-ft from default feature list in alacritty_terminal
Jul 26, 2019
84c62e7
Resolve bug with strikethrough and underlining. Add logic in TextRunI…
Jul 27, 2019
6447ef8
Able to fallback to loading a font if shaping fails to find a glyph. …
Jul 27, 2019
5f53cc4
Resolved issue with cursor not rendering, need to load an explicit gl…
Jul 27, 2019
70024db
Wide characters now render properly. Last item is to look at cleaning…
Jul 27, 2019
2935bf4
Resolve clippy error, remove hb-ft feature from default list to hopef…
Jul 28, 2019
d2076ae
Add use_font_ligatures conifg option, toggles clig and liga harfbuzz …
Jul 31, 2019
d6287c3
Merge branch 'master' into font-ligatures
Aug 1, 2019
cc34439
Merge branch 'master' into font-ligatures
Aug 5, 2019
3ceaf9c
Moved text_run mod to it's own folder, fixed update_lines_text_run() …
Aug 7, 2019
ef3a5a9
Ran formatter over new changes in code. Added line to CHANGELOG.md
Aug 7, 2019
677a439
Merge branch 'master' into font-ligatures
Aug 7, 2019
73e8a88
Resolve merge conflict in rects.rs
Aug 7, 2019
d04e706
Merge in latest changes to rects (now lines).
Aug 7, 2019
e392c88
Fix clippy errors. Remove extraneous parameters from lines.update() f…
Aug 7, 2019
3f1f25d
Remove "hb-ft" from default feature list.
Aug 7, 2019
499fe03
Cargo fmt code, fix residual clippy errors in ansi.rs
Aug 9, 2019
e423a08
Reduce scope of hb-ft feature, replace with linux toggled cfg
Aug 11, 2019
922cd41
Resolving review comments in text_run and ft
Aug 11, 2019
c7c6341
Run fmt over refactored code.
Aug 11, 2019
549acfc
Change cell_iter() -> cells() at unchanged callsites.
Aug 11, 2019
cd5201e
Don't update strikethrough and underline for hidden runs.
Aug 11, 2019
3677669
Need to rework handling of hidden text.
Aug 11, 2019
1708927
Fix rendering of hidden text based on broken.txt
Aug 17, 2019
a181714
Move code for hidden glyphs outside of render_text_run and format code.
Aug 17, 2019
438c4e7
Merge branch 'master' into font-ligatures
Aug 17, 2019
9a75eda
Remove changes to ansi.rs after file was updated to comply with clippy.
Aug 17, 2019
70edadd
Fix typos in documentation, remove custom Debug impls for TextRun
Aug 17, 2019
bb57c4a
Fix for compilation on windows and mac osx
Aug 18, 2019
601724e
Fix typo bee -> be
Aug 18, 2019
9b3e7f9
Fix windows build
Aug 27, 2019
6c7b88e
Run cargo fmt over the changes.
Aug 27, 2019
e012b4c
Merge branch 'master' into font-ligatures
Aug 27, 2019
0ca96c3
Resolve build error introduced by bold_italic merge.
Aug 27, 2019
aff6bfe
Resolve build errors on macos
Aug 27, 2019
af57cb9
Pull in updates from master and fix for windows.
Aug 27, 2019
a8b8f4e
Replace use_thin_strokes method call with field access.
Aug 27, 2019
14b1b6c
Fix test code for macosx
Aug 27, 2019
68ca294
Merge branch 'master' of https://github.com/jwilm/alacritty into font…
Sep 5, 2019
168c0bf
initial fix for selection issue, but it needs some cleaning up. curre…
Sep 5, 2019
79ef496
Resolving review comments, mainly minor cleanup and renamings.
Sep 10, 2019
8a36143
Pull master and resolve conflict in Cargo.lock
Sep 10, 2019
dd2f870
Fix build errors on mac and windows.
Sep 10, 2019
2034c7b
Continue fixing up the codebase and making refactorings. Changes PLAC…
Sep 10, 2019
54c33c7
Fix for windows and mac osx
Sep 10, 2019
715263a
Refactor text_run for clarity of intent and clean up dead code.
Sep 10, 2019
ecec6ef
Introduce placeholder keytype to represent a glyph that should render…
Sep 11, 2019
853619f
Fix error returned for missing placeholder glyph. Refactor hidden_gly…
Sep 11, 2019
ecfb55d
Merge branch 'master' into font-ligatures
Sep 18, 2019
adc929c
Merge changes from upstream master.
Sep 20, 2019
1a4d7e0
Responding to review comments. Minor cleanups.
Sep 20, 2019
37ff931
Remove RenderLines in favor of converting TextRun directly RenderRect's.
Sep 20, 2019
282adae
Rename KeyType Fallback to Char
Sep 20, 2019
5411fda
Update comment on HbFtExt.
Sep 20, 2019
717ca23
Resolve merge conflict in CHANGELOG
Sep 20, 2019
38d4eec
Actually resolve merge conflict in CHANGELOG
Sep 20, 2019
fd1bcc3
Update Char for windows and mac osx
Sep 20, 2019
226e2d0
Update comment on KeyType
Sep 21, 2019
ab75676
Refactor iter_from_text_run to be from_text_run and move flag checkin…
Sep 21, 2019
3980857
Pull master and merge
Sep 23, 2019
91e0606
Fix render_string to render as expected
Sep 26, 2019
6f0454d
Update CHANGELOG and format recent changes.
Sep 26, 2019
f7d0b4a
Resolving review comments, mainly renaming
Sep 26, 2019
0113097
Fix call to from_iter_state that wasn't renamed. Avoid allocating Vec…
Sep 26, 2019
7da599a
Clean up directwrite code and remove keytype_unwrap_char
Sep 26, 2019
816ec2f
Create text_runs method on terminal to replace renderable_cells
Oct 3, 2019
cd515dc
Merge branch 'master' of https://github.com/jwilm/alacritty into font…
Oct 3, 2019
8e619b7
Format TextRun changes
Oct 7, 2019
74c3432
Merge in config overhaul and from upstream
Oct 7, 2019
b293d08
Tidy up merge and ensure build behaves as expected
Oct 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Completions for `--class` and `-t` (short title)
- Change the mouse cursor when hovering over the message bar and its close button
- Support combined bold and italic text (with `font.bold_italic` to customize it)
- Font Ligatures on Linux/BSD
- Extra bindings for F13-F20
- Terminal escape bindings with combined modifiers
- Bindings for ScrollToTop and ScrollToBottom actions
Expand Down
35 changes: 35 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions alacritty/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ use alacritty_terminal::event::{Event, OnResize};
use alacritty_terminal::index::Line;
use alacritty_terminal::message_bar::MessageBuffer;
use alacritty_terminal::meter::Meter;
use alacritty_terminal::renderer::rects::{RenderLines, RenderRect};
use alacritty_terminal::renderer::rects::{RenderRect};
use alacritty_terminal::renderer::{self, GlyphCache, QuadRenderer};
use alacritty_terminal::term::color::Rgb;
use alacritty_terminal::term::{RenderableCell, SizeInfo, Term};
use alacritty_terminal::term::{cell::Flags, SizeInfo, Term};
use alacritty_terminal::text_run::TextRun;

use crate::config::Config;
use crate::event::{FontResize, Resize};
Expand Down Expand Up @@ -244,7 +245,7 @@ impl Display {
config: &Config,
) -> Result<(GlyphCache, f32, f32), Error> {
let font = config.font.clone();
let rasterizer = font::Rasterizer::new(dpr as f32, config.font.use_thin_strokes())?;
let rasterizer = font::Rasterizer::new(dpr as f32, config.font.use_thin_strokes(), config.font.ligatures())?;

// Initialize glyph cache
let glyph_cache = {
Expand Down Expand Up @@ -362,7 +363,7 @@ impl Display {
message_buffer: &MessageBuffer,
config: &Config,
) {
let grid_cells: Vec<RenderableCell> = terminal.renderable_cells(config).collect();
let grid_text_runs: Vec<TextRun> = terminal.text_runs(config).collect();
let visual_bell_intensity = terminal.visual_bell.intensity();
let background_color = terminal.background_color();
let metrics = self.glyph_cache.font_metrics();
Expand All @@ -380,26 +381,31 @@ impl Display {
api.clear(background_color);
});

let mut lines = RenderLines::new();
let mut rects: Vec<RenderRect> = Vec::new();

// Draw grid
{
let _sampler = self.meter.sampler();

self.renderer.with_api(&config, &size_info, |mut api| {
// Iterate over all non-empty cells in the grid
for cell in grid_cells {
for text_run in grid_text_runs {
// Update underline/strikeout
lines.update(cell);
if text_run.flags.contains(Flags::UNDERLINE) {
let underline_metrics = (metrics.descent, metrics.underline_position, metrics.underline_thickness);
rects.push(RenderRect::from_text_run(&text_run, underline_metrics, &size_info));
}
if text_run.flags.contains(Flags::STRIKEOUT) {
let strikeout_metrics = (metrics.descent, metrics.strikeout_position, metrics.strikeout_thickness);
rects.push(RenderRect::from_text_run(&text_run, strikeout_metrics, &size_info));
}

// Draw the cell
api.render_cell(cell, glyph_cache);
api.render_text_run(text_run, glyph_cache);
}
});
}

let mut rects = lines.into_rects(&metrics, &size_info);

if let Some(message) = message_buffer.message() {
let text = message.text(&size_info);

Expand Down
18 changes: 17 additions & 1 deletion alacritty_terminal/src/config/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use log::error;
use serde::de::Visitor;
use serde::{Deserialize, Deserializer};

#[cfg(target_os = "macos")]
use crate::config::DefaultTrueBool;
use crate::config::{failure_default, Delta, LOG_TARGET_CONFIG};

Expand Down Expand Up @@ -49,6 +48,11 @@ pub struct Font {
#[cfg(target_os = "macos")]
#[serde(deserialize_with = "failure_default")]
use_thin_strokes: DefaultTrueBool,

/// Toggles rendering of font ligatures
#[cfg(not(any(target_os = "macos", windows)))]
#[serde(deserialize_with = "failure_default")]
ligatures: DefaultTrueBool,
}

impl Default for Font {
Expand All @@ -61,6 +65,8 @@ impl Default for Font {
bold_italic: Default::default(),
glyph_offset: Default::default(),
offset: Default::default(),
#[cfg(not(any(target_os = "macos", windows)))]
ligatures: Default::default(),
#[cfg(target_os = "macos")]
use_thin_strokes: Default::default(),
}
Expand Down Expand Up @@ -102,6 +108,16 @@ impl Font {
pub fn use_thin_strokes(&self) -> bool {
false
}

#[cfg(not(any(target_os = "macos", windows)))]
pub fn ligatures(&self) -> bool {
self.ligatures.0
}

#[cfg(any(target_os = "macos", windows))]
pub fn ligatures(&self) -> bool {
false
}
}

fn default_font_size() -> Size {
Expand Down
17 changes: 12 additions & 5 deletions alacritty_terminal/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::cmp;

use serde::Deserialize;

use font::{Metrics, RasterizedGlyph};
use font::{Metrics, RasterizedGlyph, PLACEHOLDER_GLYPH};

use crate::ansi::CursorStyle;

Expand Down Expand Up @@ -64,7 +64,14 @@ pub fn get_underline_cursor_glyph(width: i32, line_width: i32) -> RasterizedGlyp
let buf = vec![255u8; (width * line_width * 3) as usize];

// Create a custom glyph with the rectangle data attached to it
RasterizedGlyph { c: ' ', top: line_width, left: 0, height: line_width, width, buf }
RasterizedGlyph {
c: PLACEHOLDER_GLYPH,
top: line_width,
left: 0,
height: line_width,
width,
buf,
}
}

// Returns a custom beam cursor character
Expand All @@ -73,7 +80,7 @@ pub fn get_beam_cursor_glyph(height: i32, line_width: i32) -> RasterizedGlyph {
let buf = vec![255u8; (line_width * height * 3) as usize];

// Create a custom glyph with the rectangle data attached to it
RasterizedGlyph { c: ' ', top: height, left: 0, height, width: line_width, buf }
RasterizedGlyph { c: PLACEHOLDER_GLYPH, top: height, left: 0, height, width: line_width, buf }
}

// Returns a custom box cursor character
Expand All @@ -95,7 +102,7 @@ pub fn get_box_cursor_glyph(height: i32, width: i32, line_width: i32) -> Rasteri
}

// Create a custom glyph with the rectangle data attached to it
RasterizedGlyph { c: ' ', top: height, left: 0, height, width, buf }
RasterizedGlyph { c: PLACEHOLDER_GLYPH, top: height, left: 0, height, width, buf }
}

// Returns a custom block cursor character
Expand All @@ -104,5 +111,5 @@ pub fn get_block_cursor_glyph(height: i32, width: i32) -> RasterizedGlyph {
let buf = vec![255u8; (width * height * 3) as usize];

// Create a custom glyph with the rectangle data attached to it
RasterizedGlyph { c: ' ', top: height, left: 0, height, width, buf }
RasterizedGlyph { c: PLACEHOLDER_GLYPH, top: height, left: 0, height, width, buf }
}
1 change: 1 addition & 0 deletions alacritty_terminal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub mod renderer;
pub mod selection;
pub mod sync;
pub mod term;
pub mod text_run;
pub mod tty;
pub mod url;
pub mod util;
Expand Down
Loading
0