sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.63k stars 96 forks source link

Proposing the numeric space (aka. figure space) unit. #1705

Open Omikhleia opened 1 year ago

Omikhleia commented 1 year ago

I am using the following unit here and there e.g. when it comes to ensuring there's enough space for numeric digits.

-- numeric space a.k.a. figure space
local numsp = SU.utf8charfromcodepoint("U+2007")
units["nspc"] = {
  relative = true,
  definition = function (value)
    local measureable, numspc = pcall(SILE.shaper.measureChar, SILE.shaper, numsp)
    if not measureable then
      SU.warn("Current font cannot measure the U+2007 space, falling back to measuring '0'")
      return value * SILE.shaper:measureChar("0").width
    end
    return value * numspc.width
  end
}

E.g. "3nspc" has the width of 3 numeric digits (regular 'figure' number).

Do you think it would make sense to have it in SILE's default units?

alerque commented 1 year ago

Yes I do, but I would call it "figure space" in line with the Unicode being referenced rather than "numeric space". I have a couple implementations of checking figure space sises.

The only other thing I might look into is whether any fonts do/may have different size figure spaces for +onum vs. +lnum (lining vs. old-stlye numbers).

Omikhleia commented 1 year ago

The only other thing I might look into is whether any fonts do/may have different size figure spaces for +onum vs. +lnum (lining vs. old-stlye numbers).

It turns out I am struggling with these two. (I recently used EB Garamond, which defaults to onum , but has tnum and lnum... Doh, I need to understand some font-related things deeper).

Omikhleia commented 1 year ago

I'm removing the 0.14.9 milestone here. This was a suggestion/question but there's no urge or absolute necessity for it.