Vfblib

Latest version: v0.7.1

Safety actively analyzes 688823 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 3

0.6.0

Support TrueType hinting in Composites in UFO (9).

Example: For a composite glyph consisting of three components

xml
<glyph name="onehalf" format="2">
<unicode hex="00BD"/>
<advance width="845"/>
<outline>
<component base="onesuperior"/>
<component base="fraction" xOffset="244"/>
<component base="twosuperior" xOffset="421" yOffset="-413"/>
</outline>
</glyph>


in which the bottom of the `twosuperior` component is aligned to zone `b: 3`, this hinting representation is generated:

xml
<ttProgram>
<ttc code="alignb" point="ab01-2" zone="b: 3"/>
</ttProgram>


The point label `ab01` is added to the second component, `twosuperior`, and is suffixed with the component index, 2, so it is clear in which component a hinting compiler should look for the labelled point.

0.5.5

- Fix decoding Mac name records in Python < 3.11 (41)

0.5.4

- [UFO] Don't change names of kerning classes (thanks frankrolf)
- [UFO] FL kerning "key glyphs" are now stored in the font lib key `com.lucasfonts.vfblib.groupKeyGlyphs`
- [UFO] Store original group order in the font lib key `com.lucasfonts.vfblib.groupOrder`
- [UFO] Make sure styleMapStyleName is not empty
- [UFO] Add OT classes to feature code later so that classes have already been sanitized
- [UFO] Respect ignored entries in minmal mode again

0.5.3

This release updates the dependencies only.

0.5.2

What's new?

- Reimplemented parsing of VFB files, retired old `VfbReader` class in favour of new `Vfb` class
- Implement UFO-like interface directly to the `Vfb` class, as far as needed for `draw()`/`drawPoints()` on the glyph class
- Implement compilation and esp. glyph compilation to facilitate write access via `getPen()`/`getPointPen()` on the glyph class
- Disambiguate duplicate glyph names
- Support VFB files written by FontLab 3
- Fix encoding of manual name table entries for the Mac platform
- Raise exceptions when a file exists, or when decompilation fails
- `vfb2json`: New JSON structure for export, which allows to selectively decompile data entries while keeping others as binary
- `vfb2json`: Default output file now gets `.vfb.json` suffix
- `vfb2json`: Add option to only parse the VFB header (`-h`/`--header`)
- `vfb3ufo`: Build UFOs in memory with `ufoLib2` instead of using `UfoWriter` directly
- `vfb3ufo`: Set previously missing Glyph.height
- `vfb3ufo`: Support writing `.ufoz`
- `vfb3ufo`: Add option to interpret strings as UTF-8 instead of Windows-1252 (`-u`/`--unicode`)
- `vfbcu2qu`: New command line script to convert VFBs to TrueType (quadratic) curves


