Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d7b53ec
improve colr emoji detection and testing
fundon May 6, 2026
ed40e9f
rename to is_emoji_presentation
fundon May 6, 2026
5f26116
tweak test name
fundon May 6, 2026
749c56e
update comment
fundon May 6, 2026
2ccc1c3
fix text presentation unicode
fundon May 7, 2026
30251cb
adjust name
fundon May 7, 2026
ca7b822
update test
fundon May 7, 2026
48d58d6
should update mapped
fundon May 7, 2026
7357be4
impl emoji segmenter
fundon May 9, 2026
059c707
add copyright header
fundon May 9, 2026
e6a8086
add copyright header
fundon May 9, 2026
98a672d
fix typo
fundon May 9, 2026
ffe321e
fix doc link
fundon May 9, 2026
2760eba
remove debug
fundon May 9, 2026
b574918
fix doc
fundon May 9, 2026
f9cd2d9
fix doc
fundon May 9, 2026
f651df4
fix clippy
fundon May 9, 2026
6f57530
adjust eq order
fundon May 9, 2026
80f8e77
adjust eq order
fundon May 9, 2026
9bc0701
fix copyright year
fundon May 9, 2026
b1f20eb
add comments
fundon May 10, 2026
09e21ee
add comments
fundon May 10, 2026
d200e15
fix doc
fundon May 10, 2026
953b93a
fix doc link
fundon May 10, 2026
0a29ecc
fast path
fundon May 10, 2026
c657392
add const
fundon May 10, 2026
2cf90eb
fix tag sequence range
fundon May 10, 2026
d1561ca
impl Emoji DFA
fundon May 12, 2026
bb16acb
add inline
fundon May 12, 2026
a968862
add copyright
fundon May 12, 2026
f4173b0
clippy
fundon May 12, 2026
35dda21
add state macro
fundon May 13, 2026
25774db
delete redundant types
fundon May 14, 2026
ff0f90c
fix size
fundon May 15, 2026
9deab6e
bake emoji properties
fundon May 18, 2026
8acae0b
fix
fundon May 18, 2026
3d0fbbd
fix mask
fundon May 18, 2026
b34b7cc
Optimize baking data
fundon May 18, 2026
6001a81
Add emoji_properties
fundon May 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions fontique/src/collection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,22 +318,19 @@ impl Inner {
/// Returns the family object for the given family identifier.
pub fn family(&mut self, id: FamilyId) -> Option<FamilyInfo> {
self.sync_shared();

if let Some(family) = self.data.families.get(&id) {
family.as_ref().cloned()
} else {
#[cfg(feature = "system")]
if let Some(system) = &self.system {
let family = system.fonts.lock().unwrap().family(id);
self.data.families.insert(id, family.clone());
family
} else {
None
}
#[cfg(not(feature = "system"))]
{
None
}
return family.as_ref().cloned();
}

#[cfg(feature = "system")]
if let Some(system) = &self.system {
let family = system.fonts.lock().unwrap().family(id);
self.data.families.insert(id, family.clone());
return family;
}

None
}

/// Returns the family object for the given name.
Expand Down
32 changes: 20 additions & 12 deletions parley/src/analysis/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
use alloc::vec::Vec;
use icu_normalizer::properties::Decomposed;

use crate::analysis::AnalysisDataSources;
use crate::{analysis::AnalysisDataSources, emoji::EmojiPresentationStyle};

/// The maximum number of characters in a single cluster.
const MAX_CLUSTER_SIZE: usize = 32;

#[derive(Debug, Default)]
pub(crate) struct CharCluster {
pub chars: Vec<Char>,
pub is_emoji: bool,
pub map_len: u8,
pub start: u32,
pub end: u32,
pub force_normalize: bool,
pub emoji_presentation_style: EmojiPresentationStyle,
comp: Form,
decomp: Form,
form: FormKind,
Expand Down Expand Up @@ -52,6 +52,8 @@ pub(crate) struct Char {
/// Indexes into the list of styles for the containing text run, to find the style applicable
/// to this character.
pub style_index: u16,
/// Whether the emoji presentation selector
pub is_emoji_presentation_selector: bool,
}

pub(crate) type GlyphId = u16;
Expand Down Expand Up @@ -93,7 +95,6 @@ pub(crate) enum Status {
impl CharCluster {
pub(crate) fn clear(&mut self) {
self.chars.clear();
self.is_emoji = false;
self.map_len = 0;
self.start = 0;
self.end = 0;
Expand All @@ -102,6 +103,7 @@ impl CharCluster {
self.decomp.clear();
self.form = FormKind::Original;
self.best_ratio = 0.;
self.emoji_presentation_style = EmojiPresentationStyle::Default;
}

#[inline(always)]
Expand Down Expand Up @@ -351,17 +353,23 @@ impl<'a> Mapper<'a> {
}
let mut mapped = 0;
for (c, g) in self.chars.iter().zip(glyphs.iter_mut()) {
if !c.contributes_to_shaping {
*g = f(c.ch);
if self.map_len == 1 {
mapped += 1;
}
} else {
let gid = f(c.ch);
*g = gid;
if gid != 0 {
*g = f(c.ch);

// If the color emoji has a presentation style, ignore the variation selector.
if c.is_emoji_presentation_selector {
mapped += 1;
continue;
}

if c.contributes_to_shaping {
if *g != 0 {
mapped += 1;
}
continue;
}

if self.map_len == 1 {
mapped += 1;
}
}
let ratio = mapped as f32 / self.map_len as f32;
Expand Down
18 changes: 17 additions & 1 deletion parley/src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use icu_segmenter::{
GraphemeClusterSegmenter, GraphemeClusterSegmenterBorrowed, LineSegmenter,
LineSegmenterBorrowed, WordSegmenter, WordSegmenterBorrowed,
};
use parley_data::Properties;
use parley_data::{Properties, emoji::EmojiProperties};

pub(crate) struct AnalysisDataSources;

Expand Down Expand Up @@ -92,6 +92,11 @@ impl AnalysisDataSources {
fn brackets(&self) -> CodePointMapDataBorrowed<'_, BidiMirroringGlyph> {
const { CodePointMapData::new() }
}

#[inline(always)]
pub(crate) const fn emoji_properties(&self, c: char) -> EmojiProperties {
EmojiProperties::get(c)
}
}

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand All @@ -106,6 +111,8 @@ pub(crate) struct CharInfo {
pub bidi_class: icu_properties::props::BidiClass,
/// Whether or not the character is a bracket, plus mirror data if so.
pub bracket: BidiMirroringGlyph,
/// The emoji properties of this character.
pub emoji_properties: EmojiProperties,

flags: u8,
}
Expand Down Expand Up @@ -139,6 +146,7 @@ impl CharInfo {
grapheme_cluster_break: GraphemeClusterBreak,
bidi_class: icu_properties::props::BidiClass,
bracket: BidiMirroringGlyph,
emoji_properties: EmojiProperties,
is_variation_selector: bool,
is_region_indicator: bool,
is_control: bool,
Expand All @@ -152,6 +160,7 @@ impl CharInfo {
grapheme_cluster_break,
bidi_class,
bracket,
emoji_properties,
flags: (is_variation_selector as u8) << Self::VARIATION_SELECTOR_SHIFT
| (is_region_indicator as u8) << Self::REGION_INDICATOR_SHIFT
| (is_control as u8) << Self::CONTROL_SHIFT
Expand Down Expand Up @@ -429,6 +438,7 @@ pub(crate) fn analyze_text<B: Brush>(lcx: &mut LayoutContext<B>, mut text: &str)
});

let properties = |c| lcx.analysis_data_sources.properties(c);
let emoji_properties = |c| lcx.analysis_data_sources.emoji_properties(c);

let mut needs_bidi_resolution = false;

Expand All @@ -448,6 +458,11 @@ pub(crate) fn analyze_text<B: Brush>(lcx: &mut LayoutContext<B>, mut text: &str)
let is_variation_selector = properties.is_variation_selector();
let is_region_indicator = properties.is_region_indicator();
let next_mandatory_linebreak = properties.is_mandatory_linebreak();
let emoji_properties = if is_emoji_or_pictograph {
emoji_properties(ch)
} else {
EmojiProperties::ZERO
};

let boundary = if is_mandatory_linebreak {
Boundary::Mandatory
Expand Down Expand Up @@ -479,6 +494,7 @@ pub(crate) fn analyze_text<B: Brush>(lcx: &mut LayoutContext<B>, mut text: &str)
grapheme_cluster_break,
bidi_class,
bracket,
emoji_properties,
is_variation_selector,
is_region_indicator,
general_category == GeneralCategory::Control,
Expand Down
Loading
Loading