Fix discarding of FreeType loading flags
Fixes regression introduced in 6b327b6f8f
.
Fixes #3355.
This commit is contained in:
parent
933b2e25ff
commit
8abca44182
|
@ -46,10 +46,7 @@ pub use pattern::{Pattern, PatternHash, PatternRef};
|
||||||
/// Find the font closest matching the provided pattern.
|
/// Find the font closest matching the provided pattern.
|
||||||
///
|
///
|
||||||
/// The returned pattern is the result of Pattern::render_prepare.
|
/// 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: &PatternRef) -> Option<Pattern> {
|
||||||
pattern.config_substitute(config, MatchKind::Pattern);
|
|
||||||
pattern.default_substitute();
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
// What is this result actually used for? Seems redundant with
|
// What is this result actually used for? Seems redundant with
|
||||||
// return type.
|
// return type.
|
||||||
|
@ -64,11 +61,8 @@ pub fn font_match(config: &ConfigRef, pattern: &mut PatternRef) -> Option<Patter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// list fonts by closeness to the pattern
|
/// 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: &PatternRef) -> Option<FontSet> {
|
||||||
pattern.config_substitute(config, MatchKind::Pattern);
|
|
||||||
pattern.default_substitute();
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
// What is this result actually used for? Seems redundant with
|
// What is this result actually used for? Seems redundant with
|
||||||
// return type.
|
// return type.
|
||||||
|
@ -91,15 +85,12 @@ pub fn font_sort(config: &ConfigRef, pattern: &mut PatternRef) -> Option<FontSet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List fonts matching pattern
|
/// List fonts matching pattern.
|
||||||
pub fn font_list(
|
pub fn font_list(
|
||||||
config: &ConfigRef,
|
config: &ConfigRef,
|
||||||
pattern: &mut PatternRef,
|
pattern: &PatternRef,
|
||||||
objects: &ObjectSetRef,
|
objects: &ObjectSetRef,
|
||||||
) -> Option<FontSet> {
|
) -> Option<FontSet> {
|
||||||
pattern.config_substitute(config, MatchKind::Pattern);
|
|
||||||
pattern.default_substitute();
|
|
||||||
|
|
||||||
unsafe {
|
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());
|
||||||
|
|
||||||
|
@ -198,6 +189,7 @@ impl From<isize> for Width {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subpixel geometry
|
/// Subpixel geometry
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum Rgba {
|
pub enum Rgba {
|
||||||
Unknown,
|
Unknown,
|
||||||
Rgb,
|
Rgb,
|
||||||
|
@ -297,7 +289,9 @@ mod tests {
|
||||||
pattern.add_style("regular");
|
pattern.add_style("regular");
|
||||||
|
|
||||||
let config = Config::get_current();
|
let config = Config::get_current();
|
||||||
let font = super::font_match(config, &mut pattern).expect("match font monospace");
|
pattern.config_substitute(config, MatchKind::Pattern);
|
||||||
|
pattern.default_substitute();
|
||||||
|
let font = super::font_match(config, &pattern).expect("match font monospace");
|
||||||
|
|
||||||
print!("index={:?}; ", font.index());
|
print!("index={:?}; ", font.index());
|
||||||
print!("family={:?}; ", font.family());
|
print!("family={:?}; ", font.family());
|
||||||
|
@ -319,7 +313,9 @@ mod tests {
|
||||||
pattern.set_slant(Slant::Italic);
|
pattern.set_slant(Slant::Italic);
|
||||||
|
|
||||||
let config = Config::get_current();
|
let config = Config::get_current();
|
||||||
let fonts = super::font_sort(config, &mut pattern).expect("sort font monospace");
|
pattern.config_substitute(config, MatchKind::Pattern);
|
||||||
|
pattern.default_substitute();
|
||||||
|
let fonts = super::font_sort(config, &pattern).expect("sort font monospace");
|
||||||
|
|
||||||
for font in fonts.into_iter().take(10) {
|
for font in fonts.into_iter().take(10) {
|
||||||
let font = pattern.render_prepare(&config, &font);
|
let font = pattern.render_prepare(&config, &font);
|
||||||
|
@ -341,7 +337,9 @@ mod tests {
|
||||||
drop(charset);
|
drop(charset);
|
||||||
|
|
||||||
let config = Config::get_current();
|
let config = Config::get_current();
|
||||||
let fonts = super::font_sort(config, &mut pattern).expect("font_sort");
|
pattern.config_substitute(config, MatchKind::Pattern);
|
||||||
|
pattern.default_substitute();
|
||||||
|
let fonts = super::font_sort(config, &pattern).expect("font_sort");
|
||||||
|
|
||||||
for font in fonts.into_iter().take(10) {
|
for font in fonts.into_iter().take(10) {
|
||||||
let font = pattern.render_prepare(&config, &font);
|
let font = pattern.render_prepare(&config, &font);
|
||||||
|
|
|
@ -241,9 +241,12 @@ impl FreeTypeRasterizer {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pattern.config_substitute(config, fc::MatchKind::Pattern);
|
||||||
|
pattern.default_substitute();
|
||||||
|
|
||||||
// Get font list using pattern. First font is the primary one while the rest are fallbacks
|
// Get font list using pattern. First font is the primary one while the rest are fallbacks
|
||||||
let matched_fonts = fc::font_sort(&config, &mut pattern.clone())
|
let matched_fonts =
|
||||||
.ok_or_else(|| Error::MissingFont(desc.to_owned()))?;
|
fc::font_sort(&config, &pattern).ok_or_else(|| Error::MissingFont(desc.to_owned()))?;
|
||||||
let mut matched_fonts = matched_fonts.into_iter();
|
let mut matched_fonts = matched_fonts.into_iter();
|
||||||
|
|
||||||
let primary_font =
|
let primary_font =
|
||||||
|
@ -288,7 +291,8 @@ impl FreeTypeRasterizer {
|
||||||
let list: Vec<FallbackFont> = matched_fonts
|
let list: Vec<FallbackFont> = matched_fonts
|
||||||
.map(|fallback_font| {
|
.map(|fallback_font| {
|
||||||
let charset = fallback_font.get_charset().unwrap_or(&empty_charset);
|
let charset = fallback_font.get_charset().unwrap_or(&empty_charset);
|
||||||
let fallback_font = primary_font.render_prepare(config, fallback_font);
|
// Use original pattern to preserve loading flags
|
||||||
|
let fallback_font = pattern.render_prepare(config, fallback_font);
|
||||||
let fallback_font_id = FontID::new(hash, fallback_font.hash());
|
let fallback_font_id = FontID::new(hash, fallback_font.hash());
|
||||||
|
|
||||||
let _ = coverage.merge(&charset);
|
let _ = coverage.merge(&charset);
|
||||||
|
@ -416,16 +420,7 @@ impl FreeTypeRasterizer {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recreate a pattern
|
let pattern = font_pattern.clone();
|
||||||
let mut pattern = Pattern::new();
|
|
||||||
pattern.add_pixelsize(self.pixel_size as f64);
|
|
||||||
pattern.add_style(font_pattern.style().next().unwrap_or("Regular"));
|
|
||||||
pattern.add_family(font_pattern.family().next().unwrap_or("monospace"));
|
|
||||||
|
|
||||||
// Render pattern, otherwise most of its properties wont work
|
|
||||||
let config = fc::Config::get_current();
|
|
||||||
let pattern = pattern.render_prepare(config, font_pattern);
|
|
||||||
|
|
||||||
let key = self.face_from_pattern(&pattern, font_id, None)?.unwrap();
|
let key = self.face_from_pattern(&pattern, font_id, None)?.unwrap();
|
||||||
return Ok(key);
|
return Ok(key);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue