summaryrefslogtreecommitdiffstats
path: root/font
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-12-16 22:48:04 -0800
committerJoe Wilm <joe@jwilm.com>2016-12-16 22:48:04 -0800
commitbde4dacc791501440515c1a51ad2fcb0256cf04c (patch)
tree66bd6762c4ae11705d1a82ed72112a408e5ec2d5 /font
parent781572096ea67516a98872b1b3c5b1ffaea9bae0 (diff)
Misc formatting fixes
Diffstat (limited to 'font')
-rw-r--r--font/src/darwin/mod.rs54
-rw-r--r--font/src/ft/list_fonts.rs20
-rw-r--r--font/src/ft/mod.rs5
-rw-r--r--font/src/lib.rs4
4 files changed, 58 insertions, 25 deletions
diff --git a/font/src/darwin/mod.rs b/font/src/darwin/mod.rs
index 1b295801..c445996d 100644
--- a/font/src/darwin/mod.rs
+++ b/font/src/darwin/mod.rs
@@ -226,9 +226,15 @@ impl Descriptor {
impl Font {
/// The the bounding rect of a glyph
- pub fn bounding_rect_for_glyph(&self, orientation: FontOrientation, index: u32) -> Rect<f64> {
- let cg_rect = self.ct_font.get_bounding_rects_for_glyphs(orientation as CTFontOrientation,
- &[index as CGGlyph]);
+ pub fn bounding_rect_for_glyph(
+ &self,
+ orientation: FontOrientation,
+ index: u32
+ ) -> Rect<f64> {
+ let cg_rect = self.ct_font.get_bounding_rects_for_glyphs(
+ orientation as CTFontOrientation,
+ &[index as CGGlyph]
+ );
Rect::new(
Point2D::new(cg_rect.origin.x, cg_rect.origin.y),
@@ -255,10 +261,12 @@ impl Font {
let indices = [index as CGGlyph];
- self.ct_font.get_advances_for_glyphs(FontOrientation::Default as _,
- &indices[0],
- ptr::null_mut(),
- 1)
+ self.ct_font.get_advances_for_glyphs(
+ FontOrientation::Default as _,
+ &indices[0],
+ ptr::null_mut(),
+ 1
+ )
}
pub fn get_glyph(&self, character: char, _size: f64) -> RasterizedGlyph {
@@ -297,19 +305,25 @@ impl Font {
};
}
- let mut cg_context = CGContext::create_bitmap_context(rasterized_width as usize,
- rasterized_height as usize,
- 8, // bits per component
- rasterized_width as usize * 4,
- &CGColorSpace::create_device_rgb(),
- kCGImageAlphaPremultipliedFirst |
- kCGBitmapByteOrder32Host);
+ let mut cg_context = CGContext::create_bitmap_context(
+ rasterized_width as usize,
+ rasterized_height as usize,
+ 8, // bits per component
+ rasterized_width as usize * 4,
+ &CGColorSpace::create_device_rgb(),
+ kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host
+ );
// Give the context an opaque, black background
cg_context.set_rgb_fill_color(0.0, 0.0, 0.0, 1.0);
- let context_rect = CGRect::new(&CGPoint::new(0.0, 0.0),
- &CGSize::new(rasterized_width as f64,
- rasterized_height as f64));
+ let context_rect = CGRect::new(
+ &CGPoint::new(0.0, 0.0),
+ &CGSize::new(
+ rasterized_width as f64,
+ rasterized_height as f64
+ )
+ );
+
cg_context.fill_rect(context_rect);
// Uses thin strokes
@@ -354,7 +368,11 @@ impl Font {
let chars = [character as UniChar];
let mut glyphs = [0 as CGGlyph];
- let res = self.ct_font.get_glyphs_for_characters(&chars[0], &mut glyphs[0], 1 as CFIndex);
+ let res = self.ct_font.get_glyphs_for_characters(
+ &chars[0],
+ &mut glyphs[0],
+ 1 as CFIndex
+ );
if res {
Some(glyphs[0] as u32)
diff --git a/font/src/ft/list_fonts.rs b/font/src/ft/list_fonts.rs
index 1dc716d5..44794501 100644
--- a/font/src/ft/list_fonts.rs
+++ b/font/src/ft/list_fonts.rs
@@ -65,7 +65,11 @@ fn list_families() -> Vec<String> {
}
let mut id = 0;
- while FcPatternGetString(*font, b"family\0".as_ptr() as *mut c_char, id, &mut family) == FcResultMatch {
+ while FcPatternGetString(
+ *font,
+ b"family\0".as_ptr() as *mut c_char,
+ id, &mut family
+ ) == FcResultMatch {
let safe_family = fc_char8_to_string(family);
id += 1;
families.push(safe_family);
@@ -139,7 +143,11 @@ pub fn get_family_info(family: String) -> Family {
let family_name = family_name.as_ptr();
// Add family name to pattern. Use this for searching.
- FcPatternAddString(pattern, FAMILY.as_ptr() as *mut c_char, family_name as *mut FcChar8);
+ FcPatternAddString(
+ pattern,
+ FAMILY.as_ptr() as *mut c_char,
+ family_name as *mut FcChar8
+ );
// Request filename, style, and index for each variant in family
let object_set = FcObjectSetCreate(); // *mut FcObjectSet
@@ -147,7 +155,13 @@ pub fn get_family_info(family: String) -> Family {
FcObjectSetAdd(object_set, INDEX.as_ptr() as *mut c_char);
FcObjectSetAdd(object_set, STYLE.as_ptr() as *mut c_char);
- let variants = FcFontSetList(config, &mut font_set, 1 /* nsets */, pattern, object_set);
+ let variants = FcFontSetList(
+ config,
+ &mut font_set,
+ 1 /* nsets */,
+ pattern, object_set
+ );
+
let num_variant = (*variants).nfont as isize;
for i in 0..num_variant {
diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs
index fa4325a0..c9abd693 100644
--- a/font/src/ft/mod.rs
+++ b/font/src/ft/mod.rs
@@ -117,7 +117,10 @@ impl Rasterizer {
unsafe {
let ft_lib = self.library.raw();
- freetype::ffi::FT_Library_SetLcdFilter(ft_lib, freetype::ffi::FT_LCD_FILTER_DEFAULT);
+ freetype::ffi::FT_Library_SetLcdFilter(
+ ft_lib,
+ freetype::ffi::FT_LCD_FILTER_DEFAULT
+ );
}
let bitmap = glyph.bitmap();
diff --git a/font/src/lib.rs b/font/src/lib.rs
index 74563b1a..ca8de0a2 100644
--- a/font/src/lib.rs
+++ b/font/src/lib.rs
@@ -14,11 +14,9 @@
//
//! Compatibility layer for different font engines
//!
-//! This module is developed as part of Alacritty; Alacritty does not include Windows support
-//! as a goal at this time, and neither does this module.
-//!
//! CoreText is used on Mac OS.
//! FreeType is used on everything that's not Mac OS.
+//! Eventually, ClearType support will be available for windows
#![feature(integer_atomics)]
#[cfg(not(target_os = "macos"))]