Skip to content

Commit

Permalink
Merge pull request #1710 from googlefonts/windows-fixes
Browse files Browse the repository at this point in the history
Windows fixes
  • Loading branch information
justvanrossum authored Oct 10, 2024
2 parents 623b5a7 + 48efa91 commit a3c9f50
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 13 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,38 @@ on:
branches: [main]

jobs:
build:
pre-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 19.x
cache: "npm"

- name: Install Node dependencies
run: |
npm install
- name: Run pre-commit
uses: pre-commit/[email protected]
with:
extra_args: --all-files --verbose --show-diff-on-failure

build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [windows-latest, ubuntu-latest]
python-version: ["3.10", "3.12"]
node-version: [19.x]
exclude:
- os: windows-latest
python-version: "3.10"

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -42,11 +67,6 @@ jobs:
# run: |
# npm install

- name: Run pre-commit
uses: pre-commit/[email protected]
with:
extra_args: --all-files --verbose --show-diff-on-failure

- name: Run Python tests with pytest
run: |
pytest -vv
Expand Down
4 changes: 4 additions & 0 deletions src/fontra/backends/filenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def stringToFileName(string: str) -> str:
)
if fileName[0] == ".":
fileName = "%2E" + fileName[1:]
elif "." in fileName:
base, rest = fileName.split(".", 1)
if base.lower() in reservedFileNames:
fileName = base + "%2E" + rest
if not codeDigits and fileName.lower() in reservedFileNames:
codeDigits = [0]
if codeDigits:
Expand Down
8 changes: 4 additions & 4 deletions src/fontra/backends/fontra.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ async def putCustomData(self, customData: dict[str, Any]) -> None:
self._scheduler.schedule(self._writeFontData)

def _readGlyphInfo(self) -> None:
with self.glyphInfoPath.open("r", encoding="utf-8") as file:
with self.glyphInfoPath.open("r", encoding="utf-8", newline="") as file:
reader = csv.reader(file, delimiter=";")
header = next(reader)
assert header[:2] == ["glyph name", "code points"]
Expand All @@ -202,7 +202,7 @@ def _readGlyphInfo(self) -> None:
self.glyphMap[glyphName] = codePoints

def _writeGlyphInfo(self) -> None:
with self.glyphInfoPath.open("w", encoding="utf-8") as file:
with self.glyphInfoPath.open("w", encoding="utf-8", newline="") as file:
writer = csv.writer(file, delimiter=";")
writer.writerow(["glyph name", "code points"])
for glyphName, codePoints in sorted(self.glyphMap.items()):
Expand Down Expand Up @@ -312,7 +312,7 @@ def serialize(data: list | dict) -> str:


def writeKerningFile(path: pathlib.Path, kerning: dict[str, Kerning]) -> None:
with path.open("w", encoding="utf-8") as file:
with path.open("w", encoding="utf-8", newline="") as file:
writer = csv.writer(file, delimiter=";")

isFirst = True
Expand Down Expand Up @@ -346,7 +346,7 @@ class KerningParseError(Exception):
def readKerningFile(path: pathlib.Path) -> dict[str, Kerning]:
kerning = {}

with path.open("r", encoding="utf-8") as file:
with path.open("r", encoding="utf-8", newline="") as file:
reader = csv.reader(file, delimiter=";")
rowIter = iter(enumerate(reader, 1))

Expand Down
2 changes: 1 addition & 1 deletion test-py/test_backends_designspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def writableTestFontSingleUFO(tmpdir):
def readGLIFData(glyphName, ufoLayers):
glyphSets = {layer.fontraLayerName: layer.glyphSet for layer in ufoLayers}
return {
layerName: glyphSet.getGLIF(glyphName).decode("utf-8")
layerName: glyphSet.getGLIF(glyphName).decode("utf-8").replace("\r\n", "\n")
for layerName, glyphSet in glyphSets.items()
if glyphName in glyphSet
}
Expand Down
7 changes: 6 additions & 1 deletion test-py/test_backends_filenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
("CON", "CON^7"),
("con", "con^0"),
("aux", "aux^0"),
("con.alt", "con.alt"),
("con.alt", "con%2Ealt"),
("conalt", "conalt"),
("con.bbb.alt", "con%2Ebbb.alt"),
("nul.alt", "nul%2Ealt"),
("aux.alt", "aux%2Ealt"),
("com1.alt", "com1%2Ealt"),
("a:", "a%3A"),
("A:", "A%3A^1"),
("a/", "a%2F"),
Expand Down
2 changes: 1 addition & 1 deletion test-py/test_unicode_usedby_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

def test_unicode_usedBy_needs_update():
try:
subprocess.run([scriptPath, "--check"], check=True)
subprocess.run(f"python {scriptPath} --check", check=True, shell=True)
except subprocess.CalledProcessError:
assert 0, f"unicode-utils.js is stale, please run ./scripts/{scriptPath.name}"

0 comments on commit a3c9f50

Please sign in to comment.