Skip to content

Commit

Permalink
Merge pull request #25 from source-foundry/dev
Browse files Browse the repository at this point in the history
v3.1.0
  • Loading branch information
chrissimpkins authored Mar 29, 2020
2 parents 885f6b1 + 4c76831 commit e9fd094
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 68 deletions.
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,32 @@ matrix:
script: flake8 --ignore=E501,W503 lib/fontline/*.py
- python: 3.6
env: TOX_ENV=py36
install: pip install tox
install:
- pip install tox
script: tox -e $TOX_ENV
- python: 3.7
env: TOX_ENV=py37
install: pip install tox
install:
- pip install tox
dist: xenial
script: tox -e $TOX_ENV
- python: 3.8
env: TOX_ENV=py38
install:
- pip install tox
dist: xenial
script: tox -e $TOX_ENV
- python: 3.7
dist: xenial
env: TOX_ENV=coverage
install:
- pip install --upgrade coverage
- pip install .
- pip install -r requirements.txt .
script:
- coverage run --source fontline -m py.test
- coverage report -m
after_success:
- bash <(curl -s https://codecov.io/bash)

notifications:
email: false
email: false
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Changelog

### v3.1.0

- add requirements.txt file with pinned dependency versions
- update all build dependencies to current release versions
- the fontTools dependency updates add support for Unicode 13
- convert PyPI documentation to repository README Markdown file
- add Py3.8 interpreter to CI testing

### v3.0.0

- added baseline to baseline distance calculations for hhea, typo, and win metrics to reports
Expand All @@ -18,7 +26,7 @@
- modified Travis CI testing to Python 3.5 - 3.7
- refactored Appveyor CI settings file
- modified Appveyor CI testing to Python 3.5 - 3.7
-
-

### v1.0.1

Expand Down Expand Up @@ -52,8 +60,8 @@

- modified percent command calculations to maintain vertical metrics approaches in the original font design
- added vertical metrics modification support for fonts designed with the following vertical metrics approaches:
- Google style metrics where TypoLinegap = hhea linegap = 0, internal leading is present in [OS/2] TypoAsc/TypoDesc, [hhea] Asc/Desc, [OS/2] winAsc/winDesc
- Adobe style metrics where TypoLinegap = hhea linegap = 0, TypoAsc - TypoDesc = UPM, internal leading in [hhea] Asc/Desc & [OS/2] winAsc/winDesc
- Google style metrics where TypoLinegap = hhea linegap = 0, internal leading is present in [OS/2] TypoAsc/TypoDesc, [hhea] Asc/Desc, [OS/2] winAsc/winDesc
- Adobe style metrics where TypoLinegap = hhea linegap = 0, TypoAsc - TypoDesc = UPM, internal leading in [hhea] Asc/Desc & [OS/2] winAsc/winDesc

### v0.5.4

Expand Down
43 changes: 19 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<img src ="https://raw.githubusercontent.com/source-foundry/font-line/img/img/font-line-crunch.png" />


[![PyPI](https://img.shields.io/pypi/v/font-line.svg)](https://pypi.org/project/font-line)
[![PyPI](https://img.shields.io/pypi/v/font-line?color=blueviolet&label=PyPI&logo=python&logoColor=white)](https://pypi.org/project/font-line)
[![Build Status](https://travis-ci.org/source-foundry/font-line.svg?branch=master)](https://travis-ci.org/source-foundry/font-line)
[![Build status](https://ci.appveyor.com/api/projects/status/2s4725o5mxh2298c/branch/master?svg=true)](https://ci.appveyor.com/project/chrissimpkins/font-line/branch/master)
[![Build status](https://ci.appveyor.com/api/projects/status/2s4725o5mxh2298c/branch/master?svg=true)](https://ci.appveyor.com/project/chrissimpkins/font-line/branch/master)
[![codecov.io](https://codecov.io/github/source-foundry/font-line/coverage.svg?branch=master)](https://codecov.io/github/source-foundry/font-line?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d77b55866c794a5a9dd3b3dfea9ec318)](https://www.codacy.com/app/SourceFoundry/font-line)

## About
font-line is a libre, open source command line tool for OpenType vertical metrics reporting and command line based font line spacing modifications. It supports `.ttf` and `.otf` font builds.

font-line is a libre, open source command line tool for OpenType vertical metrics reporting and command line based font line spacing modifications. It supports `.ttf` and `.otf` font builds.

## Contents

- [Install Guide](https://github.com/source-foundry/font-line#install)
- [Usage](https://github.com/source-foundry/font-line#usage)
- [Vertical Metrics Reporting](https://github.com/source-foundry/font-line#vertical-metrics-reporting)
- [Line Spacing Modifications](https://github.com/source-foundry/font-line#vertical-metrics-modifications)
- [Usage](https://github.com/source-foundry/font-line#usage) - [Vertical Metrics Reporting](https://github.com/source-foundry/font-line#vertical-metrics-reporting) - [Line Spacing Modifications](https://github.com/source-foundry/font-line#vertical-metrics-modifications)
- [Changelog](https://github.com/source-foundry/font-line/blob/master/CHANGELOG.md)
- [License](https://github.com/source-foundry/font-line/blob/master/docs/LICENSE.md)

Expand Down Expand Up @@ -64,7 +62,7 @@ Follow the same instructions to upgrade to a new version of the application if y

## Usage

font-line works via sub-commands to the `font-line` command line executable. The following sub-commands are available:
font-line works via sub-commands to the `font-line` command line executable. The following sub-commands are available:

- `percent` - modify the line spacing of a font to a percent of the Ascender to Descender distance
- `report` - report OpenType metrics values for a font
Expand Down Expand Up @@ -104,6 +102,7 @@ $ font-line report Hack-Regular.ttf
```

#### Example Font Vertical Metrics Report

```
=== Hack-Regular.ttf ===
Version 3.003;[3114f1256]-release
Expand Down Expand Up @@ -197,34 +196,33 @@ where external leading is defined as:
MAX(0, hhea.LineGap - ((OS/2.WinAscent + OS/2.winDescent) - (hhea.Ascent - hhea.Descent)))
```


### Vertical Metrics Modifications

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.
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.

#### `percent` Sub-Command Usage

Enter the desired percentage of the UPM as the first argument to the command. This should be *entered as an integer value*. Then enter one or more font paths to which you would like to apply your font metrics changes.
Enter the desired percentage of the UPM as the first argument to the command. This should be _entered as an integer value_. Then enter one or more font paths to which you would like to apply your font metrics changes.

```
$ font-line percent [percent change] [fontpath 1] <fontpath ...>
```

A common default value used by typeface designers is 20% UPM. To modify a font on the path `TheFont.ttf` to 20% of the UPM metric, you would enter the following command:
A common default value used by typeface designers is 20% UPM. To modify a font on the path `TheFont.ttf` to 20% of the UPM metric, you would enter the following command:

```
$ font-line percent 20 TheFont.ttf
```

Increase or decrease the integer value to increase or decrease your line spacing accordingly.

The original font file is preserved in an unmodified version and the modified file write takes place on a new path defined as `[original filename]-linegap[percent].[ttf|otf]`. The path to the file is reported to you in the standard output after the modification is completed. font-line does not modify the glyph set or hints applied to the font. See the Details section below for a description of the OpenType table modifications that occur when the application is used on a font file.
The original font file is preserved in an unmodified version and the modified file write takes place on a new path defined as `[original filename]-linegap[percent].[ttf|otf]`. The path to the file is reported to you in the standard output after the modification is completed. font-line does not modify the glyph set or hints applied to the font. See the Details section below for a description of the OpenType table modifications that occur when the application is used on a font file.

You can inspect the vertical metrics in the new font file with the `report` sub-command (see Usage above).

#### Details of Font Metrics Changes with `percent` Sub-Command

The interpretation and display of these multiple vertical metrics values is platform and application dependent. [There is no broadly accepted "best" approach](https://github.com/source-foundry/font-line/issues/2). As such, font-line attempts to preserve the original metrics design in the font when modifications are made with the `percent` sub-command.
The interpretation and display of these multiple vertical metrics values is platform and application dependent. [There is no broadly accepted "best" approach](https://github.com/source-foundry/font-line/issues/2). As such, font-line attempts to preserve the original metrics design in the font when modifications are made with the `percent` sub-command.

font-line currently supports three commonly used vertical metrics approaches.

Expand All @@ -237,7 +235,7 @@ Where metrics are defined as:
- [OS/2] TypoAscender = [OS/2] winAscent = [hhea] Ascent
- [OS/2] TypoDescender = [OS/2] winDescent = [hhea] Descent

font-line calculates a delta value for the total expected height based upon the % UPM value defined on the command line. The difference between this value and the observed number of units that span the [OS/2] winAscent to winDescent values is divided by half and then added to (for increased line spacing) or subtracted from (for decreased line spacing) each of the three sets of Ascender/Descender values in the font. The [OS/2] TypoLinegap and [hhea] linegap values are not modified.
font-line calculates a delta value for the total expected height based upon the % UPM value defined on the command line. The difference between this value and the observed number of units that span the [OS/2] winAscent to winDescent values is divided by half and then added to (for increased line spacing) or subtracted from (for decreased line spacing) each of the three sets of Ascender/Descender values in the font. The [OS/2] TypoLinegap and [hhea] linegap values are not modified.

**Vertical Metrics Approach 2**

Expand All @@ -249,7 +247,7 @@ Where metrics are defined as:
- [OS/2] winAscent = [hhea] Ascent
- [OS/2] winDescent = [hhea] Descent

font-line calculates a delta value for the total expected height based upon the % UPM value defined on the command line. The difference between this value and the observed number of units that span the [OS/2] winAscent to winDescent values is divided by half and then added to (for increased line spacing) or subtracted from (for decreased line spacing) the [OS/2] winAsc/winDesc and [hhea] Asc/Desc values. The [OS/2] TypoAsc/TypoDesc values are not modified and maintain a definition of size = UPM value. The [OS/2] TypoLinegap and [hhea] linegap values are not modified.
font-line calculates a delta value for the total expected height based upon the % UPM value defined on the command line. The difference between this value and the observed number of units that span the [OS/2] winAscent to winDescent values is divided by half and then added to (for increased line spacing) or subtracted from (for decreased line spacing) the [OS/2] winAsc/winDesc and [hhea] Asc/Desc values. The [OS/2] TypoAsc/TypoDesc values are not modified and maintain a definition of size = UPM value. The [OS/2] TypoLinegap and [hhea] linegap values are not modified.

**Vertical Metrics Approach 3**

Expand All @@ -261,31 +259,28 @@ Where metrics are defined as:
- [OS/2] winAscent = [hhea] Ascent
- [OS/2] winDescent = [hhea] Descent

*Changes to the metrics values in the font are defined as*:
_Changes to the metrics values in the font are defined as_:

- [OS/2] TypoLineGap = x% * UPM value
- [OS/2] TypoLineGap = x% \* UPM value
- [hhea] Ascent = [OS/2] TypoAscender + 0.5(modified TypoLineGap)
- [hhea] Descent = [OS/2] TypoDescender + 0.5(modified TypoLineGap)
- [OS/2] WinAscent = [OS/2] TypoAscender + 0.5(modified TypoLineGap)
- [OS/2] WinDescent = [OS/2] TypoDescender + 0.5(modified TypoLineGap)

Note that the internal leading modifications are split evenly across [hhea] Ascent & Descent values, and across [OS/2] WinAscent & WinDescent values. We add half of the new [OS/2] TypoLineGap value to the original [OS/2] TypoAscender or TypoDescender in order to define these new metrics properties. The [hhea] linegap value is always defined as zero.
Note that the internal leading modifications are split evenly across [hhea] Ascent & Descent values, and across [OS/2] WinAscent & WinDescent values. We add half of the new [OS/2] TypoLineGap value to the original [OS/2] TypoAscender or TypoDescender in order to define these new metrics properties. The [hhea] linegap value is always defined as zero.

### Important

The newly defined vertical metrics values can lead to clipping of glyph components if not properly defined. There are no tests in font-line to provide assurance that this does not occur. We assume that the user is versed in these issues before use of the application and leave this testing to the designer / user before the modified fonts are used in a production setting.

The newly defined vertical metrics values can lead to clipping of glyph components if not properly defined. There are no tests in font-line to provide assurance that this does not occur. We assume that the user is versed in these issues before use of the application and leave this testing to the designer / user before the modified fonts are used in a production setting.

## Issue Reporting

Please [submit a new issue report](https://github.com/source-foundry/font-line/issues/new) on the project repository.


## Acknowledgments

font-line is built with the fantastic [fontTools](https://github.com/fonttools/fonttools) Python library.


## License

MIT License. See [LICENSE.md](docs/LICENSE.md) for details.
MIT License. See [LICENSE.md](docs/LICENSE.md) for details.
8 changes: 6 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ environment:
PYTHON_HOME: "C:\\Python37-x64"
TOX_PY: py37

- JOB: "3.8 64-bit"
PYTHON_HOME: "C:\\Python38-x64"
TOX_PY: py38

install:
# Prepend Python to the PATH of this build
- "SET PATH=%PYTHON_HOME%;%PYTHON_HOME%\\Scripts;%PATH%"

# check that we have the expected version and architecture for Python
- "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
- 'python -c "import struct; print(struct.calcsize(''P'') * 8)"'

# upgrade pip and setuptools to avoid out-of-date warnings
- "python -m pip install --disable-pip-version-check --user --upgrade pip setuptools virtualenv"
Expand All @@ -36,4 +40,4 @@ branches:
- /^v\d+\.\d+.*$/

test_script:
- "tox -e %TOX_PY%"
- "tox -e %TOX_PY%"
2 changes: 1 addition & 1 deletion lib/fontline/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Version Number
# ------------------------------------------------------------------------------
major_version = "3"
minor_version = "0"
minor_version = "1"
patch_version = "0"

# ------------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile
#
commandlines==0.4.1 # via font-line (setup.py)
fonttools==4.6.0 # via font-line (setup.py)
standardstreams==0.2.0 # via font-line (setup.py)
74 changes: 42 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import io
import os
import re
import sys
from setuptools import setup, find_packages


def docs_read(fname):
return open(os.path.join(os.path.dirname(__file__), 'docs', fname)).read()
# Use repository Markdown README.md for PyPI long description
try:
with io.open("README.md", encoding="utf-8") as f:
readme = f.read()
except IOError as readme_e:
sys.stderr.write(
"[ERROR] setup.py: Failed to read the README.md file for the long description definition: {}".format(
str(readme_e)
)
)
raise readme_e


def version_read():
settings_file = open(os.path.join(os.path.dirname(__file__), 'lib', 'fontline', 'settings.py')).read()
settings_file = open(
os.path.join(os.path.dirname(__file__), "lib", "fontline", "settings.py")
).read()
major_regex = """major_version\s*?=\s*?["']{1}(\d+)["']{1}"""
minor_regex = """minor_version\s*?=\s*?["']{1}(\d+)["']{1}"""
patch_regex = """patch_version\s*?=\s*?["']{1}(\d+)["']{1}"""
Expand All @@ -28,38 +41,35 @@ def version_read():


setup(
name='font-line',
name="font-line",
version=version_read(),
description='A font vertical metrics reporting and line spacing adjustment tool',
long_description=(docs_read('README.rst')),
url='https://github.com/source-foundry/font-line',
license='MIT license',
author='Christopher Simpkins',
author_email='[email protected]',
platforms=['any'],
description="A font vertical metrics reporting and line spacing adjustment tool",
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/source-foundry/font-line",
license="MIT license",
author="Christopher Simpkins",
author_email="[email protected]",
platforms=["any"],
packages=find_packages("lib"),
package_dir={'': 'lib'},
install_requires=['commandlines', 'standardstreams', 'fontTools'],
entry_points={
'console_scripts': [
'font-line = fontline.app:main'
],
},
keywords='font,typeface,fonts,spacing,line spacing,spaces,vertical metrics,metrics,type',
package_dir={"": "lib"},
install_requires=["commandlines", "standardstreams", "fontTools"],
entry_points={"console_scripts": ["font-line = fontline.app:main"],},
keywords="font,typeface,fonts,spacing,line spacing,spaces,vertical metrics,metrics,type",
include_package_data=True,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Natural Language :: English',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries :: Python Modules',
"Development Status :: 5 - Production/Stable",
"Natural Language :: English",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tox]
envlist = py27, py36, py37
envlist = py37

[testenv]
commands =
py.test tests
;- coverage run --source {{fontline}} -m py.test
;- coverage report
deps =
-rrequirements.txt
pytest
fontTools

[testenv:flake8]
deps =
Expand Down

0 comments on commit e9fd094

Please sign in to comment.