summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorAaron Williamson <guitarfanman@gmail.com>2017-04-26 20:28:18 -0600
committerJoe Wilm <jwilm@users.noreply.github.com>2017-05-01 08:52:22 -0700
commitf06be732a231c218104a538abef670835d3a68b9 (patch)
tree6406bcebaef016c300cd9e92a0022b16c42ed3a9 /src/config.rs
parent0a1dc56bcf0b125cfd79787148d219d9e38f85b8 (diff)
downloadalacritty-f06be732a231c218104a538abef670835d3a68b9.tar.gz
alacritty-f06be732a231c218104a538abef670835d3a68b9.zip
Combine FontOffset and GlyphOffset structs into Delta struct
The two structs are very similar, so there is no reason for them to be separate. Instead combine them into a single Delta struct, which can be used to shift a point in a two dimensional plane.
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs58
1 files changed, 11 insertions, 47 deletions
diff --git a/src/config.rs b/src/config.rs
index c4f836db..2b46b324 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1163,54 +1163,18 @@ impl Dpi {
}
}
-/// Modifications to font spacing
-///
-/// The way Alacritty calculates vertical and horizontal cell sizes may not be
-/// ideal for all fonts. This gives the user a way to tweak those values.
-#[derive(Debug, Deserialize)]
-pub struct FontOffset {
- /// Extra horizontal spacing between letters
- x: f32,
- /// Extra vertical spacing between lines
- y: f32,
-}
-
-impl FontOffset {
- /// Get letter spacing
- #[inline]
- pub fn x(&self) -> f32 {
- self.x
- }
-
- /// Get line spacing
- #[inline]
- pub fn y(&self) -> f32 {
- self.y
- }
-}
-
-impl Default for FontOffset {
- fn default() -> FontOffset {
- FontOffset { x: 0.0, y: 0.0 }
- }
-}
-
-/// Modifications to glyph positions within their cells
-///
-/// By default the glyphs are located at the bottom of the cell which can be
-/// undesirable. This gives the user a way to shift where the glyphs are
-/// displayed in their cells.
+/// A delta for a point in a 2 dimensional plane
#[derive(Clone, Copy, Debug, Deserialize)]
-pub struct GlyphOffset {
- /// Horizontal position
+pub struct Delta {
+ /// Horizontal change
pub x: f32,
- /// Vertical position
+ /// Vertical change
pub y: f32,
}
-impl Default for GlyphOffset {
- fn default() -> GlyphOffset {
- GlyphOffset { x: 0.0, y: 0.0 }
+impl Default for Delta {
+ fn default() -> Delta {
+ Delta { x: 0.0, y: 0.0 }
}
}
@@ -1273,11 +1237,11 @@ pub struct Font {
size: Size,
/// Extra spacing per character
- offset: FontOffset,
+ offset: Delta,
/// Glyph offset within character cell
#[serde(default)]
- glyph_offset: GlyphOffset,
+ glyph_offset: Delta,
#[serde(default="true_bool")]
use_thin_strokes: bool
@@ -1316,13 +1280,13 @@ impl Font {
/// Get offsets to font metrics
#[inline]
- pub fn offset(&self) -> &FontOffset {
+ pub fn offset(&self) -> &Delta {
&self.offset
}
/// Get cell offsets for glyphs
#[inline]
- pub fn glyph_offset(&self) -> &GlyphOffset {
+ pub fn glyph_offset(&self) -> &Delta {
&self.glyph_offset
}
}