docs: Actualizar CLAUDE.md - zcatttf v1.0 funcionando

- TTF section actualizada: TRIUNFO HISTÓRICO zcatttf v1.0
- Lección clave: 'No reimplementar, TRADUCIR'
- Bug final: y_offset = -iy0 (positivo, no negativo)
- Versión actualizada a v0.17.0
- PROYECTOS RELACIONADOS: zcatttf v1.0 COMPLETA

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
reugenio 2025-12-17 00:51:48 +01:00
parent 8b90a1b285
commit 6bf1eb1eb8

107
CLAUDE.md
View file

@ -129,82 +129,72 @@ GPU/CPU interpola → bordes suaves sin multisampling
---
## ⚠️ BUG TTF: Rendering Corrupto → SOLUCIÓN: zcatttf
## ✅ TTF Rendering - RESUELTO (2025-12-17) ⭐⭐⭐
> **Estado**: PAUSADO - Nueva librería zcatttf en desarrollo (otra conversación)
> **Documentación debug**: `docs/research/TTF_DEBUG_SESSION_2025-12-17.md`
> **Fecha**: 2025-12-16/17
> **Estado**: ✅ COMPLETADO - zcatttf v1.0 integrado y funcionando perfectamente
> **Documentación**: `/mnt/cello2/arno/re/recode/teamdocs/agenda/hitos/2025-12-17_zcatttf_v1.0.md`
### El Problema
### El Problema (16-17 Dic)
El texto TTF se renderiza como **garabatos ilegibles** en zsimifactu. TODO el texto está corrupto, incluyendo ASCII básico (A-Z, a-z, 0-9).
El texto TTF se renderizaba como garabatos ilegibles. 2 días de debugging con múltiples intentos fallidos.
### Lo que se intentó (Sesiones 16-17 Dic)
### Solución: zcatttf v1.0
| Intento | Hipótesis | Resultado |
|---------|-----------|-----------|
| DroidSans | AdwaitaSans era fuente variable | ❌ Sigue corrupto |
| Y-flip rasterización | Coordenadas TTF invertidas | ❌ Mejoró colores, no texto |
| UTF-8 decode | drawText iteraba bytes | ❌ No era el problema |
| Fix ABGR (líneas 951-955) | Framebuffer usa ABGR, no RGBA | ⚠️ Colores OK, texto aún mal |
| bearing_x = 0 | Offset incorrecto | ⚠️ Mejoró, pero "eco" |
| bearing_y = y_max | Baseline incorrecto | ⚠️ NO VERIFICADO |
**TRADUCCIÓN LITERAL** de stb_truetype.h, sin intentar "mejorar" o "reimaginar".
### Diagnóstico cmap_debug
**Bug final:** `y_offset = iy0` (negativo) → `y_offset = -iy0` (positivo).
El bearing_y debe ser positivo para glyphs encima de la baseline.
Se creó `src/render/cmap_debug.zig` para diagnosticar. **Resultado**:
- ✅ DroidSans se parsea correctamente
- ✅ cmap format 4 funciona ('A'→36, 'a'→68)
- ✅ ASCII Art de 'A' es legible en test aislado
- ❌ La integración con zcatgui sigue corrupta
### Lección Clave
**Conclusión**: El código base TTF funciona. El bug está en la integración.
### Solución: Nueva librería zcatttf
Decisión consensuada: Reimplementar TTF desde cero en librería independiente.
> **"No reimplementar, TRADUCIR"**
> Si existe código C que funciona, traducirlo literalmente.
> La humildad técnica es fundamental.
| Campo | Valor |
|-------|-------|
| **Proyecto** | `/mnt/cello2/arno/re/recode/zig/zcatttf/` |
| **Algoritmo** | Áreas trapezoidales (como stb_truetype) |
| **Estado** | EN DESARROLLO (otra conversación Claude) |
| **Integración** | zcatgui usará zcatttf como dependencia |
| **Librería** | `/mnt/cello2/arno/re/recode/zig/zcatttf/` |
| **Versión** | v1.0 |
| **Algoritmo** | Traducción literal stb_truetype (~1,200 LOC rasterize.zig) |
| **Estado** | ✅ FUNCIONA PERFECTAMENTE en zsimifactu |
**Documentación zcatttf**:
- `teamdocs/agenda/hitos/2025-12-16_zcatttf_plan_implementacion.md`
- `teamdocs/agenda/hitos/2025-12-16_estudio_dvui_stb_truetype.md`
### Archivos clave
- `src/render/ttf.zig` - Wrapper sobre zcatttf (API compatible)
- `src/render/embedded_font.zig` - Fuente DroidSans embebida
- `build.zig.zon` - Dependencia de zcatttf
### Mientras tanto
- zsimifactu usa **bitmap fonts** (funciona)
- El código TTF en `src/render/ttf.zig` está **congelado** hasta integrar zcatttf
### Archivos clave (NO MODIFICAR)
- `src/render/ttf.zig` - Parser TTF + rasterización (CONGELADO)
- `src/render/embedded_font.zig` - Fuente embebida
- `src/render/cmap_debug.zig` - Herramienta diagnóstico
### Uso
```zig
var ttf = try TtfFont.initEmbedded(allocator);
defer ttf.deinit();
ttf.setSize(14);
ttf.drawText(fb, x, y, "Hola UTF-8: áéíóú ñ €", color, clip);
```
---
## Fuentes TTF: Estado Técnico
### Estado actual (v0.16.2) - CONGELADO
- ✅ Parsing TTF (glyf, cmap format 4 y 12)
- ✅ Rasterización bezier cuadráticas
- ✅ Antialiasing 2x supersampling
### Estado actual (v0.17.0) - FUNCIONAL
- ✅ Parsing TTF via zcatttf (cmap format 4 y 12)
- ✅ Rasterización con áreas trapezoidales (antialiasing)
- ✅ Fuente embebida (DroidSans)
- **BUG: Rendering corrupto en integración** (ver arriba)
- 🔄 **ESPERANDO**: Librería zcatttf
- ✅ Soporte UTF-8 completo (áéíóú ñ €)
- ✅ Cache de glyphs renderizados
### Uso futuro (cuando zcatttf esté listo)
### Uso actual
```zig
// zcatttf reemplazará el código actual
const zcatttf = @import("zcatttf");
var font = try zcatttf.Font.load(allocator, font_data);
const ttf = @import("render/ttf.zig");
// Opción 1: Fuente embebida
var font = try ttf.TtfFont.initEmbedded(allocator);
// Opción 2: Cargar archivo
var font = try ttf.TtfFont.loadFromFile(allocator, "/path/to/font.ttf");
defer font.deinit();
font.setSize(14);
const bitmap = try font.rasterizeGlyph(font.getGlyphIndex('A'));
font.drawText(fb, x, y, "Texto con UTF-8: ñ €", color, clip);
```
---
@ -214,9 +204,9 @@ const bitmap = try font.rasterizeGlyph(font.getGlyphIndex('A'));
| Campo | Valor |
|-------|-------|
| **Nombre** | zcatgui |
| **Versión** | v0.16.2 |
| **Versión** | v0.17.0 |
| **Fecha inicio** | 2025-12-09 |
| **Estado** | ✅ COMPLETO - 37 widgets, ~35K LOC, 4 backends |
| **Estado** | ✅ COMPLETO - 37 widgets, ~35K LOC, 4 backends, TTF funcional |
| **Lenguaje** | Zig 0.15.2 |
| **Paradigma** | Immediate Mode GUI |
| **Inspiración** | Gio (Go), microui (C), DVUI (Zig), Dear ImGui (C++) |
@ -774,13 +764,14 @@ const stdout = std.fs.File.stdout(); // NO std.io.getStdOut()
| 2025-12-11 | v0.15.2 | Widgets adaptados a FocusSystem: numberentry, textarea, select, radio, slider, tabs |
| 2025-12-16 | v0.16.0 | TTF rasterization con antialiasing (supersampling 2x) |
| 2025-12-16 | v0.16.1 | Fuente embebida: TtfFont.initEmbedded() |
| 2025-12-16 | v0.16.2 | Fix TTF: DroidSans (187KB) reemplaza AdwaitaSans (variable). Y-flip rasterización. **UTF-8 pendiente** |
| 2025-12-16 | v0.16.2 | Fix TTF: DroidSans (187KB) reemplaza AdwaitaSans (variable). Y-flip rasterización. |
| 2025-12-17 | v0.17.0 | ⭐⭐⭐ Integración zcatttf v1.0 - TTF FUNCIONA PERFECTAMENTE |
---
## ESTADO ACTUAL
**✅ PROYECTO COMPLETADO - v0.16.2**
**✅ PROYECTO COMPLETADO - v0.17.0**
> **Para detalles técnicos completos, ver `REFERENCE.md`** (1370 líneas de documentación)
@ -936,7 +927,7 @@ state.focused = has_focus;
| Proyecto | Ruta | Descripción |
|----------|------|-------------|
| **zcatttf** | `/mnt/cello2/arno/re/recode/zig/zcatttf/` | ⭐ Librería TTF (reemplazará ttf.zig) - EN DESARROLLO |
| **zcatttf** | `/mnt/cello2/arno/re/recode/zig/zcatttf/` | ⭐ Librería TTF v1.0 - COMPLETA (dependencia de zcatgui) |
| **zsimifactu** | `/mnt/cello2/arno/re/recode/zig/zsimifactu/` | App de facturación Zig (consumidor principal) |
| **zcatui** | `/mnt/cello2/arno/re/recode/zig/zcatui/` | TUI library (proyecto hermano) |
| **zcatp2p** | `/mnt/cello2/arno/re/recode/zig/zcatp2p/` | Librería P2P (v1.0.0 completa) |