Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #30.
The most important idea of this PR is that it codifies what a "modifier" is.
In that aspect, it stands on its own and makes sense even without considering the context of usage in typst.
For this, there is a new
ModifierSet
type that contains all the logic for comparing and composing modifiers.This new type is designed to be generic, so that typst can reuse it with
EcoString
.(In particular, typst's
symbol::Repr::Modified
would change toModified(Arc<(List, ModifierSet<EcoString>)>)
)Some private functions from
typst-library/src/foundations/symbol.rs
are lifted to public methods onModifierSet
:parts
becomesModifierSet::iter
contained
becomesModifierSet::contains
find
becomesModifierSet::best_match_in
(with reversed argument order), which is generic since it was really easy to make it so and this prepares it for when we let symbols have more than onechar
per variant (cf. Emoji Variation selectors #25)I've also taken the liberty of consolidating the types from
lib.rs
andbuild.rs
. It bugged me that they were duplicated and this change didn't really do anything in terms of code size while arguably improving maintainability (unless you don't like macros, but even among macros this one is very tame).There are some new functions (
get
,variants
andmodifiers
) oncodex::Symbol
that somewhat mirror the ones on typst'sSymbol
, but aren't intended to replace them right now (for why, see the next paragraph). They just made sense to add anyway.The only changes made to typst would be to start using
ModifierSet
, which would basically have the effect of having moved the relevant code from typst to codex.Actually integrating typst's
symbol::Repr::Modified
into codex proved too complicated, so I left that for later (if we even need it). Further considerations regarding the integrating of this into typst is left to a future PR at typst/typst (only if this one is accepted, of course).