Skip to content

Commit 885f6b1

Browse files
Merge pull request #24 from source-foundry/dev
Add baseline to baseline distance calculations across typo, hhea, win metrics, add OS/2.fsSelection USE_TYPO_METRICS bit setting
2 parents 7cc5f91 + 077a498 commit 885f6b1

File tree

13 files changed

+382
-162
lines changed

13 files changed

+382
-162
lines changed

.travis.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ matrix:
99
env: TOX_ENV=lint
1010
install: pip install flake8
1111
script: flake8 --ignore=E501,W503 lib/fontline/*.py
12-
- python: 3.5
13-
env: TOX_ENV=py35
14-
install: pip install tox
15-
script: tox -e $TOX_ENV
1612
- python: 3.6
1713
env: TOX_ENV=py36
1814
install: pip install tox
@@ -22,6 +18,17 @@ matrix:
2218
install: pip install tox
2319
dist: xenial
2420
script: tox -e $TOX_ENV
21+
- python: 3.7
22+
dist: xenial
23+
env: TOX_ENV=coverage
24+
install:
25+
- pip install --upgrade coverage
26+
- pip install .
27+
script:
28+
- coverage run --source fontline -m py.test
29+
- coverage report -m
30+
after_success:
31+
- bash <(curl -s https://codecov.io/bash)
2532

2633
notifications:
2734
email: false

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
## Changelog
22

3+
### v3.0.0
4+
5+
- added baseline to baseline distance calculations for hhea, typo, and win metrics to reports
6+
- added fsSelection bit 7 `USE_TYPO_METRICS` bit flag setting to report
7+
- standard output report formatting improvements for `report` subcommand
8+
- removed Py3.5 interpreter testing, we will support for Py3.6+ only as of this release
9+
- add support for automated source code coverage push to Codecov from Travis
10+
311
### v2.0.0
412

513
- changed copyright notice from "Christopher Simpkins" to "Source Foundry Authors"

README.md

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ font-line is a libre, open source command line tool for OpenType vertical metric
2828

2929
## Install
3030

31-
font-line is built with Python and is tested with Python 3.5+ interpreters. You can verify your installed Python version on the command line with the command:
31+
font-line is built with Python and is tested with Python 3.6+ interpreters. You can verify your installed Python version on the command line with the command:
3232

3333
```
3434
$ python3 --version
@@ -106,40 +106,57 @@ $ font-line report Hack-Regular.ttf
106106
#### Example Font Vertical Metrics Report
107107
```
108108
=== Hack-Regular.ttf ===
109-
Version 3.001; 379b3ad6d-dev
110-
SHA1: 20d02edca75f2d23787e80161a64418598c850de
111-
112-
--- Metrics ---
113-
[head] Units per Em: 2048
114-
[head] yMax: 2027
115-
[head] yMin: -605
116-
[OS/2] CapHeight: 1493
117-
[OS/2] xHeight: 1120
118-
[OS/2] TypoAscender: 1556
119-
[OS/2] TypoDescender: -492
120-
[OS/2] WinAscent: 1901
121-
[OS/2] WinDescent: 483
122-
[hhea] Ascent: 1901
123-
[hhea] Descent: -483
124-
125-
[hhea] LineGap: 0
126-
[OS/2] TypoLineGap: 410
127-
128-
--- Height Calculations by Table Values ---
129-
[OS/2] TypoAscender to TypoDescender: 2048
130-
[OS/2] WinAscent to WinDescent: 2384
131-
[hhea] Ascent to Descent: 2384
132-
133-
--- Delta Values ---
134-
WinAscent to TypoAscender: 345
135-
Ascent to TypoAscender: 345
136-
WinDescent to TypoDescender: -9
137-
Descent to TypoDescender: -9
138-
139-
--- Ratios ---
140-
(Typo Asc + Desc + Linegap) / UPM: 1.2
141-
(winAsc + winDesc) / UPM: 1.16
142-
(hhea Asc + Desc) / UPM: 1.16
109+
Version 3.003;[3114f1256]-release
110+
SHA1: b1cd50ba36380d6d6ada37facfc954a8f20c15ba
111+
112+
::::::::::::::::::::::::::::::::::::::::::::::::::
113+
Metrics
114+
::::::::::::::::::::::::::::::::::::::::::::::::::
115+
[head] Units per Em: 2048
116+
[head] yMax: 2027
117+
[head] yMin: -605
118+
[OS/2] CapHeight: 1493
119+
[OS/2] xHeight: 1120
120+
[OS/2] TypoAscender: 1556
121+
[OS/2] TypoDescender: -492
122+
[OS/2] WinAscent: 1901
123+
[OS/2] WinDescent: 483
124+
[hhea] Ascent: 1901
125+
[hhea] Descent: -483
126+
127+
[hhea] LineGap: 0
128+
[OS/2] TypoLineGap: 410
129+
130+
::::::::::::::::::::::::::::::::::::::::::::::::::
131+
Ascent to Descent Calculations
132+
::::::::::::::::::::::::::::::::::::::::::::::::::
133+
[hhea] Ascent to Descent: 2384
134+
[OS/2] TypoAscender to TypoDescender: 2048
135+
[OS/2] WinAscent to WinDescent: 2384
136+
137+
::::::::::::::::::::::::::::::::::::::::::::::::::
138+
Delta Values
139+
::::::::::::::::::::::::::::::::::::::::::::::::::
140+
[hhea] Ascent to [OS/2] TypoAscender: 345
141+
[hhea] Descent to [OS/2] TypoDescender: -9
142+
[OS/2] WinAscent to [OS/2] TypoAscender: 345
143+
[OS/2] WinDescent to [OS/2] TypoDescender: -9
144+
145+
::::::::::::::::::::::::::::::::::::::::::::::::::
146+
Baseline to Baseline Distances
147+
::::::::::::::::::::::::::::::::::::::::::::::::::
148+
hhea metrics: 2384
149+
typo metrics: 2458
150+
win metrics: 2384
151+
152+
[OS/2] fsSelection USE_TYPO_METRICS bit set: False
153+
154+
::::::::::::::::::::::::::::::::::::::::::::::::::
155+
Ratios
156+
::::::::::::::::::::::::::::::::::::::::::::::::::
157+
hhea metrics / UPM: 1.16
158+
typo metrics / UPM: 1.2
159+
win metrics / UPM: 1.16
143160
```
144161

145162
The report includes the font version string, a SHA-1 hash digest of the font file, and OpenType table metrics that are associated with line spacing in the font.
@@ -152,6 +169,35 @@ $ font-line report TheFont.ttf > font-report.txt
152169

153170
You can modify the `font-report.txt` file path above to the file path string of your choice.
154171

172+
#### Baseline to Baseline Distance Calculations
173+
174+
Baseline to baseline distance (BTBD) calculations are performed according to the [Microsoft Recommendations for OpenType Fonts](https://docs.microsoft.com/en-us/typography/opentype/spec/recom#baseline-to-baseline-distances) and [OpenType OS/2 table specification](https://docs.microsoft.com/en-us/typography/opentype/spec/os2).
175+
176+
##### hhea Metrics
177+
178+
```
179+
BTBD = hhea.Ascent + abs(hhea.Descent) + hhea.LineGap
180+
```
181+
182+
##### typo Metrics
183+
184+
```
185+
BTBD = OS/2.typoAscent + abs(OS/2.typoDescent) + OS/2.typoLineGap
186+
```
187+
188+
##### win Metrics
189+
190+
```
191+
BTBD = OS/2.winAscent + OS/2.winDescent + [External Leading]
192+
```
193+
194+
where external leading is defined as:
195+
196+
```
197+
MAX(0, hhea.LineGap - ((OS/2.WinAscent + OS/2.winDescent) - (hhea.Ascent - hhea.Descent)))
198+
```
199+
200+
155201
### Vertical Metrics Modifications
156202

157203
font-line supports automated line spacing modifications to a user-defined percentage of the units per em metric. This value will be abbreviated as UPM below.

appveyor.yml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,14 @@
11
environment:
22
matrix:
3-
- JOB: "3.5 64-bit"
4-
PYTHON_HOME: "C:\\Python35-x64"
5-
TOX_PY: py35
6-
7-
- JOB: "3.6 64-bit"
8-
PYTHON_HOME: "C:\\Python36-x64"
3+
- JOB: "3.6 32-bit"
4+
PYTHON_HOME: "C:\\Python36"
95
TOX_PY: py36
106

117
- JOB: "3.7 64-bit"
128
PYTHON_HOME: "C:\\Python37-x64"
139
TOX_PY: py37
1410

15-
- JOB: "3.7 32-bit"
16-
PYTHON_HOME: "C:\\Python37"
17-
TOX_PY: py37
18-
1911
install:
20-
# If there is a newer build queued for the same PR, cancel this one.
21-
# The AppVeyor 'rollout builds' option is supposed to serve the same
22-
# purpose but it is problematic because it tends to cancel builds pushed
23-
# directly to master instead of just PR builds (or the converse).
24-
# credits: JuliaLang developers.
25-
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
26-
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
27-
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
28-
throw "There are newer queued builds for this pull request, failing early." }
29-
3012
# Prepend Python to the PATH of this build
3113
- "SET PATH=%PYTHON_HOME%;%PYTHON_HOME%\\Scripts;%PATH%"
3214

@@ -35,12 +17,23 @@ install:
3517
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
3618

3719
# upgrade pip and setuptools to avoid out-of-date warnings
38-
- "python -m pip install --disable-pip-version-check --user --upgrade pip setuptools"
20+
- "python -m pip install --disable-pip-version-check --user --upgrade pip setuptools virtualenv"
3921

40-
# install the test dependencies
41-
- "python -m pip install tox"
22+
# install the dependencies to run the tests
23+
- "python -m pip install --upgrade tox pytest"
4224

4325
build: false
4426

45-
test_script:
27+
# The following prevents Travis from running CI on pull requests that come from a
28+
# branch in the same repository. Without this, it will run the same CI for the
29+
# pull request branch _and_ the pull request itself, which makes no sense.
30+
branches:
31+
only:
32+
- master
33+
# We want to build wip/* branches since these are not usually used for PRs
34+
- /^wip\/.*$/
35+
# We want to build version tags as well.
36+
- /^v\d+\.\d+.*$/
37+
38+
test_script:
4639
- "tox -e %TOX_PY%"

codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
codecov:
22
max_report_age: off
3+
4+
coverage:
5+
status:
6+
project:
7+
default:
8+
# basic
9+
target: auto
10+
threshold: 2%
11+
base: auto
12+
13+
comment: off

lib/fontline/app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
"""
54
The app.py module defines a main() function that includes the logic for the `font-line` command line executable.
@@ -23,7 +22,6 @@
2322

2423
# TODO: support integer addition and subtraction to the metrics values through new sub-commands
2524
# TODO: JSON formatted metrics output
26-
# TODO: add report line items for 'exceeds ymax/ymin values' across each of the three metrics
2725

2826

2927
def main():

0 commit comments

Comments
 (0)