mirror of
https://github.com/slavfox/Cozette.git
synced 2024-10-05 12:57:13 +03:00
Don't check repo history on import
This commit is contained in:
parent
a2612e1669
commit
999a1fe7f5
21
build.py
21
build.py
@ -1,7 +1,7 @@
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import argparse
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from shlex import quote
|
||||
@ -10,19 +10,19 @@ from typing import Optional, Sequence, cast
|
||||
|
||||
import crayons # type: ignore
|
||||
|
||||
from cozette_builder.changeloggen import get_changelog
|
||||
from cozette_builder.imagegen import (
|
||||
add_margins,
|
||||
read_sample,
|
||||
save_charlist,
|
||||
save_sample,
|
||||
add_margins,
|
||||
)
|
||||
from cozette_builder.scanner import (
|
||||
find_missing_codepoints,
|
||||
print_codepoints_for_changelog,
|
||||
scan_for_codepoints,
|
||||
)
|
||||
from cozette_builder.ttfbuilder import TTFBuilder
|
||||
from cozette_builder.scanner import (
|
||||
scan_for_codepoints,
|
||||
print_codepoints_for_changelog,
|
||||
find_missing_codepoints,
|
||||
)
|
||||
from cozette_builder.changeloggen import get_changelog
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent
|
||||
BUILD_DIR = REPO_ROOT / "build"
|
||||
@ -138,8 +138,9 @@ if __name__ == "__main__":
|
||||
)
|
||||
if missing_codepoints:
|
||||
print_codepoints_for_changelog(
|
||||
missing_codepoints, print_source_files=args.print_source_files,
|
||||
reverse=args.reverse
|
||||
missing_codepoints,
|
||||
print_source_files=args.print_source_files,
|
||||
reverse=args.reverse,
|
||||
)
|
||||
else:
|
||||
print(
|
||||
|
@ -1,21 +1,30 @@
|
||||
from git import Repo
|
||||
import re
|
||||
from pathlib import Path
|
||||
from unicodedata import name
|
||||
|
||||
from git import Repo
|
||||
|
||||
REPO_ROOT = Path(__file__).parent.parent
|
||||
COZETTE_SFD = REPO_ROOT / "Cozette" / "Cozette.sfd"
|
||||
repo = Repo(REPO_ROOT)
|
||||
last_ver = sorted(repo.tags, key=lambda tag: tag.commit.committed_date)[-1]
|
||||
|
||||
last_cozette_sfd: str = (
|
||||
last_ver
|
||||
.commit
|
||||
.tree["Cozette/Cozette.sfd"]
|
||||
.data_stream
|
||||
.read().decode('utf-8')
|
||||
|
||||
def get_last_ver():
|
||||
repo = Repo(REPO_ROOT)
|
||||
return sorted(repo.tags, key=lambda tag: tag.commit.committed_date)[-1]
|
||||
|
||||
|
||||
def get_last_cozette_sfd() -> str:
|
||||
return (
|
||||
get_last_ver()
|
||||
.commit.tree["Cozette/Cozette.sfd"]
|
||||
.data_stream.read()
|
||||
.decode("utf-8")
|
||||
)
|
||||
|
||||
|
||||
char_regex = re.compile(
|
||||
r"BDFChar: (-?\d+) (-?\d+) (-?\d+) (-?\d+) (-?\d+) (-?\d+) (-?\d+)"
|
||||
)
|
||||
char_regex = re.compile(r'BDFChar: (-?\d+) (-?\d+) (-?\d+) (-?\d+) (-?\d+) (-?\d+) (-?\d+)')
|
||||
|
||||
|
||||
def get_codepoints(cozette_sfd: str):
|
||||
@ -35,17 +44,17 @@ def print_codepoint(codepoint):
|
||||
chrname = " " + name(chr(codepoint))
|
||||
except ValueError:
|
||||
chrname = ""
|
||||
print(
|
||||
f"- {chr(codepoint)} (U+{codepoint:04X}{chrname})"
|
||||
)
|
||||
print(f"- {chr(codepoint)} (U+{codepoint:04X}{chrname})")
|
||||
|
||||
|
||||
def get_changelog():
|
||||
previous_codepoints = get_codepoints(last_cozette_sfd)
|
||||
previous_codepoints = get_codepoints(get_last_cozette_sfd())
|
||||
with COZETTE_SFD.open() as f:
|
||||
current_codepoints = get_codepoints(f.read())
|
||||
|
||||
print(f"Changelog since {last_ver}: {len(current_codepoints)} glyphs found")
|
||||
print(
|
||||
f"Changelog since {get_last_ver()}: {len(current_codepoints)} glyphs found"
|
||||
)
|
||||
added = set(current_codepoints) - set(previous_codepoints)
|
||||
removed = set(previous_codepoints) - set(current_codepoints)
|
||||
changed = set()
|
||||
@ -69,4 +78,4 @@ def get_changelog():
|
||||
print("### Removed\n")
|
||||
for codepoint in sorted(removed):
|
||||
print_codepoint(codepoint)
|
||||
print("")
|
||||
print("")
|
||||
|
@ -2,8 +2,9 @@ import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from shlex import quote
|
||||
from typing import Dict, NamedTuple, Optional, Tuple, List
|
||||
from typing import Dict, List, NamedTuple, Optional, Tuple
|
||||
from unicodedata import east_asian_width as charwidth
|
||||
|
||||
from PIL import Image, ImageOps # type: ignore
|
||||
|
||||
Color = Tuple[int, int, int]
|
||||
@ -135,6 +136,7 @@ def color_text(text: str, palette: Palette) -> str:
|
||||
)
|
||||
return colored_text
|
||||
|
||||
|
||||
def make_charmap(sfd: Path) -> List[str]:
|
||||
text = [
|
||||
" 0 1 2 3 4 5 6 7 8 9 A B C D E F",
|
||||
@ -155,6 +157,7 @@ def make_charmap(sfd: Path) -> List[str]:
|
||||
text.append(f"U+{i//16:04X}_│{line}")
|
||||
return text
|
||||
|
||||
|
||||
def sfd_codepoints(sfd: Path) -> List[int]:
|
||||
codepoints = []
|
||||
with sfd.open() as f:
|
||||
|
@ -1,10 +1,11 @@
|
||||
from typing import Set, Dict, Iterable, List, Set
|
||||
from pathlib import Path
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Dict, Iterable, List, Set
|
||||
from unicodedata import name as uniname
|
||||
|
||||
UESCAPE = re.compile(r"\\[uU]([0-9A-Fa-f]{4,5})")
|
||||
|
||||
|
||||
def scan_file_for_nonascii(path: Path) -> Set[int]:
|
||||
with path.open() as f:
|
||||
try:
|
||||
@ -17,13 +18,10 @@ def scan_file_for_nonascii(path: Path) -> Set[int]:
|
||||
return nonascii
|
||||
|
||||
|
||||
|
||||
# noinspection PyShadowingBuiltins
|
||||
def scan_for_codepoints(dir: Path) -> Dict[int, List[Path]]:
|
||||
if dir.is_file():
|
||||
return {
|
||||
cp: [dir] for cp in scan_file_for_nonascii(dir)
|
||||
}
|
||||
return {cp: [dir] for cp in scan_file_for_nonascii(dir)}
|
||||
non_ascii_codepoints: Dict[int, List[Path]] = {}
|
||||
for path in dir.glob("**/*"):
|
||||
if path.is_file():
|
||||
|
@ -96,8 +96,8 @@ class TTFBuilder:
|
||||
panose={
|
||||
**_panoseDefaults,
|
||||
"bFamilyType": 2, # Text and display
|
||||
"bProportion": 9 # Monospace
|
||||
}
|
||||
"bProportion": 9, # Monospace
|
||||
},
|
||||
)
|
||||
self.fb.setupPost(isFixedPitch=1)
|
||||
self.fb.save(output_path)
|
||||
|
Loading…
Reference in New Issue
Block a user