diff options
author | Joe Wilm <joe@jwilm.com> | 2016-04-11 08:05:19 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-04-11 08:05:19 -0700 |
commit | e794bc11b962adef4d6fbbaeb85344cb138376da (patch) | |
tree | 71d0442ca31a24fcb3c8e64f7887d35688f2109b /src/main.rs | |
parent | b84eb9e921c040c4eadaabd8f3087690efa267b6 (diff) | |
download | r-alacritty-e794bc11b962adef4d6fbbaeb85344cb138376da.tar.gz r-alacritty-e794bc11b962adef4d6fbbaeb85344cb138376da.tar.bz2 r-alacritty-e794bc11b962adef4d6fbbaeb85344cb138376da.zip |
Use subpixel font rendering
OpenGL only supports shared alpha blending. Subpixel font rendering
requires using the font RGB values as alpha masks for the corresponding
RGB channels. To support this, blending is implemented in the fragment
shader.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index 1845bb94..48aaf11b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ use grid::Grid; static INIT_LIST: &'static str = "abcdefghijklmnopqrstuvwxyz\ ABCDEFGHIJKLMNOPQRSTUVWXYZ\ 01234567890\ - ~`!@#$%^&*()[]{}-_=+\\|\"/?.,<>"; + ~`!@#$%^&*()[]{}-_=+\\|\"/?.,<>;:"; fn main() { let window = glutin::Window::new().unwrap(); @@ -37,12 +37,12 @@ fn main() { let (dpi_x, dpi_y) = window.get_dpi().unwrap(); let dpr = window.hidpi_factor(); - let font_size = 12.0; + let font_size = 11.0; let sep_x = 2; - let sep_y = 2; + let sep_y = 5; - let desc = FontDesc::new("Ubuntu Mono", "Regular"); + let desc = FontDesc::new("DejaVu Sans Mono", "Book"); let mut rasterizer = text::Rasterizer::new(dpi_x, dpi_y, dpr); let (cell_width, cell_height) = rasterizer.box_size_for_font(&desc, font_size); @@ -54,10 +54,35 @@ fn main() { let mut grid = Grid::new(num_rows as usize, num_cols as usize); - grid[0][0] = grid::Cell::new(Some(String::from("R"))); - grid[0][1] = grid::Cell::new(Some(String::from("u"))); - grid[0][2] = grid::Cell::new(Some(String::from("s"))); - grid[0][3] = grid::Cell::new(Some(String::from("t"))); + // let contents = [ + // "for (row, line) in contents.iter().enumerate() {", + // " for (i, c) in line.chars().enumerate() {", + // " grid[row][i] = grid::Cell::new(Some(c.escape_default().collect()));", + // " }", + // "}"]; + + let contents = include_str!("grid.rs"); + let mut row = 0usize; + let mut col = 0; + + for (i, c) in contents.chars().enumerate() { + if c == '\n' { + row += 1; + col = 0; + continue; + } + + if row >= (num_rows as usize) { + break; + } + + if col >= grid.cols() { + continue; + } + + grid[row][col] = grid::Cell::new(Some(c.escape_default().collect())); + col += 1; + } let mut glyph_cache = HashMap::new(); for c in INIT_LIST.chars() { @@ -67,8 +92,8 @@ fn main() { } unsafe { - gl::Enable(gl::BLEND); - gl::BlendFunc(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA); + // gl::Enable(gl::BLEND); + // gl::BlendFunc(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA); gl::Enable(gl::MULTISAMPLE); } |