From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alex Myczko Date: Jun, 01 2026 10:36:21 +0200 Subject: [PATCH] TODO: Put a short summary on the line above and replace this paragraph with a longer explanation of this change. Complete the meta-information with other relevant fields (see below for details). To make it easier, the information below has been extracted from the changelog. Adjust it or drop it. --- The information above should follow the Patch Tagging Guidelines, please checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: (upstream|backport|vendor|other), (|commit:) Bug: Bug-: Forwarded: (no|not-needed|) Applied-Upstream: , (|commit:) Reviewed-By: --- fonts-0xproto-2.502+ds.orig/Makefile +++ fonts-0xproto-2.502+ds/Makefile @@ -8,8 +8,9 @@ SCRIPTS_DIR = scripts .PHONY: setup setup: - @echo "Dependencies must be installed via pip (fontmake, fonttools, glyphsLib, ttfautohint-py)" - @echo "Run: pip install -r requirements.txt" + @echo "For Debian SID, install: python3-fontmake python3-fonttools" + @echo "Optional dependencies: python3-glyphslib (for Glyphs support)" + @echo "Alternatively, for all dependencies: pip install -r requirements.txt" .PHONY: build build: @@ -42,6 +43,4 @@ install: .PHONY: test test: - fontbakery check-universal $(OUTPUT_DIR)/$(FONT_NAME)-*.ttf - fontbakery check-universal $(OUTPUT_DIR)/No-Ligatures/*.ttf - fontbakery check-universal $(OUTPUT_DIR)/ZxProto/*.ttf + python3 $(SCRIPTS_DIR)/validate_fonts.py $(OUTPUT_DIR)/$(FONT_NAME)-*.ttf $(OUTPUT_DIR)/No-Ligatures $(OUTPUT_DIR)/ZxProto --- /dev/null +++ fonts-0xproto-2.502+ds/scripts/validate_fonts.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 +""" +Simple font validation script to replace fontbakery check-universal. +Validates TTF/OTF fonts without requiring fontbakery installation. +""" + +import sys +import os +from fontTools.ttLib import TTFont +from pathlib import Path + + +def validate_font(font_path): + """ + Validate a single font file. + + Args: + font_path (str): Path to the font file + + Returns: + tuple: (success: bool, message: str) + """ + if not os.path.exists(font_path): + return False, f"File not found: {font_path}" + + if not os.path.isfile(font_path): + return False, f"Not a file: {font_path}" + + try: + font = TTFont(font_path) + + # Check required tables + required_tables = ['head', 'hhea', 'maxp', 'name', 'cmap', 'glyf' if font_path.endswith('.ttf') else 'CFF '] + missing_tables = [t for t in required_tables if t not in font] + + if missing_tables: + return False, f"Missing required tables: {', '.join(missing_tables)}" + + # Check glyph count + num_glyphs = font['maxp'].numGlyphs + if num_glyphs == 0: + return False, "No glyphs in font" + + # Check name table + if 'name' not in font: + return False, "Missing name table" + + # Check cmap table + if 'cmap' not in font or not font['cmap'].tables: + return False, "Missing or empty cmap table" + + # Basic checks passed + file_size = os.path.getsize(font_path) / 1024 + return True, f"✓ Valid font with {num_glyphs} glyphs ({file_size:.1f}KB)" + + except Exception as e: + return False, f"Error reading font: {e}" + + +def validate_fonts_in_directory(directory): + """ + Validate all TTF and OTF files in a directory and subdirectories. + + Args: + directory (str): Path to directory to scan + + Returns: + tuple: (success_count: int, failure_count: int, total: int) + """ + font_extensions = ('.ttf', '.otf') + font_files = [] + + # Recursively find all font files + for root, dirs, files in os.walk(directory): + for file in files: + if file.lower().endswith(font_extensions): + font_files.append(os.path.join(root, file)) + + if not font_files: + print(f"No font files found in {directory}") + return 0, 0, 0 + + success_count = 0 + failure_count = 0 + + print(f"Validating {len(font_files)} font file(s)...\n") + + for font_path in sorted(font_files): + rel_path = os.path.relpath(font_path) + success, message = validate_font(font_path) + + if success: + print(f" {rel_path}") + print(f" {message}") + success_count += 1 + else: + print(f" {rel_path}") + print(f" ✗ {message}") + failure_count += 1 + + return success_count, failure_count, len(font_files) + + +def main(): + if not sys.argv[1:]: + print("Usage: validate_fonts.py [directory_or_file ...]") + print("Validates all TTF/OTF fonts in the given directory/file.") + sys.exit(1) + + total_success = 0 + total_failure = 0 + + for path in sys.argv[1:]: + if os.path.isdir(path): + success, failure, total = validate_fonts_in_directory(path) + total_success += success + total_failure += failure + elif os.path.isfile(path): + success, message = validate_font(path) + if success: + print(f"✓ {path}: {message}") + total_success += 1 + else: + print(f"✗ {path}: {message}") + total_failure += 1 + else: + print(f"Warning: {path} not found") + + # Print summary + print(f"\n{'='*60}") + print(f"Validation Summary:") + print(f" Passed: {total_success}") + print(f" Failed: {total_failure}") + print(f" Total: {total_success + total_failure}") + print(f"{'='*60}") + + if total_failure > 0: + sys.exit(1) + sys.exit(0) + + +if __name__ == "__main__": + main()