summaryrefslogtreecommitdiffstats
path: root/font/src/ft/fc
diff options
context:
space:
mode:
Diffstat (limited to 'font/src/ft/fc')
-rw-r--r--font/src/ft/fc/char_set.rs14
-rw-r--r--font/src/ft/fc/config.rs11
-rw-r--r--font/src/ft/fc/font_set.rs34
-rw-r--r--font/src/ft/fc/mod.rs53
-rw-r--r--font/src/ft/fc/object_set.rs6
-rw-r--r--font/src/ft/fc/pattern.rs254
6 files changed, 140 insertions, 232 deletions
diff --git a/font/src/ft/fc/char_set.rs b/font/src/ft/fc/char_set.rs
index 151d14a3..310fa189 100644
--- a/font/src/ft/fc/char_set.rs
+++ b/font/src/ft/fc/char_set.rs
@@ -11,10 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-use foreign_types::{ForeignTypeRef};
+use foreign_types::ForeignTypeRef;
-use super::ffi::{FcCharSet, FcCharSetDestroy, FcCharSetAddChar};
-use super::ffi::{FcCharSetCreate};
+use super::ffi::FcCharSetCreate;
+use super::ffi::{FcCharSet, FcCharSetAddChar, FcCharSetDestroy};
foreign_type! {
type CType = FcCharSet;
@@ -37,12 +37,6 @@ impl Default for CharSet {
impl CharSetRef {
pub fn add(&mut self, glyph: char) -> bool {
- unsafe {
- FcCharSetAddChar(
- self.as_ptr(),
- glyph as _
- ) == 1
- }
+ unsafe { FcCharSetAddChar(self.as_ptr(), glyph as _) == 1 }
}
}
-
diff --git a/font/src/ft/fc/config.rs b/font/src/ft/fc/config.rs
index 9744b37a..12ec2844 100644
--- a/font/src/ft/fc/config.rs
+++ b/font/src/ft/fc/config.rs
@@ -11,10 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-use foreign_types::{ForeignTypeRef};
+use foreign_types::ForeignTypeRef;
-use super::{SetName, FontSetRef};
-use super::ffi::{FcConfigGetCurrent, FcConfigGetFonts, FcConfig, FcConfigDestroy};
+use super::ffi::{FcConfig, FcConfigDestroy, FcConfigGetCurrent, FcConfigGetFonts};
+use super::{FontSetRef, SetName};
foreign_type! {
type CType = FcConfig;
@@ -25,13 +25,10 @@ foreign_type! {
pub struct ConfigRef;
}
-
impl Config {
/// Get the current configuration
pub fn get_current() -> &'static ConfigRef {
- unsafe {
- ConfigRef::from_ptr(FcConfigGetCurrent())
- }
+ unsafe { ConfigRef::from_ptr(FcConfigGetCurrent()) }
}
}
diff --git a/font/src/ft/fc/font_set.rs b/font/src/ft/fc/font_set.rs
index 4eccd487..aeb34371 100644
--- a/font/src/ft/fc/font_set.rs
+++ b/font/src/ft/fc/font_set.rs
@@ -15,9 +15,9 @@ use std::ops::Deref;
use foreign_types::{ForeignType, ForeignTypeRef};
-use super::{ConfigRef, PatternRef, ObjectSetRef};
+use super::{ConfigRef, ObjectSetRef, PatternRef};
-use super::ffi::{FcFontSetList, FcFontSetDestroy, FcFontSet};
+use super::ffi::{FcFontSet, FcFontSetDestroy, FcFontSetList};
foreign_type! {
type CType = FcFontSet;
@@ -33,13 +33,13 @@ impl FontSet {
config: &ConfigRef,
source: &mut FontSetRef,
pattern: &PatternRef,
- objects: &ObjectSetRef
+ objects: &ObjectSetRef,
) -> FontSet {
let raw = unsafe {
FcFontSetList(
config.as_ptr(),
&mut source.as_ptr(),
- 1 /* nsets */,
+ 1, // nsets
pattern.as_ptr(),
objects.as_ptr(),
)
@@ -56,38 +56,28 @@ pub struct Iter<'a> {
}
impl<'a> IntoIterator for &'a FontSet {
- type Item = &'a PatternRef;
type IntoIter = Iter<'a>;
+ type Item = &'a PatternRef;
+
fn into_iter(self) -> Iter<'a> {
- let num_fonts = unsafe {
- (*self.as_ptr()).nfont as isize
- };
+ let num_fonts = unsafe { (*self.as_ptr()).nfont as isize };
trace!("Number of fonts is {}", num_fonts);
- Iter {
- font_set: self.deref(),
- num_fonts: num_fonts as _,
- current: 0,
- }
+ Iter { font_set: self.deref(), num_fonts: num_fonts as _, current: 0 }
}
}
impl<'a> IntoIterator for &'a FontSetRef {
- type Item = &'a PatternRef;
type IntoIter = Iter<'a>;
+ type Item = &'a PatternRef;
+
fn into_iter(self) -> Iter<'a> {
- let num_fonts = unsafe {
- (*self.as_ptr()).nfont as isize
- };
+ let num_fonts = unsafe { (*self.as_ptr()).nfont as isize };
trace!("Number of fonts is {}", num_fonts);
- Iter {
- font_set: self,
- num_fonts: num_fonts as _,
- current: 0,
- }
+ Iter { font_set: self, num_fonts: num_fonts as _, current: 0 }
}
}
diff --git a/font/src/ft/fc/mod.rs b/font/src/ft/fc/mod.rs
index 5e5deb0c..ae8fb808 100644
--- a/font/src/ft/fc/mod.rs
+++ b/font/src/ft/fc/mod.rs
@@ -12,21 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-use std::ptr;
use std::fmt;
+use std::ptr;
use foreign_types::{ForeignType, ForeignTypeRef};
use fontconfig::fontconfig as ffi;
-use self::ffi::{FcSetSystem, FcSetApplication};
use self::ffi::FcResultNoMatch;
-use self::ffi::{FcFontMatch, FcFontList, FcFontSort};
+use self::ffi::{FcFontList, FcFontMatch, FcFontSort};
use self::ffi::{FcMatchFont, FcMatchPattern, FcMatchScan};
-use self::ffi::{FC_SLANT_OBLIQUE, FC_SLANT_ITALIC, FC_SLANT_ROMAN};
-use self::ffi::{FC_WEIGHT_THIN, FC_WEIGHT_EXTRALIGHT, FC_WEIGHT_LIGHT};
-use self::ffi::{FC_WEIGHT_BOOK, FC_WEIGHT_REGULAR, FC_WEIGHT_MEDIUM, FC_WEIGHT_SEMIBOLD};
-use self::ffi::{FC_WEIGHT_BOLD, FC_WEIGHT_EXTRABOLD, FC_WEIGHT_BLACK, FC_WEIGHT_EXTRABLACK};
+use self::ffi::{FcSetApplication, FcSetSystem};
+use self::ffi::{FC_SLANT_ITALIC, FC_SLANT_OBLIQUE, FC_SLANT_ROMAN};
+use self::ffi::{FC_WEIGHT_BLACK, FC_WEIGHT_BOLD, FC_WEIGHT_EXTRABLACK, FC_WEIGHT_EXTRABOLD};
+use self::ffi::{FC_WEIGHT_BOOK, FC_WEIGHT_MEDIUM, FC_WEIGHT_REGULAR, FC_WEIGHT_SEMIBOLD};
+use self::ffi::{FC_WEIGHT_EXTRALIGHT, FC_WEIGHT_LIGHT, FC_WEIGHT_THIN};
pub mod config;
pub use self::config::{Config, ConfigRef};
@@ -46,10 +46,7 @@ pub use self::pattern::{Pattern, PatternRef};
/// Find the font closest matching the provided pattern.
///
/// The returned pattern is the result of Pattern::render_prepare.
-pub fn font_match(
- config: &ConfigRef,
- pattern: &mut PatternRef,
-) -> Option<Pattern> {
+pub fn font_match(config: &ConfigRef, pattern: &mut PatternRef) -> Option<Pattern> {
pattern.config_substitute(config, MatchKind::Pattern);
pattern.default_substitute();
@@ -57,11 +54,7 @@ pub fn font_match(
// What is this result actually used for? Seems redundant with
// return type.
let mut result = FcResultNoMatch;
- let ptr = FcFontMatch(
- config.as_ptr(),
- pattern.as_ptr(),
- &mut result,
- );
+ let ptr = FcFontMatch(config.as_ptr(), pattern.as_ptr(), &mut result);
if ptr.is_null() {
None
@@ -72,10 +65,7 @@ pub fn font_match(
}
/// list fonts by closeness to the pattern
-pub fn font_sort(
- config: &ConfigRef,
- pattern: &mut PatternRef,
-) -> Option<FontSet> {
+pub fn font_sort(config: &ConfigRef, pattern: &mut PatternRef) -> Option<FontSet> {
pattern.config_substitute(config, MatchKind::Pattern);
pattern.default_substitute();
@@ -112,11 +102,7 @@ pub fn font_list(
pattern.default_substitute();
unsafe {
- let ptr = FcFontList(
- config.as_ptr(),
- pattern.as_ptr(),
- objects.as_ptr(),
- );
+ let ptr = FcFontList(config.as_ptr(), pattern.as_ptr(), objects.as_ptr());
if ptr.is_null() {
None
@@ -174,7 +160,7 @@ pub enum Width {
Expanded,
Extraexpanded,
Ultraexpanded,
- Other(i32)
+ Other(i32),
}
impl Width {
@@ -190,7 +176,7 @@ impl Width {
Expanded => 125,
Extraexpanded => 150,
Ultraexpanded => 200,
- Other(value) => value as isize
+ Other(value) => value as isize,
}
}
}
@@ -207,7 +193,7 @@ impl From<isize> for Width {
125 => Width::Expanded,
150 => Width::Extraexpanded,
200 => Width::Ultraexpanded,
- _ => Width::Other(value as _)
+ _ => Width::Other(value as _),
}
}
}
@@ -219,7 +205,7 @@ pub enum Rgba {
Bgr,
Vrgb,
Vbgr,
- None
+ None,
}
impl Rgba {
@@ -230,7 +216,7 @@ impl Rgba {
Rgba::Bgr => 2,
Rgba::Vrgb => 3,
Rgba::Vbgr => 4,
- Rgba::None => 5
+ Rgba::None => 5,
}
}
}
@@ -268,7 +254,7 @@ pub enum HintStyle {
None,
Slight,
Medium,
- Full
+ Full,
}
impl fmt::Display for HintStyle {
@@ -287,7 +273,7 @@ pub enum LcdFilter {
None,
Default,
Light,
- Legacy
+ Legacy,
}
impl fmt::Display for LcdFilter {
@@ -334,8 +320,7 @@ mod tests {
pattern.set_slant(Slant::Italic);
let config = Config::get_current();
- let fonts = super::font_sort(config, &mut pattern)
- .expect("sort font monospace");
+ let fonts = super::font_sort(config, &mut pattern).expect("sort font monospace");
for font in fonts.into_iter().take(10) {
let font = font.render_prepare(&config, &pattern);
diff --git a/font/src/ft/fc/object_set.rs b/font/src/ft/fc/object_set.rs
index 47d11674..2494b582 100644
--- a/font/src/ft/fc/object_set.rs
+++ b/font/src/ft/fc/object_set.rs
@@ -13,8 +13,8 @@
// limitations under the License.
use libc::c_char;
+use super::ffi::{FcObjectSet, FcObjectSetAdd, FcObjectSetCreate, FcObjectSetDestroy};
use foreign_types::ForeignTypeRef;
-use super::ffi::{FcObjectSetCreate, FcObjectSetAdd, FcObjectSet, FcObjectSetDestroy};
foreign_type! {
type CType = FcObjectSet;
@@ -31,9 +31,7 @@ impl ObjectSet {
impl Default for ObjectSet {
fn default() -> Self {
- ObjectSet(unsafe {
- FcObjectSetCreate()
- })
+ ObjectSet(unsafe { FcObjectSetCreate() })
}
}
diff --git a/font/src/ft/fc/pattern.rs b/font/src/ft/fc/pattern.rs
index bb0c4c38..84187aa3 100644
--- a/font/src/ft/fc/pattern.rs
+++ b/font/src/ft/fc/pattern.rs
@@ -11,38 +11,34 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-use std::ptr;
-use std::fmt;
use std::ffi::{CStr, CString};
+use std::fmt;
+use std::mem;
use std::path::PathBuf;
+use std::ptr;
use std::str;
-use std::mem;
-use libc::{c_char, c_int, c_double};
use foreign_types::{ForeignType, ForeignTypeRef};
+use libc::{c_char, c_double, c_int};
use super::ffi::FcResultMatch;
-use super::ffi::{FcPatternDestroy, FcPatternAddCharSet};
-use super::ffi::{FcPatternGetString, FcPatternCreate, FcPatternAddString, FcPatternAddDouble};
-use super::ffi::{FcPatternGetInteger, FcPatternAddInteger, FcPatternPrint};
-use super::ffi::{FcChar8, FcPattern, FcDefaultSubstitute, FcConfigSubstitute};
-use super::ffi::{FcFontRenderPrepare, FcPatternGetBool, FcBool, FcPatternGetDouble};
+use super::ffi::{FcBool, FcFontRenderPrepare, FcPatternGetBool, FcPatternGetDouble};
+use super::ffi::{FcChar8, FcConfigSubstitute, FcDefaultSubstitute, FcPattern};
+use super::ffi::{FcPatternAddCharSet, FcPatternDestroy};
+use super::ffi::{FcPatternAddDouble, FcPatternAddString, FcPatternCreate, FcPatternGetString};
+use super::ffi::{FcPatternAddInteger, FcPatternGetInteger, FcPatternPrint};
-use super::{MatchKind, ConfigRef, CharSetRef, Weight, Slant, Width, Rgba, HintStyle, LcdFilter};
+use super::{CharSetRef, ConfigRef, HintStyle, LcdFilter, MatchKind, Rgba, Slant, Weight, Width};
pub struct StringPropertyIter<'a> {
pattern: &'a PatternRef,
object: &'a [u8],
- index: usize
+ index: usize,
}
impl<'a> StringPropertyIter<'a> {
fn new<'b>(pattern: &'b PatternRef, object: &'b [u8]) -> StringPropertyIter<'b> {
- StringPropertyIter {
- pattern,
- object,
- index: 0
- }
+ StringPropertyIter { pattern, object, index: 0 }
}
fn get_value(&self, index: usize) -> Option<&'a str> {
@@ -53,7 +49,7 @@ impl<'a> StringPropertyIter<'a> {
self.pattern.as_ptr(),
self.object.as_ptr() as *mut c_char,
index as c_int,
- &mut value
+ &mut value,
)
};
@@ -75,17 +71,12 @@ impl<'a> StringPropertyIter<'a> {
pub struct BooleanPropertyIter<'a> {
pattern: &'a PatternRef,
object: &'a [u8],
- index: usize
+ index: usize,
}
-
impl<'a> BooleanPropertyIter<'a> {
fn new<'b>(pattern: &'b PatternRef, object: &'b [u8]) -> BooleanPropertyIter<'b> {
- BooleanPropertyIter {
- pattern,
- object,
- index: 0
- }
+ BooleanPropertyIter { pattern, object, index: 0 }
}
fn get_value(&self, index: usize) -> Option<bool> {
@@ -96,7 +87,7 @@ impl<'a> BooleanPropertyIter<'a> {
self.pattern.as_ptr(),
self.object.as_ptr() as *mut c_char,
index as c_int,
- &mut value
+ &mut value,
)
};
@@ -112,16 +103,12 @@ impl<'a> BooleanPropertyIter<'a> {
pub struct IntPropertyIter<'a> {
pattern: &'a PatternRef,
object: &'a [u8],
- index: usize
+ index: usize,
}
impl<'a> IntPropertyIter<'a> {
fn new<'b>(pattern: &'b PatternRef, object: &'b [u8]) -> IntPropertyIter<'b> {
- IntPropertyIter {
- pattern,
- object,
- index: 0
- }
+ IntPropertyIter { pattern, object, index: 0 }
}
fn get_value(&self, index: usize) -> Option<isize> {
@@ -132,7 +119,7 @@ impl<'a> IntPropertyIter<'a> {
self.pattern.as_ptr(),
self.object.as_ptr() as *mut c_char,
index as c_int,
- &mut value
+ &mut value,
)
};
@@ -150,9 +137,7 @@ pub struct RgbaPropertyIter<'a> {
impl<'a> RgbaPropertyIter<'a> {
fn new<'b>(pattern: &'b PatternRef, object: &'b [u8]) -> RgbaPropertyIter<'b> {
- RgbaPropertyIter {
- inner: IntPropertyIter::new(pattern, object)
- }
+ RgbaPropertyIter { inner: IntPropertyIter::new(pattern, object) }
}
#[inline]
@@ -161,8 +146,7 @@ impl<'a> RgbaPropertyIter<'a> {
}
fn get_value(&self, index: usize) -> Option<Rgba> {
- self.inner.get_value(index)
- .map(Rgba::from)
+ self.inner.get_value(index).map(Rgba::from)
}
}
@@ -172,9 +156,7 @@ pub struct HintStylePropertyIter<'a> {
impl<'a> HintStylePropertyIter<'a> {
fn new(pattern: &PatternRef) -> HintStylePropertyIter {
- HintStylePropertyIter {
- inner: IntPropertyIter::new(pattern, b"hintstyle\0")
- }
+ HintStylePropertyIter { inner: IntPropertyIter::new(pattern, b"hintstyle\0") }
}
#[inline]
@@ -183,16 +165,15 @@ impl<'a> HintStylePropertyIter<'a> {
}
fn get_value(&self, index: usize) -> Option<HintStyle> {
- self.inner.get_value(index)
- .and_then(|hint_style| {
- Some(match hint_style {
- 0 => HintStyle::None,
- 1 => HintStyle::Slight,
- 2 => HintStyle::Medium,
- 3 => HintStyle::Full,
- _ => return None
- })
+ self.inner.get_value(index).and_then(|hint_style| {
+ Some(match hint_style {
+ 0 => HintStyle::None,
+ 1 => HintStyle::Slight,
+ 2 => HintStyle::Medium,
+ 3 => HintStyle::Full,
+ _ => return None,
})
+ })
}
}
@@ -202,9 +183,7 @@ pub struct LcdFilterPropertyIter<'a> {
impl<'a> LcdFilterPropertyIter<'a> {
fn new(pattern: &PatternRef) -> LcdFilterPropertyIter {
- LcdFilterPropertyIter {
- inner: IntPropertyIter::new(pattern, b"lcdfilter\0")
- }
+ LcdFilterPropertyIter { inner: IntPropertyIter::new(pattern, b"lcdfilter\0") }
}
#[inline]
@@ -213,16 +192,15 @@ impl<'a> LcdFilterPropertyIter<'a> {
}
fn get_value(&self, index: usize) -> Option<LcdFilter> {
- self.inner.get_value(index)
- .and_then(|hint_style| {
- Some(match hint_style {
- 0 => LcdFilter::None,
- 1 => LcdFilter::Default,
- 2 => LcdFilter::Light,
- 3 => LcdFilter::Legacy,
- _ => return None
- })
+ self.inner.get_value(index).and_then(|hint_style| {
+ Some(match hint_style {
+ 0 => LcdFilter::None,
+ 1 => LcdFilter::Default,
+ 2 => LcdFilter::Light,
+ 3 => LcdFilter::Legacy,
+ _ => return None,
})
+ })
}
}
@@ -230,16 +208,12 @@ impl<'a> LcdFilterPropertyIter<'a> {
pub struct DoublePropertyIter<'a> {
pattern: &'a PatternRef,
object: &'a [u8],
- index: usize
+ index: usize,
}
impl<'a> DoublePropertyIter<'a> {
fn new<'b>(pattern: &'b PatternRef, object: &'b [u8]) -> DoublePropertyIter<'b> {
- DoublePropertyIter {
- pattern,
- object,
- index: 0
- }
+ DoublePropertyIter { pattern, object, index: 0 }
}
fn get_value(&self, index: usize) -> Option<f64> {
@@ -250,7 +224,7 @@ impl<'a> DoublePropertyIter<'a> {
self.pattern.as_ptr(),
self.object.as_ptr() as *mut c_char,
index as c_int,
- &mut value
+ &mut value,
)
};
@@ -277,13 +251,13 @@ macro_rules! impl_property_iter_debug {
write!(f, "{}", val)?;
}
},
- _ => break
+ _ => break,
}
}
write!(f, "]")
}
}
- }
+ };
}
/// Implement Iterator and Debug for a property iterator
@@ -427,15 +401,55 @@ macro_rules! double_getter {
}
impl PatternRef {
+ boolean_getter! {
+ antialias() => b"antialias\0",
+ hinting() => b"hinting\0",
+ verticallayout() => b"verticallayout\0",
+ autohint() => b"autohint\0",
+ globaladvance() => b"globaladvance\0",
+ scalable() => b"scalable\0",
+ symbol() => b"symbol\0",
+ color() => b"color\0",
+ minspace() => b"minspace\0",
+ embolden() => b"embolden\0",
+ embeddedbitmap() => b"embeddedbitmap\0",
+ decorative() => b"decorative\0"
+ }
+
+ double_getter! {
+ size() => b"size\0",
+ aspect() => b"aspect\0",
+ pixelsize() => b"pixelsize\0",
+ scale() => b"scale\0",
+ dpi() => b"dpi\0"
+ }
+
+ string_accessor! {
+ [family, add_family] => b"family\0",
+ [familylang, add_familylang] => b"familylang\0",
+ [style, add_style] => b"style\0",
+ [stylelang, add_stylelang] => b"stylelang\0",
+ [fullname, add_fullname] => b"fullname\0",
+ [fullnamelang, add_fullnamelang] => b"fullnamelang\0",
+ [foundry, add_foundry] => b"foundry\0",
+ [capability, add_capability] => b"capability\0",
+ [fontformat, add_fontformat] => b"fontformat\0",
+ [fontfeatures, add_fontfeatures] => b"fontfeatures\0",
+ [namelang, add_namelang] => b"namelang\0",
+ [postscriptname, add_postscriptname] => b"postscriptname\0"
+ }
+
+ pattern_get_integer! {
+ index() => b"index\0"
+ }
+
// Prints the pattern to stdout
//
// FontConfig doesn't expose a way to iterate over all members of a pattern;
// instead, we just defer to FcPatternPrint. Otherwise, this could have been
// a `fmt::Debug` impl.
pub fn print(&self) {
- unsafe {
- FcPatternPrint(self.as_ptr())
- }
+ unsafe { FcPatternPrint(self.as_ptr()) }
}
/// Add a string value to the pattern
@@ -450,27 +464,16 @@ impl PatternRef {
let value = CString::new(&value[..]).unwrap();
let value = value.as_ptr();
- FcPatternAddString(
- self.as_ptr(),
- object.as_ptr() as *mut c_char,
- value as *mut FcChar8
- ) == 1
+ FcPatternAddString(self.as_ptr(), object.as_ptr() as *mut c_char, value as *mut FcChar8)
+ == 1
}
unsafe fn add_integer(&self, object: &[u8], int: isize) -> bool {
- FcPatternAddInteger(
- self.as_ptr(),
- object.as_ptr() as *mut c_char,
- int as c_int
- ) == 1
+ FcPatternAddInteger(self.as_ptr(), object.as_ptr() as *mut c_char, int as c_int) == 1
}
unsafe fn add_double(&self, object: &[u8], value: f64) -> bool {
- FcPatternAddDouble(
- self.as_ptr(),
- object.as_ptr() as *mut c_char,
- value as c_double
- ) == 1
+ FcPatternAddDouble(self.as_ptr(), object.as_ptr() as *mut c_char, value as c_double) == 1
}
unsafe fn get_string<'a>(&'a self, object: &'a [u8]) -> StringPropertyIter<'a> {
@@ -497,74 +500,24 @@ impl PatternRef {
LcdFilterPropertyIter::new(self)
}
- boolean_getter! {
- antialias() => b"antialias\0",
- hinting() => b"hinting\0",
- verticallayout() => b"verticallayout\0",
- autohint() => b"autohint\0",
- globaladvance() => b"globaladvance\0",
- scalable() => b"scalable\0",
- symbol() => b"symbol\0",
- color() => b"color\0",
- minspace() => b"minspace\0",
- embolden() => b"embolden\0",
- embeddedbitmap() => b"embeddedbitmap\0",
- decorative() => b"decorative\0"
- }
-
- double_getter! {
- size() => b"size\0",
- aspect() => b"aspect\0",
- pixelsize() => b"pixelsize\0",
- scale() => b"scale\0",
- dpi() => b"dpi\0"
- }
-
- string_accessor! {
- [family, add_family] => b"family\0",
- [familylang, add_familylang] => b"familylang\0",
- [style, add_style] => b"style\0",
- [stylelang, add_stylelang] => b"stylelang\0",
- [fullname, add_fullname] => b"fullname\0",
- [fullnamelang, add_fullnamelang] => b"fullnamelang\0",
- [foundry, add_foundry] => b"foundry\0",
- [capability, add_capability] => b"capability\0",
- [fontformat, add_fontformat] => b"fontformat\0",
- [fontfeatures, add_fontfeatures] => b"fontfeatures\0",
- [namelang, add_namelang] => b"namelang\0",
- [postscriptname, add_postscriptname] => b"postscriptname\0"
- }
-
pub fn set_slant(&mut self, slant: Slant) -> bool {
- unsafe {
- self.add_integer(b"slant\0", slant as isize)
- }
+ unsafe { self.add_integer(b"slant\0", slant as isize) }
}
pub fn add_pixelsize(&mut self, size: f64) -> bool {
- unsafe {
- self.add_double(b"pixelsize\0", size)
- }
+ unsafe { self.add_double(b"pixelsize\0", size) }
}
pub fn set_weight(&mut self, weight: Weight) -> bool {
- unsafe {
- self.add_integer(b"weight\0", weight as isize)
- }
+ unsafe { self.add_integer(b"weight\0", weight as isize) }
}
pub fn set_width(&mut self, width: Width) -> bool {
- unsafe {
- self.add_integer(b"width\0", width.to_isize())
- }
+ unsafe { self.add_integer(b"width\0", width.to_isize()) }
}
pub fn get_width(&self) -> Option<Width> {
- unsafe {
- self.get_integer(b"width\0")
- .nth(0)
- .map(Width::from)
- }
+ unsafe { self.get_integer(b"width\0").nth(0).map(Width::from) }
}
pub fn rgba(&self) -> RgbaPropertyIter {
@@ -572,9 +525,7 @@ impl PatternRef {
}
pub fn set_rgba(&self, rgba: &Rgba) -> bool {
- unsafe {
- self.add_integer(b"rgba\0", rgba.to_isize())
- }
+ unsafe { self.add_integer(b"rgba\0", rgba.to_isize()) }
}
pub fn render_prepare(&self, config: &ConfigRef, request: &PatternRef) -> Pattern {
@@ -595,19 +546,13 @@ impl PatternRef {
FcPatternAddCharSet(
self.as_ptr(),
b"charset\0".as_ptr() as *mut c_char,
- charset.as_ptr()
+ charset.as_ptr(),
) == 1
}
}
pub fn file(&self, index: usize) -> Option<PathBuf> {
- unsafe {
- self.get_string(b"file\0").nth(index)
- }.map(From::from)
- }
-
- pattern_get_integer! {
- index() => b"index\0"
+ unsafe { self.get_string(b"file\0").nth(index) }.map(From::from)
}
pub fn config_substitute(&mut self, config: &ConfigRef, kind: MatchKind) {
@@ -622,4 +567,3 @@ impl PatternRef {
}
}
}
-