Install or update [vfbLib via pip](https://pypi.org/project/vfbLib/).

TrueType conversion

VFBs can now be directly converted to TrueType, using the industry-standard [cu2qu](https://github.com/fonttools/fonttools/tree/main/Lib/fontTools/cu2qu) library.

plain
$ vfbcu2qu -h
usage: vfbcu2qu [-h] [-p PATH] [-fo] [-m MAX_ERR_EM] inputpath [outputpath]

VFB Cubic to Quadratic Converter Copyright (c) 2023 by LucasFonts Build 2023-07-19

positional arguments:
inputpath input file path (.vfb)
outputpath output file path (.vfb)

options:
-h, --help show this help message and exit
-p PATH, --path PATH output folder
-fo, --force-overwrite
force overwrite
-m MAX_ERR_EM, --max-err-em MAX_ERR_EM
Maximum allowed error, relative to the font's units per em.


Improved UFO workflow

If you are using a UFO workflow, but don’t want to save the UFOs converted from a VFB to disk, you can now keep them in memory. This new functionality uses the `ufoLib2` library, a new dependency.

Read and convert a VFB like this:

python
from vfbLib.vfb.vfb import Vfb
from vfbLib.ufo.builder import VfbToUfoBuilder

vfb = Vfb("path/to/my.vfb")
ufo_builder = VfbToUfoBuilder(vfb)

Save UFOs and Designspace document, as before ...
ufo_builder.write("path/to/my.ufo")
Writes "path/to/my.ufo"
"path/to/my-1.ufo"
"path/to/my-2.ufo"
"path/to/my-3.ufo"
"path/to/my.designspace"
(for a VFB with 4 masters)

... or convert in memory and do something with the UFOs and designspace:
ufos, ds = ufo_builder.get_ufos_designspace("path/to/my.ufo")
The out_path is only used to construct the source paths inside the designspace document.

... or, if you only need the UFOs:
ufos = ufo_builder.get_ufo_masters()


Using pens on VFBs

You can now draw glyphs from VFBs directly to an object supporting the pen protocol, e.g. in a DrawBot script:

python
from vfbLib.vfb.vfb import Vfb

size(1000, 1000)

vfb_path = "vfbLib/Tests/Data/ComicJensPro-Regular.vfb"

vfb = Vfb(vfb_path)
g = vfb["Adieresis"]
bez = BezierPath()
g.drawPoints(bez)
drawPath(bez)


You can also draw into the Vfb by requesting a pen from a glyph, but this currently only supports TrueType curves:

python
from vfbLib.vfb.vfb import Vfb

vfb_path = "vfbLib/Tests/Data/ComicJensPro-Regular.vfb"

vfb = Vfb(vfb_path)
g = vfb["a"]
g.clearContours()
pen = g.getPointPen()
pen.beginPath()
pen.addPoint((92, 0), "line", False, None)
pen.addPoint((92, 698), "line", False, None)
pen.addPoint((277, 698), "line", False, None)
pen.addPoint((336, 698), None, False, None)
pen.addPoint((419, 657), None, False, None)
pen.addPoint((461, 579), None, False, None)
pen.addPoint((461, 526), "qcurve", False, None)
pen.addPoint((461, 471), None, False, None)
pen.addPoint((420, 391), None, False, None)
pen.addPoint((381, 371), "qcurve", False, None)
pen.addPoint((416, 363), None, False, None)
pen.addPoint((472, 314), None, False, None)
pen.addPoint((502, 242), None, False, None)
pen.addPoint((502, 200), "qcurve", False, None)
pen.addPoint((502, 138), None, False, None)
pen.addPoint((451, 47), None, False, None)
pen.addPoint((358, 0), None, False, None)
pen.addPoint((296, 0), "qcurve", False, None)
pen.endPath()
vfb.write("vfbLib/Tests/Data/ComicJensPro-Regular_modified.vfb")

0.4.6

What's new?

- Bugfix for TrueType hinting stem assignment

Install or update [vfbLib via pip](https://pypi.org/project/vfbLib/).

Designspace export

I’m happy that there is now basic support for exporting a designspace file.

Tip for Glyphs.app users: You can open the designspace file in Glyphs and will get a matching multiple master Glyphs file.

You probably need to manually edit the exported file to suit your needs, but basically you can now generate static or variable fonts from a VFB with `vfb3ufo` and [fontmake](https://github.com/googlefonts/fontmake):

plain
$ vfb3ufo TheSansC4sTT.vfb
VFB3UFO Converter
Copyright (c) 2022 by LucasFonts
Build 2023-04-18
Reading file TheSansC4sTT.vfb ...
Source file was successfully imported in 346 ms.
Processing font: TheSans Variable C4s, master 0
Processing font: TheSans Variable C4s, master 1
Writing designspace: TheSansC4sTT.designspace
$ fontmake -m TheSansC4sTT.designspace -o ttf --keep-overlaps --keep-direction -i --output-dir instances
$ fontmake -m TheSansC4sTT.designspace -o variable --keep-overlaps --keep-direction --output-dir variable_ttf


diffvfb

`diffvfb` generates a diff from two VFB files. In normal mode, a unified diff is printed to the standard output. Via the option `--html out.html` a HTML diff is written to the specified file instead.

`diffvfb` is very slow.


usage: diffvfb [-h] [--html HTML] file1 file2

diffvfb Copyright (c) 2023 by LucasFonts Build 2023-03-15

positional arguments:
file1 First input file path (.vfb)
file2 Second input file path (.vfb)

options:
-h, --help show this help message and exit
--html HTML Output diff in HTML format to file path

Page 2 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.