aboutsummaryrefslogtreecommitdiff
path: root/font/src/ft/mod.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2017-06-28 20:36:01 -0700
committerJoe Wilm <jwilm@users.noreply.github.com>2017-10-08 22:20:58 -0700
commit6c74c51ceff3ec1af0b3973e373aba6e315beffa (patch)
treeae4d738d6896790b5fa0eb7cdc32204afcd02ee4 /font/src/ft/mod.rs
parent65065e06d19216ed5de9b1db952db76a5457492e (diff)
downloadalacritty-6c74c51ceff3ec1af0b3973e373aba6e315beffa.tar.gz
alacritty-6c74c51ceff3ec1af0b3973e373aba6e315beffa.zip
Extend and improve FcPattern bindings
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); }
Diffstat (limited to 'font/src/ft/mod.rs')
-rw-r--r--font/src/ft/mod.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs
index 89ca6047..7a75d11f 100644
--- a/font/src/ft/mod.rs
+++ b/font/src/ft/mod.rs
@@ -19,7 +19,7 @@ use std::cmp::min;
use freetype::{self, Library, Face};
-mod fc;
+pub mod fc;
use super::{FontDesc, RasterizedGlyph, Metrics, Size, FontKey, GlyphKey, Weight, Slant, Style};
@@ -142,7 +142,7 @@ impl FreeTypeRasterizer {
let font = fc::font_match(fc::Config::get_current(), &mut pattern)
.ok_or_else(|| Error::MissingFont(desc.to_owned()))?;
- if let (Some(path), Some(index)) = (font.file(0), font.index(0)) {
+ if let (Some(path), Some(index)) = (font.file(0), font.index().nth(0)) {
return Ok(self.library.new_face(path, index)?);
}
@@ -160,7 +160,7 @@ impl FreeTypeRasterizer {
let font = fc::font_match(fc::Config::get_current(), &mut pattern)
.ok_or_else(|| Error::MissingFont(desc.to_owned()))?;
- if let (Some(path), Some(index)) = (font.file(0), font.index(0)) {
+ if let (Some(path), Some(index)) = (font.file(0), font.index().nth(0)) {
println!("got font path={:?}", path);
Ok(self.library.new_face(path, index)?)
}
@@ -293,7 +293,7 @@ impl FreeTypeRasterizer {
let config = fc::Config::get_current();
match fc::font_match(config, &mut pattern) {
Some(font) => {
- if let (Some(path), Some(index)) = (font.file(0), font.index(0)) {
+ if let (Some(path), Some(index)) = (font.file(0), font.index().nth(0)) {
match self.keys.get(&path) {
// We've previously loaded this font, so don't
// load it again.