Add dotless parameter to math.accent (#5939)

Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
Max 2025-03-31 09:17:49 +00:00 committed by GitHub
parent a64af130dc
commit 4f0fbfb7e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 36 additions and 4 deletions

View File

@ -19,8 +19,10 @@ pub fn layout_accent(
let mut base = ctx.layout_into_fragment(&elem.base, styles.chain(&cramped))?; let mut base = ctx.layout_into_fragment(&elem.base, styles.chain(&cramped))?;
// Try to replace a glyph with its dotless variant. // Try to replace a glyph with its dotless variant.
if let MathFragment::Glyph(glyph) = &mut base { if elem.dotless(styles) {
glyph.make_dotless_form(ctx); if let MathFragment::Glyph(glyph) = &mut base {
glyph.make_dotless_form(ctx);
}
} }
// Preserve class to preserve automatic spacing. // Preserve class to preserve automatic spacing.

View File

@ -13,8 +13,8 @@ use crate::math::Mathy;
/// ``` /// ```
#[elem(Mathy)] #[elem(Mathy)]
pub struct AccentElem { pub struct AccentElem {
/// The base to which the accent is applied. /// The base to which the accent is applied. May consist of multiple
/// May consist of multiple letters. /// letters.
/// ///
/// ```example /// ```example
/// $arrow(A B C)$ /// $arrow(A B C)$
@ -51,9 +51,24 @@ pub struct AccentElem {
pub accent: Accent, pub accent: Accent,
/// The size of the accent, relative to the width of the base. /// The size of the accent, relative to the width of the base.
///
/// ```example
/// $dash(A, size: #150%)$
/// ```
#[resolve] #[resolve]
#[default(Rel::one())] #[default(Rel::one())]
pub size: Rel<Length>, pub size: Rel<Length>,
/// Whether to remove the dot on top of lowercase i and j when adding a top
/// accent.
///
/// This enables the `dtls` OpenType feature.
///
/// ```example
/// $hat(dotless: #false, i)$
/// ```
#[default(true)]
pub dotless: bool,
} }
/// An accent character. /// An accent character.
@ -103,11 +118,18 @@ macro_rules! accents {
/// The size of the accent, relative to the width of the base. /// The size of the accent, relative to the width of the base.
#[named] #[named]
size: Option<Rel<Length>>, size: Option<Rel<Length>>,
/// Whether to remove the dot on top of lowercase i and j when
/// adding a top accent.
#[named]
dotless: Option<bool>,
) -> Content { ) -> Content {
let mut accent = AccentElem::new(base, Accent::new($primary)); let mut accent = AccentElem::new(base, Accent::new($primary));
if let Some(size) = size { if let Some(size) = size {
accent = accent.with_size(size); accent = accent.with_size(size);
} }
if let Some(dotless) = dotless {
accent = accent.with_dotless(dotless);
}
accent.pack() accent.pack()
} }
)+ )+

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

View File

@ -42,3 +42,11 @@ $tilde(U, size: #1.1em), x^tilde(U, size: #1.1em), sscript(tilde(U, size: #1.1em
macron(bb(#c)), dot(cal(#c)), diaer(upright(#c)), breve(bold(#c)), macron(bb(#c)), dot(cal(#c)), diaer(upright(#c)), breve(bold(#c)),
circle(bold(upright(#c))), caron(upright(sans(#c))), arrow(bold(frak(#c)))$ circle(bold(upright(#c))), caron(upright(sans(#c))), arrow(bold(frak(#c)))$
$test(i) \ test(j)$ $test(i) \ test(j)$
--- math-accent-dotless-disabled ---
// Test disabling the dotless glyph variants.
$hat(i), hat(i, dotless: #false), accent(j, tilde), accent(j, tilde, dotless: #false)$
--- math-accent-dotless-set-rule ---
#set math.accent(dotless: false)
$ hat(i) $