Opció --no-accents / «Sense accents» a CLI i GUI

This commit is contained in:
2026-05-12 10:34:10 +02:00
parent 3ee2b303fe
commit 01415776b9
2 changed files with 32 additions and 12 deletions
+11 -1
View File
@@ -103,6 +103,7 @@ def build_font_bitmap(
columns: int = 15,
box_width_override: int | None = None,
box_height_override: int | None = None,
strip_accents: bool = False,
) -> FontBitmapResult:
"""Rasteriza un TTF a un bitmap de fuente en memoria. No toca disco.
@@ -160,6 +161,9 @@ def build_font_bitmap(
if ch.isspace():
chars_to_render.append(ch)
char_render_as[ch] = ch
elif strip_accents and ch in CHAR_FALLBACKS and font.getlength(CHAR_FALLBACKS[ch]) >= 1.0:
chars_to_render.append(ch)
char_render_as[ch] = CHAR_FALLBACKS[ch]
elif font.getlength(ch) >= 1.0 and not _is_notdef(ch):
chars_to_render.append(ch)
char_render_as[ch] = ch
@@ -408,10 +412,13 @@ def render_font(
columns: int,
box_width_override: int | None,
box_height_override: int | None,
strip_accents: bool = False,
) -> None:
"""Wrapper CLI: rasteriza el TTF y escribe los ficheros, con logging."""
try:
result = build_font_bitmap(ttf_path, size, columns, box_width_override, box_height_override)
result = build_font_bitmap(ttf_path, size, columns,
box_width_override, box_height_override,
strip_accents)
except (FileNotFoundError, RuntimeError) as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
@@ -492,6 +499,8 @@ Notas:
parser.add_argument("--box-height", default=None, type=int, help="Altura fija de celda en px (default: auto)")
parser.add_argument("--cell-spacing", default=0, type=int, help="Píxeles de separación entre columnas, y borde (default: 0)")
parser.add_argument("--row-spacing", default=None, type=int, help="Píxeles de separación entre filas (default: igual a --cell-spacing)")
parser.add_argument("--no-accents", action="store_true",
help="Renderiza À/É/ñ/Ç… como A/E/n/C (sin acentos). El codepoint original se conserva en el .fnt.")
args = parser.parse_args()
@@ -529,6 +538,7 @@ Notas:
columns = args.columns,
box_width_override = args.box_width,
box_height_override= args.box_height,
strip_accents = args.no_accents,
)