-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
bugSomething isn't workingSomething isn't workingscriptingAbout Typst's coding capabilitiesAbout Typst's coding capabilities
Description
Description
Typst (tested on 0.9.0) seems to incorrectly round the repr
of length
, relative
, fraction
and ratio
values between 1
and 1.035
.
#repr(1.005pt + 1.005em) \
#repr(1.005%) \
#repr(1.005% + 1.005pt + 1.005em) \
#repr(1.005fr) \
#repr(1.015pt + 1.015em) \
#repr(1.015%) \
#repr(1.015% + 1.015pt + 1.015em) \
#repr(1.015fr) \
#repr(1.025pt + 1.025em) \
#repr(1.025%) \
#repr(1.025% + 1.025pt + 1.025em) \
#repr(1.025fr) \
#repr(1.035pt + 1.035em) \
#repr(1.035%) \
#repr(1.035% + 1.035pt + 1.035em) \
#repr(1.035fr) \
#repr(1.045pt + 1.045em) \
#repr(1.045%) \
#repr(1.045% + 1.045pt + 1.045em) \
#repr(1.045fr) \
1.036
rounds correctly:
#repr(1.036pt + 1.036em) \
#repr(1.036%) \
#repr(1.036% + 1.036pt + 1.036em) \
#repr(1.036fr) \
Compare that to the following, which simply changes the first digit from 1
to 2
for each component:
#repr(2.005pt + 2.005em) \
#repr(2.005%) \
#repr(2.005% + 2.005pt + 2.005em) \
#repr(2.005fr) \
#repr(2.015pt + 2.015em) \
#repr(2.015%) \
#repr(2.015% + 2.015pt + 2.015em) \
#repr(2.015fr) \
#repr(2.025pt + 2.025em) \
#repr(2.025%) \
#repr(2.025% + 2.025pt + 2.025em) \
#repr(2.025fr) \
#repr(2.035pt + 2.035em) \
#repr(2.035%) \
#repr(2.035% + 2.035pt + 2.035em) \
#repr(2.035fr) \
#repr(2.045pt + 2.045em) \
#repr(2.045%) \
#repr(2.045% + 2.045pt + 2.045em) \
#repr(2.045fr) \
As evident, em
components are also not rounded.
I would argue that none of the components should be rounded, since repr
(as stated in the documentation) is for debugging purposes. There's not much use for repr
for debugging if it doesn't precisely represent the actual value. With the fields added by #790, you can, of course, work around this, but I think my point still stands.
EDIT: The issue is also present for angle
.
Reproduction URL
No response
Operating system
Linux
Typst version
- I am using the latest version of Typst
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingscriptingAbout Typst's coding capabilitiesAbout Typst's coding capabilities