Skip to content
Merged

1.1.1 #942

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/scripts/supported_python_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ def supported_versions() -> list[str]:
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"which",
nargs="?",
default="all",
choices=["all", "oldest", "newest"],
"which", nargs="?", default="all", choices=["all", "oldest", "newest"]
)
args = parser.parse_args()

Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- 'main'
- 'dev'
tags:
- '[0-9].*'

Expand Down Expand Up @@ -61,31 +60,6 @@ jobs:
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish-to-testpypi:
name: Publish to TestPyPI
if: startsWith(github.ref, 'refs/heads/dev')
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/fontParts

permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v6
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

create-github-release:
name: Create GitHub Release
needs:
Expand Down
21 changes: 15 additions & 6 deletions Lib/fontParts/base/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class BaseFont(_BaseGlyphVendor, InterpolationMixin, DeprecatedFont, RemovedFont
"""

def __init__(
self, pathOrObject: str | BaseFont | None = None, showInterface: bool = True
self,
pathOrObject: str | os.PathLike | BaseFont | None = None,
showInterface: bool = True,
) -> None:
super().__init__(pathOrObject=pathOrObject, showInterface=showInterface)

Expand Down Expand Up @@ -221,7 +223,7 @@ def _get_path(self, **kwargs: Any) -> str | None: # type: ignore[return]

def save(
self,
path: str | None = None,
path: str | os.PathLike | None = None,
showProgress: bool = False,
formatVersion: int | None = None,
fileStructure: str | None = None,
Expand Down Expand Up @@ -285,7 +287,7 @@ def save(

def _save(
self,
path: str | None,
path: str | os.PathLike | None,
showProgress: bool,
formatVersion: int | None,
fileStructure: str | None,
Expand Down Expand Up @@ -405,7 +407,10 @@ def generateFormatToExtension(format: str, fallbackFormat: str) -> str:
return formatToExtension.get(format, fallbackFormat)

def generate(
self, format: str, path: str | None = None, **environmentOptions: Any
self,
format: str,
path: str | os.PathLike | None = None,
**environmentOptions: Any,
) -> None:
r"""Generate the font in another format.

Expand Down Expand Up @@ -463,7 +468,7 @@ def generate(
"The file cannot be generated because an output path was not defined."
)
elif path is None:
path = os.path.splitext(self.path)[0]
path = os.path.splitext(os.fsdecode(self.path))[0]
path += ext
elif os.path.isdir(path):
if self.path is None:
Expand Down Expand Up @@ -501,7 +506,11 @@ def _isValidGenerateEnvironmentOption(name: str) -> bool:
return False

def _generate(
self, format: str, path: str | None, environmentOptions: dict, **kwargs: object
self,
format: str,
path: str | os.PathLike | None,
environmentOptions: dict,
**kwargs: object,
) -> None:
"""Generate the native font in another format.

Expand Down
3 changes: 2 additions & 1 deletion Lib/fontParts/base/normalizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from fontTools.misc.fixedTools import otRound
from pathlib import Path
import datetime
import os

from fontParts.base.annotations import (
InterpolationFactorLike,
Expand Down Expand Up @@ -1164,7 +1165,7 @@ def normalizeGlyphNote(value: str) -> str:
# File Path


def normalizeFilePath(value: str | Path) -> str:
def normalizeFilePath(value: str | os.PathLike) -> str:
"""Normalize a file path.

:param value: The file path to normalize as a :class:`str` or :class:`pathlib.Path`.
Expand Down
2 changes: 1 addition & 1 deletion Lib/fontParts/fontshell/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _get_path(self, **kwargs: Any) -> str | None:

def _save(
self,
path: str | None = None,
path: str | os.PathLike | None = None,
showProgress: bool = False,
formatVersion: int | None = None,
fileStructure: str | None = None,
Expand Down
5 changes: 5 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.1.1 (released 2026-07-9)
--------------------------
- Include os.PathLike in path types, thanks @adbac! (#940)


1.1.0 (released 2026-07-3)
--------------------------
Adding in Bounds object, `insertContour` method along with more tests, bug fixes, and cleanup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
font = OpenFont("test.ufo")

# a list of accented glyphs that you want to build
myList = ['Aacute', 'aacute']
myList = ["Aacute", "aacute"]

# search for glyphs related to glyphs in myList and add them to myList
myList = buildRelatedAccentList(font, myList)+myList
myList = buildRelatedAccentList(font, myList) + myList

# start the class
at = AccentTools(font, myList)
Expand Down
14 changes: 8 additions & 6 deletions documentation/examples/howtos/helpneeded/buildingAccents_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@

theList = [
# caps
'AEacute',
'AEmacron',
'Aacute',
'Abreve',
"AEacute",
"AEmacron",
"Aacute",
"Abreve",
# add all the accents you want in this list
]

con = readGlyphConstructions()
theList.sort()


def accentify(f, preflight=False):
print('start accentification', f.info.fullName)
print("start accentification", f.info.fullName)
slots = list(con.keys())
slots.sort()
for k in theList:
Expand All @@ -52,5 +53,6 @@ def accentify(f, preflight=False):
f[k].update()
f.update()


accentify(f)
print('done')
print("done")
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
# fontParts does not seem to expose the fullName attribute through the RInfo class
path = os.sep.join([dir, font.info.fullName])
# raises NotImplemented
font.generate('mactype1', path)
font.generate("mactype1", path)
6 changes: 3 additions & 3 deletions documentation/examples/howtos/helpneeded/glyphMath_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Glyphmath howto
# Fun examples

#FLM: Fun with GlyphMath
# FLM: Fun with GlyphMath

# this example is meant to run with the RoboFab Demo Font
# as the Current Font. So, if you're doing this in FontLab
Expand All @@ -20,9 +20,9 @@

destination = f.newGlyph("a#deltaexperiment")
destination.clear()
x = wideBold + (condensedLight-wideLight)*random()
x = wideBold + (condensedLight - wideLight) * random()

destination.appendGlyph( x)
destination.appendGlyph(x)
destination.width = x.width

f.update()
1 change: 1 addition & 0 deletions documentation/examples/howtos/helpneeded/interpolate_01.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fontParts.world import OpenFont

f = OpenFont("test.ufo")
a = f["a"]
# fontParts RGlyph.isCompatible doesn't take the boolean argument.
Expand Down
5 changes: 3 additions & 2 deletions documentation/examples/howtos/helpneeded/interpolate_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
# Straight Interpolating examples

from fontParts.world import OpenFont

minFont = OpenFont(pathToMinFont)
maxFont = OpenFont(pathToMaxFont)
# or any other way you like to get two font objects

inbetweenFont = OpenFont(pathToInbetweenFont)
# so now we have 3 font objects, right?

inbetweenFont.interpolate(.5, minFont, maxFont)
inbetweenFont.interpolate(0.5, minFont, maxFont)
# presto, inbetweenFont is now 50% of one and 50% of the other

inbetweenFont.interpolate((.92, .12), minFont, maxFont)
inbetweenFont.interpolate((0.92, 0.12), minFont, maxFont)
# presto, inbetweenFont is now horizontally
# vertically interpolated in different ways.
2 changes: 1 addition & 1 deletion documentation/examples/howtos/helpneeded/kerning_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
print(list(f.kerning.keys()))

# get the value for this pair
print(f.kerning[('MMK_L_baseserif', 'n')])
print(f.kerning[("MMK_L_baseserif", "n")])
4 changes: 2 additions & 2 deletions documentation/examples/howtos/helpneeded/makeUFO_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from fontParts.tools.toolsAll import fontToUFO
from fontParts.interface.all.dialogs import GetFile, PutFile

srcPath = GetFile('Select the source')
dstPath = PutFile('Save as...')
srcPath = GetFile("Select the source")
dstPath = PutFile("Save as...")

fontToUFO(srcPath, dstPath)
2 changes: 1 addition & 1 deletion documentation/examples/howtos/helpneeded/pens_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

f = OpenFont("test.ufo")

newGlyph = f.newGlyph('demoDrawGlyph', clear=True)
newGlyph = f.newGlyph("demoDrawGlyph", clear=True)
newGlyph.width = 1000

# hey, what's this:
Expand Down
2 changes: 1 addition & 1 deletion documentation/examples/howtos/helpneeded/pens_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
f = OpenFont("test.ufo")

myPen = DigestPointPen()
f['period'].drawPoints(myPen)
f["period"].drawPoints(myPen)

print(myPen.getDigest())
2 changes: 1 addition & 1 deletion documentation/examples/howtos/helpneeded/pens_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
f = OpenFont("test.ufo")

myPen = DigestPointStructurePen()
f['period'].drawPoints(myPen)
f["period"].drawPoints(myPen)

print(myPen.getDigest())
1 change: 1 addition & 0 deletions documentation/examples/howtos/helpneeded/pens_04.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fontParts.world import CurrentGlyph
from fontParts.pens.filterPen import thresholdGlyph

d = 10
thresholdGlyph(CurrentGlyph(), d)
1 change: 1 addition & 0 deletions documentation/examples/howtos/helpneeded/pens_05.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from fontParts.world import CurrentGlyph
from fontParts.pens.filterPen import spikeGlyph

segmentLength = 20
spikeLength = 100
spikeGlyph(CurrentGlyph(), segmentLength, spikeLength)
1 change: 1 addition & 0 deletions documentation/examples/howtos/helpneeded/pens_06.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from fontParts.world import CurrentGlyph
from fontParts.pens.filterPen import halftoneGlyph

halftoneGlyph(CurrentGlyph())
3 changes: 2 additions & 1 deletion documentation/examples/howtos/interpolate_00.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fontParts.world import OpenFont

f = OpenFont("test.ufo")
a = f["a"]
# RGlyph.isCompatible doesn't accept the boolean argument.
#print(a.isCompatible(f["b"], False))
# print(a.isCompatible(f["b"], False))
print(a.isCompatible(f["b"]))
1 change: 1 addition & 0 deletions documentation/examples/howtos/lowLevel_00.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fontParts.world import OpenFont

f = OpenFont("test.ufo")
# this is the high level RoboFab object
print(f)
Expand Down
1 change: 1 addition & 0 deletions documentation/examples/howtos/scripting_00.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fontParts.world import OpenFont

f = OpenFont("test.ufo")
# hey look! an open font dialog!
print(f)
1 change: 1 addition & 0 deletions documentation/examples/howtos/scripting_01.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fontParts.world import OpenFont

path = "test.ufo"
f = OpenFont(path)
# hey look! it opens the file without asking..
Expand Down
1 change: 1 addition & 0 deletions documentation/examples/howtos/scripting_02.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# in Fontlab:
from fontParts.world import OpenFont

f = OpenFont("test.ufo")
print(f)
2 changes: 1 addition & 1 deletion documentation/examples/objects/RAnchor_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from fontParts.world import OpenFont

f = OpenFont("test.ufo")
g = f['a']
g = f["a"]

if len(g.anchors) > 0:
for a in g.anchors:
Expand Down
2 changes: 1 addition & 1 deletion documentation/examples/objects/RComponent_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from fontParts.world import OpenFont

f = OpenFont("test.ufo")
g = f['gbreve']
g = f["gbreve"]

for c in g.components:
print(c)
8 changes: 4 additions & 4 deletions documentation/examples/objects/RComponent_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

f = OpenFont("test.ufo")

print(f['gbreve'].components[0].baseGlyph)
print(f['gbreve'].components[1].baseGlyph)
print(f["gbreve"].components[0].baseGlyph)
print(f["gbreve"].components[1].baseGlyph)

# move the component in the base glyph
f['gbreve'].components[1].offset = (100,100)
f["gbreve"].components[1].offset = (100, 100)

# scale the component in the base glyph
f['gbreve'].components[0].scale = (.5, .25)
f["gbreve"].components[0].scale = (0.5, 0.25)
2 changes: 1 addition & 1 deletion documentation/examples/objects/RContour_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

f = OpenFont("test.ufo")
# take a glyph (one with outlines obviously)
g = f['adieresis']
g = f["adieresis"]

# get to contours by index:
print(g[0])
Expand Down
2 changes: 2 additions & 0 deletions documentation/examples/objects/RFont_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

# start using the current font
from fontParts.world import OpenFont

f = OpenFont("test.ufo")

# get a clean, empty new font object,
# appropriate for the current environment
from fontParts.world import RFont

f = RFont()

# get an open dialog and start a new font
Expand Down
Loading
Loading