Skip to content

Commit 3133727

Browse files
hansmicodingjoe
authored andcommitted
Add point as distance unit
In typography points are a standard unit of measure and are equal to 1/72 of an inch or ca. 0.3528mm. The Portable Document Format (PDF) also specifies its standard coordinate system in 1/72 inch (PDF 32000-1:2008, section 8.3.2.3). Signed-off-by: Michael Hanselmann <[email protected]>
1 parent 4454c12 commit 3133727

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

measurement/measures/geometry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Distance(AbstractMeasure):
7171
sears_yard = Unit("0.91439841", ["sears_yd", "Yard (Sears"])
7272
survey_foot = Unit("0.304800609601", ["survey_ft", "US survey foot", "U.S. Foot"])
7373
yard = Unit("0.9144", ["yd"])
74+
point = Unit(decimal.Decimal("25.4e-3") / 72, ["pt"])
7475

7576
def __mul__(self, other):
7677
if isinstance(other, Distance):

tests/measures/test_geometry.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ def test_get_base_unit_names_for_class(self):
8383
["metre", "m", "meter", "Meter", "Metre"]
8484
)
8585

86+
def test_point(self):
87+
assert Distance(inch=3).mm == pytest.approx(Distance(pt=3 * 72).mm)
88+
assert Distance(inch=decimal.Decimal("8") / 72).mm == pytest.approx(
89+
Distance(pt=8).mm
90+
)
91+
8692

8793
class TestArea:
8894
def test_truediv(self):

0 commit comments

Comments
 (0)