{"id":13531042,"url":"https://github.com/source-foundry/font-line","last_synced_at":"2025-04-06T14:11:45.094Z","repository":{"id":41842525,"uuid":"54590641","full_name":"source-foundry/font-line","owner":"source-foundry","description":"OpenType vertical metrics reporting and font line spacing adjustment tool","archived":false,"fork":false,"pushed_at":"2023-05-11T00:57:14.000Z","size":877,"stargazers_count":189,"open_issues_count":5,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-30T12:07:51.939Z","etag":null,"topics":["ascent","descent","font","font-metrics-changes","line-spacing","metric-values","metrics-reported","open-type","python","typeface","upm","vertical-metrics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/source-foundry.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-23T20:23:59.000Z","updated_at":"2025-03-30T00:42:41.000Z","dependencies_parsed_at":"2024-06-21T18:55:37.051Z","dependency_job_id":"ca2e55ea-bb55-4091-bce3-145808d283b1","html_url":"https://github.com/source-foundry/font-line","commit_stats":{"total_commits":282,"total_committers":6,"mean_commits":47.0,"dds":"0.24113475177304966","last_synced_commit":"66941d242b683facde2265a273bb56f340434ffe"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-foundry%2Ffont-line","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-foundry%2Ffont-line/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-foundry%2Ffont-line/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-foundry%2Ffont-line/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/source-foundry","download_url":"https://codeload.github.com/source-foundry/font-line/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247492557,"owners_count":20947545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascent","descent","font","font-metrics-changes","line-spacing","metric-values","metrics-reported","open-type","python","typeface","upm","vertical-metrics"],"created_at":"2024-08-01T07:00:59.316Z","updated_at":"2025-04-06T14:11:45.075Z","avatar_url":"https://github.com/source-foundry.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cimg src =\"https://raw.githubusercontent.com/source-foundry/font-line/img/img/font-line-crunch.png\" /\u003e\n\n[![PyPI](https://img.shields.io/pypi/v/font-line?color=blueviolet\u0026label=PyPI\u0026logo=python\u0026logoColor=white)](https://pypi.org/project/font-line)\n![Python CI](https://github.com/source-foundry/font-line/workflows/Python%20CI/badge.svg)\n![Python Lints](https://github.com/source-foundry/font-line/workflows/Python%20Lints/badge.svg)\n[![codecov.io](https://codecov.io/github/source-foundry/font-line/coverage.svg?branch=master)](https://codecov.io/github/source-foundry/font-line?branch=master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d77b55866c794a5a9dd3b3dfea9ec318)](https://www.codacy.com/app/SourceFoundry/font-line)\n\n## About\n\nfont-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.\n\n## Contents\n\n- [Install Guide](https://github.com/source-foundry/font-line#install)\n- [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)\n- [Changelog](https://github.com/source-foundry/font-line/blob/master/CHANGELOG.md)\n- [License](https://github.com/source-foundry/font-line/blob/master/docs/LICENSE.md)\n\n## Quickstart\n\n- Install: `$ pip3 install font-line`\n- Metrics Report: `$ font-line report [font path]`\n- Modify line spacing: `$ font-line percent [integer %] [font path]`\n- Help: `$ font-line --help`\n\n## Install\n\nfont-line is built with Python and supports Python 3.7+ interpreters. Check your installed Python version on the command line with the command:\n\n```\n$ python3 --version\n```\n\nUse either of the following methods to install font-line on your system.\n\n### pip Install\n\nThe latest font-line release is available through the Python Package Index and can be installed with pip:\n\n```\n$ pip3 install font-line\n```\n\nTo upgrade to a new version of font-line after a pip install, use the command `pip3 install --upgrade font-line`.\n\n### Download Project Repository and Install\n\nThe current repository version (which may be ahead of the PyPI release) can be installed by [downloading the repository](https://github.com/source-foundry/font-line/archive/master.zip) or cloning it with git:\n\n```\ngit clone https://github.com/source-foundry/font-line.git\n```\n\nNavigate to the top level repository directory and enter the following command:\n\n```\n$ pip3 install .\n```\n\nFollow the same instructions to upgrade to a new version of the application if you install with this approach.\n\n## Usage\n\nfont-line works via sub-commands to the `font-line` command line executable. The following sub-commands are available:\n\n- `percent` - modify the line spacing of a font to a percent of the Ascender to Descender distance\n- `report` - report OpenType metrics values for a font\n\nUsage of these sub-commands is described in detail below.\n\n### Vertical Metrics Reporting\n\nThe following OpenType vertical metrics values and calculated values derived from these data are displayed with the `report` sub-command:\n\n- [OS/2] TypoAscender\n- [OS/2] TypoDescender\n- [OS/2] WinAscent\n- [OS/2] WinDescent\n- [OS/2] TypoLineGap\n- [OS/2] xHeight\n- [OS/2] CapHeight\n- [hhea] Ascent\n- [hhea] Descent\n- [hhea] lineGap\n- [head] unitsPerEm\n- [head] yMax\n- [head] yMin\n\n#### `report` Sub-Command Usage\n\nEnter one or more font path arguments to the command:\n\n```\n$ font-line report [fontpath 1] \u003cfontpath ...\u003e\n```\n\nHere is an example of the report generated with the Hack typeface file `Hack-Regular.ttf` using the command:\n\n```\n$ font-line report Hack-Regular.ttf\n```\n\n#### Example Font Vertical Metrics Report\n\n```\n=== Hack-Regular.ttf ===\nVersion 3.003;[3114f1256]-release\nSHA1: b1cd50ba36380d6d6ada37facfc954a8f20c15ba\n\n::::::::::::::::::::::::::::::::::::::::::::::::::\n  Metrics\n::::::::::::::::::::::::::::::::::::::::::::::::::\n[head] Units per Em:   2048\n[head] yMax:           2027\n[head] yMin:          -605\n[OS/2] CapHeight:      1493\n[OS/2] xHeight:        1120\n[OS/2] TypoAscender:   1556\n[OS/2] TypoDescender: -492\n[OS/2] WinAscent:      1901\n[OS/2] WinDescent:     483\n[hhea] Ascent:         1901\n[hhea] Descent:       -483\n\n[hhea] LineGap:        0\n[OS/2] TypoLineGap:    410\n\n::::::::::::::::::::::::::::::::::::::::::::::::::\n  Ascent to Descent Calculations\n::::::::::::::::::::::::::::::::::::::::::::::::::\n[hhea] Ascent to Descent:              2384\n[OS/2] TypoAscender to TypoDescender:  2048\n[OS/2] WinAscent to WinDescent:        2384\n\n::::::::::::::::::::::::::::::::::::::::::::::::::\n  Delta Values\n::::::::::::::::::::::::::::::::::::::::::::::::::\n[hhea] Ascent to [OS/2] TypoAscender:       345\n[hhea] Descent to [OS/2] TypoDescender:     -9\n[OS/2] WinAscent to [OS/2] TypoAscender:    345\n[OS/2] WinDescent to [OS/2] TypoDescender:  -9\n\n::::::::::::::::::::::::::::::::::::::::::::::::::\n  Baseline to Baseline Distances\n::::::::::::::::::::::::::::::::::::::::::::::::::\nhhea metrics: 2384\ntypo metrics: 2458\nwin metrics:  2384\n\n[OS/2] fsSelection USE_TYPO_METRICS bit set: False\n\n::::::::::::::::::::::::::::::::::::::::::::::::::\n  Ratios\n::::::::::::::::::::::::::::::::::::::::::::::::::\nhhea metrics / UPM:  1.16\ntypo metrics / UPM:  1.2\nwin metrics  / UPM:  1.16\n```\n\nThe 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.\n\nUnix/Linux/OS X users can write this report to a file with the `\u003e` command line idiom:\n\n```\n$ font-line report TheFont.ttf \u003e font-report.txt\n```\n\nModify the `font-report.txt` file path above to the file path string of your choice.\n\n#### Baseline to Baseline Distance Calculations\n\nBaseline 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).\n\n##### hhea Metrics\n\n```\nBTBD = hhea.Ascent + abs(hhea.Descent) + hhea.LineGap\n```\n\n##### typo Metrics\n\n```\nBTBD = OS/2.typoAscent + abs(OS/2.typoDescent) + OS/2.typoLineGap\n```\n\n##### win Metrics\n\n```\nBTBD = OS/2.winAscent + OS/2.winDescent + [External Leading]\n```\n\nwhere external leading is defined as:\n\n```\nMAX(0, hhea.LineGap - ((OS/2.WinAscent + OS/2.winDescent) - (hhea.Ascent - hhea.Descent)))\n```\n\n### Vertical Metrics Modifications\n\nfont-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.\n\n#### `percent` Sub-Command Usage\n\nEnter 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.\n\n```\n$ font-line percent [percent change] [fontpath 1] \u003cfontpath ...\u003e\n```\n\nA 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:\n\n```\n$ font-line percent 20 TheFont.ttf\n```\n\nIncrease or decrease the integer value to increase or decrease your line spacing accordingly.\n\nThe 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.\n\nYou can inspect the vertical metrics in the new font file with the `report` sub-command (see Usage above).\n\n#### Details of Font Metrics Changes with `percent` Sub-Command\n\nThe 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.\n\nfont-line currently supports three commonly used vertical metrics approaches.\n\n**Vertical Metrics Approach 1**:\n\nWhere metrics are defined as:\n\n- [OS/2] TypoLinegap = 0\n- [hhea] linegap = 0\n- [OS/2] TypoAscender = [OS/2] winAscent = [hhea] Ascent\n- [OS/2] TypoDescender = [OS/2] winDescent = [hhea] Descent\n\nfont-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.\n\n**Vertical Metrics Approach 2**\n\nWhere metrics are defined as:\n\n- [OS/2] TypoLinegap = 0\n- [hhea] linegap = 0\n- [OS/2] TypoAscender + TypoDescender = UPM\n- [OS/2] winAscent = [hhea] Ascent\n- [OS/2] winDescent = [hhea] Descent\n\nfont-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.\n\n**Vertical Metrics Approach 3**\n\nWhere metrics are defined as:\n\n- [OS/2] TypoAscender + TypoDescender = UPM\n- [OS/2] TypoLinegap is set to leading value\n- [hhea] linegap = 0\n- [OS/2] winAscent = [hhea] Ascent\n- [OS/2] winDescent = [hhea] Descent\n\n_Changes to the metrics values in the font are defined as_:\n\n- [OS/2] TypoLineGap = x% \\* UPM value\n- [hhea] Ascent = [OS/2] TypoAscender + 0.5(modified TypoLineGap)\n- [hhea] Descent = [OS/2] TypoDescender + 0.5(modified TypoLineGap)\n- [OS/2] WinAscent = [OS/2] TypoAscender + 0.5(modified TypoLineGap)\n- [OS/2] WinDescent = [OS/2] TypoDescender + 0.5(modified TypoLineGap)\n\nNote that the internal leading modifications are split evenly across [hhea] Ascent \u0026 Descent values, and across [OS/2] WinAscent \u0026 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.\n\n### Important\n\nThe 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.\n\n## Issue Reporting\n\nPlease [submit a new issue report](https://github.com/source-foundry/font-line/issues/new) on the project repository.\n\n## Acknowledgments\n\nfont-line is built with the fantastic [fontTools](https://github.com/fonttools/fonttools) Python library.\n\n## License\n\nMIT License. See [LICENSE.md](docs/LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-foundry%2Ffont-line","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsource-foundry%2Ffont-line","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-foundry%2Ffont-line/lists"}