-
Notifications
You must be signed in to change notification settings - Fork 711
[css-syntax][css-values] Awkward Decimal Fractions and Non-Finite Values #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Another partial solution, which I somehow didn’t list before, would be new fractional-inch units, e.g.:
|
Dael Jackson @ www-style (2017-02-13): [CSSWG] Minutes Seattle F2F 2017-01-11 Part VI: Writings Modes, CSS Tables, Values & Units 4 Traditional pica notation is discussed under the heading “Adding older typographic units”. Nobody engaged in the F2F discussion seems to have read this issue. My current minimal suggestion would be to add a note to css-values to remind authors that traditional <pica>p<point> and <x>/16 in syntaxes can already be expressed in CSS as |
Yeah, having a note about the I didn't add anything about fractional inches; they're identical to fractions of any other unit and don't, I believe, need to be called out specially. |
As noted in #315 by @dauwhe and @plinss and in #309 by me, some existing CSS units do not play well with decimal floating point numbers. These are vulgar fractions on the one hand, which can become rather long but terminating, like 1/16 = 0.0625, or repeating, like 1/12 = 0.08_3, and irrational constants on the other hand, e.g. π = ½τ = 3.1415…, √2 = 1.4142… or φ = ½+√1¼ = 1.6180…
The English typogaphical units (inch, pica and point) in particular are traditionally used either with vulgar fractions and a single unit (
in
) or with integer amounts of a mix of units (pc
andpt
, e.g. “1p2” for14pt
). Both can be achieved by usingcalc()
:Unless we add keywords for some common (quasi) constants to be used within
calc()
, the same approach doesn’t work for irrational numbers:This is obviously not quite as convenient as handwritten or typeset values, which would look a bit like this if approximated with CSS syntax:
I tried to show some possible solutions in #315 which I’ll repeat here for convenience and annotation. The example value was “3p4½” or “9/16 inch” in classic notation. This can be expressed with
calc()
in several ways:A natural adoption of the “p notation” would be function syntax:
p(3, 4.5)
p(3 4.5)
p(3 p 4.5)
p(3pc 4.5pt)
p(40.5)
Parentheses or brackets might provide a way to escape restrictions by the core grammar:
(3 p 4.5)
[3p4.5]
If the core grammar needed to be changed, there would be several ways it could be done that still mimic the traditional notation. The value for the secondary unit could be added either between the primary value and unit or after them, in both cases with a punctuation character used as separator. The third option would be similar to exponent
e
syntax withp
and would be specific to the pica-point case.3-4.5pc
3+4.5pc
3:4.5pc
3,4.5pc
3/4.5pc
3&4.5pc
3..4.5pc
3pc-4.5
3pc+4.5
3pc:4.5
3pc,4.5
3pc/4.5
3pc&4.5
3pc..4.5
3p4.5pc
3p4.5pt
If it was possible to put two values around a base unit symbol like
pc
to specify the fractional value in the “sub-unit”, this would apply to other units as well and there needed to be agreement which units combine (e.g.mm
andq
):3pc4.5
=40pt10
=0in3.375
=40.5pt
14mm1.15
=57q37.5
=3cc2.1
=1.42875cm
Conversion to different units may bring nicer values, but does not fit the work flow. In some cases, integer values or nice fractions could be achieved only with additional units
Unicode characters beyond Basic Latin would cover several use cases (including constants), but probably not all of them. (Note the fraction slash U+2044.)
3_3_8pc
,3⅜pc
40_1_2pt
,40½pt
9_16in
,9⅟16in
,9⁄16in
,9÷16in
It would be nice to have a common solution to these related problems. I’m in no way claiming that I’ve already found it. I’m also not preferring one particular option out of the presented ones.
The text was updated successfully, but these errors were encountered: