revert the references
This commit is contained in:
parent
fb852d3ab5
commit
71b0680e6f
2 changed files with 27 additions and 35 deletions
28
src/attrs.rs
28
src/attrs.rs
|
|
@ -169,13 +169,7 @@ pub struct FontFeatures {
|
||||||
impl FontFeatures {
|
impl FontFeatures {
|
||||||
/// Create new font features with default settings
|
/// Create new font features with default settings
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let mut features = Vec::new();
|
Self { features: Vec::new() }
|
||||||
// Enable kerning by default
|
|
||||||
features.push(Feature { tag: FeatureTag::KERNING, value: 1 });
|
|
||||||
// Enable standard ligatures by default
|
|
||||||
features.push(Feature { tag: FeatureTag::STANDARD_LIGATURES, value: 1 });
|
|
||||||
|
|
||||||
Self { features }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a feature value
|
/// Set a feature value
|
||||||
|
|
@ -207,7 +201,7 @@ pub struct Attrs<'a> {
|
||||||
pub metadata: usize,
|
pub metadata: usize,
|
||||||
pub cache_key_flags: CacheKeyFlags,
|
pub cache_key_flags: CacheKeyFlags,
|
||||||
pub metrics_opt: Option<CacheMetrics>,
|
pub metrics_opt: Option<CacheMetrics>,
|
||||||
pub font_features: Option<FontFeatures>,
|
pub font_features: FontFeatures,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Attrs<'a> {
|
impl<'a> Attrs<'a> {
|
||||||
|
|
@ -224,7 +218,7 @@ impl<'a> Attrs<'a> {
|
||||||
metadata: 0,
|
metadata: 0,
|
||||||
cache_key_flags: CacheKeyFlags::empty(),
|
cache_key_flags: CacheKeyFlags::empty(),
|
||||||
metrics_opt: None,
|
metrics_opt: None,
|
||||||
font_features: None, // Use default features
|
font_features: FontFeatures::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,7 +272,7 @@ impl<'a> Attrs<'a> {
|
||||||
|
|
||||||
/// Set [FontFeatures]
|
/// Set [FontFeatures]
|
||||||
pub fn font_features(mut self, font_features: FontFeatures) -> Self {
|
pub fn font_features(mut self, font_features: FontFeatures) -> Self {
|
||||||
self.font_features = Some(font_features);
|
self.font_features = font_features;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -330,7 +324,7 @@ pub struct AttrsOwned {
|
||||||
pub metadata: usize,
|
pub metadata: usize,
|
||||||
pub cache_key_flags: CacheKeyFlags,
|
pub cache_key_flags: CacheKeyFlags,
|
||||||
pub metrics_opt: Option<CacheMetrics>,
|
pub metrics_opt: Option<CacheMetrics>,
|
||||||
pub font_features: Option<FontFeatures>,
|
pub font_features: FontFeatures,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AttrsOwned {
|
impl AttrsOwned {
|
||||||
|
|
@ -373,9 +367,9 @@ pub struct AttrsList {
|
||||||
|
|
||||||
impl AttrsList {
|
impl AttrsList {
|
||||||
/// Create a new attributes list with a set of default [Attrs]
|
/// Create a new attributes list with a set of default [Attrs]
|
||||||
pub fn new(defaults: &Attrs) -> Self {
|
pub fn new(defaults: Attrs) -> Self {
|
||||||
Self {
|
Self {
|
||||||
defaults: AttrsOwned::new(defaults.clone()),
|
defaults: AttrsOwned::new(defaults),
|
||||||
spans: RangeMap::new(),
|
spans: RangeMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -401,13 +395,13 @@ impl AttrsList {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add an attribute span, removes any previous matching parts of spans
|
/// Add an attribute span, removes any previous matching parts of spans
|
||||||
pub fn add_span(&mut self, range: Range<usize>, attrs: &Attrs) {
|
pub fn add_span(&mut self, range: Range<usize>, attrs: Attrs) {
|
||||||
//do not support 1..1 or 2..1 even if by accident.
|
//do not support 1..1 or 2..1 even if by accident.
|
||||||
if range.is_empty() {
|
if range.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.spans.insert(range, AttrsOwned::new(attrs.clone()));
|
self.spans.insert(range, AttrsOwned::new(attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the attribute span for an index
|
/// Get the attribute span for an index
|
||||||
|
|
@ -457,8 +451,8 @@ impl AttrsList {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets the attributes with new defaults.
|
/// Resets the attributes with new defaults.
|
||||||
pub(crate) fn reset(mut self, default: &Attrs) -> Self {
|
pub(crate) fn reset(mut self, default: Attrs) -> Self {
|
||||||
self.defaults = AttrsOwned::new(default.clone());
|
self.defaults = AttrsOwned::new(default);
|
||||||
self.spans.clear();
|
self.spans.clear();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
src/shape.rs
24
src/shape.rs
|
|
@ -141,25 +141,23 @@ fn shape_fallback(
|
||||||
assert_eq!(rtl, span_rtl);
|
assert_eq!(rtl, span_rtl);
|
||||||
|
|
||||||
let attrs = attrs_list.get_span(start_run);
|
let attrs = attrs_list.get_span(start_run);
|
||||||
let mut rb_features = Vec::new();
|
let mut rb_font_features = Vec::new();
|
||||||
|
|
||||||
// Convert attrs::Feature to rustybuzz::Feature
|
// Convert attrs::Feature to rustybuzz::Feature
|
||||||
if let Some(font_features) = attrs.font_features {
|
for feature in attrs.font_features.features {
|
||||||
for feature in font_features.features {
|
rb_font_features.push(rustybuzz::Feature::new(
|
||||||
rb_features.push(rustybuzz::Feature::new(
|
rustybuzz::ttf_parser::Tag::from_bytes(&feature.tag.as_bytes()),
|
||||||
rustybuzz::ttf_parser::Tag::from_bytes(&feature.tag.as_bytes()),
|
feature.value,
|
||||||
feature.value,
|
0..usize::MAX,
|
||||||
0..usize::MAX,
|
));
|
||||||
));
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let shape_plan = rustybuzz::ShapePlan::new(
|
let shape_plan = rustybuzz::ShapePlan::new(
|
||||||
font.rustybuzz(),
|
font.rustybuzz(),
|
||||||
buffer.direction(),
|
buffer.direction(),
|
||||||
Some(buffer.script()),
|
Some(buffer.script()),
|
||||||
buffer.language().as_ref(),
|
buffer.language().as_ref(),
|
||||||
&rb_features,
|
&rb_font_features,
|
||||||
);
|
);
|
||||||
let glyph_buffer = rustybuzz::shape_with_plan(font.rustybuzz(), &shape_plan, buffer);
|
let glyph_buffer = rustybuzz::shape_with_plan(font.rustybuzz(), &shape_plan, buffer);
|
||||||
let glyph_infos = glyph_buffer.glyph_infos();
|
let glyph_infos = glyph_buffer.glyph_infos();
|
||||||
|
|
@ -262,7 +260,7 @@ fn shape_run(
|
||||||
|
|
||||||
let attrs = attrs_list.get_span(start_run);
|
let attrs = attrs_list.get_span(start_run);
|
||||||
|
|
||||||
let fonts = font_system.get_font_matches(&attrs);
|
let fonts = font_system.get_font_matches(attrs);
|
||||||
|
|
||||||
let default_families = [&attrs.family];
|
let default_families = [&attrs.family];
|
||||||
let mut font_iter = FontFallbackIter::new(
|
let mut font_iter = FontFallbackIter::new(
|
||||||
|
|
@ -445,7 +443,7 @@ fn shape_skip(
|
||||||
end_run: usize,
|
end_run: usize,
|
||||||
) {
|
) {
|
||||||
let attrs = attrs_list.get_span(start_run);
|
let attrs = attrs_list.get_span(start_run);
|
||||||
let fonts = font_system.get_font_matches(&attrs);
|
let fonts = font_system.get_font_matches(attrs);
|
||||||
|
|
||||||
let default_families = [&attrs.family];
|
let default_families = [&attrs.family];
|
||||||
let mut font_iter = FontFallbackIter::new(font_system, &fonts, &default_families, &[], "");
|
let mut font_iter = FontFallbackIter::new(font_system, &fonts, &default_families, &[], "");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue