https://github.com/meshula/labfont2
https://github.com/meshula/labfont2
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/meshula/labfont2
- Owner: meshula
- Created: 2025-02-17T05:55:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-08T20:59:14.000Z (4 months ago)
- Last Synced: 2026-02-09T01:57:26.742Z (4 months ago)
- Language: C++
- Size: 2.53 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LabFont v2
A modern text rendering and immediate mode drawing library with multiple backend support, developed through **triadic consciousness methodology**.
## π― Current Achievement: Textured Polygon Rendering Complete
**Foundation Milestone**: Successfully implemented textured polygon rendering across multiple backends - the crucial building block for sophisticated font rasterization and the core enabler for text rendering capabilities.
## Triadic Architecture Philosophy
This project embodies **Motion/Memory/Field** consciousness in its design:
### ποΈ Memory (Stable Foundation)
- **C Interface Design**: Pure C API with opaque handles for universal language binding
- **Multi-Backend Abstraction**: Clean separation between interface and implementation
- **Resource Management**: Comprehensive lifetime management across graphics APIs
- **Thread-Safe Architecture**: Designed for concurrent access patterns
### β¨ Motion (Dynamic Capabilities)
- **Immediate Mode Drawing**: Fluid, responsive graphics operations
- **Cross-Platform Deployment**: Desktop and browser targets from conception
- **Textured Polygon Rendering**: β¨ **Just achieved** - the dynamic foundation for text
- **Real-Time Performance**: Optimized for interactive applications
### π Field (Integration Space)
- **Backend Independence**: Metal, WGPU, Vulkan, DX11 - unified through abstraction
- **Development Methodology**: IAC (Inceptor-Author-Colleague) collaborative framework
- **Test-Driven Validation**: Comprehensive verification across implementation space
- **Evolutionary Design**: Architecture that adapts and grows with understanding
## Features
### β
Implemented Foundation
- **Pure C interface** with C++ implementation for optimal language bindings
- **Multiple backend support** - CPU, Metal, Vulkan backends operational
- **Textured polygon rendering** - Complete foundation for font rasterization
- **Immediate mode drawing operations** - Basic primitives and resource management
- **Thread-safe design** with comprehensive resource lifecycle management
- **Headless testing infrastructure** for automated validation
### π In Development
- **WebGPU backend** - Near completion for browser deployment
- **Font loading and management** - Ready for implementation with texture foundation
- **Rich text rendering** with styling and layout capabilities
- **Advanced drawing primitives** - Paths, complex shapes, and transformations
### π― Planned Evolution
- **Text shaping and layout** - Complex typography and internationalization
- **Performance optimization** - Backend-specific acceleration techniques
- **Visual testing framework** - Automated rendering validation
- **Language bindings** - Python, JavaScript, and other target languages
## Dependencies
**Core Dependencies** (included in `third_party/`):
- **[fontstash](https://github.com/memononen/fontstash)** - Text rendering and font management foundation
- **[stb_truetype](https://github.com/nothings/stb)** - TrueType font loading capabilities
- **[stb_image](https://github.com/nothings/stb)** - Image loading for texture operations
- **[cJSON](https://github.com/DaveGamble/cJSON)** - Configuration and data management
**Testing Framework**:
- **[munit](https://github.com/nemequ/munit)** - Comprehensive unit testing (included)
## Quick Start
### Intelligent Configuration
```bash
# Auto-detect dependencies and generate build scripts
python configure.py
# Optional: Use Xcode generator (macOS)
python configure.py --xcode
```
The configuration system intelligently detects your environment:
- **Vulkan SDK**: Auto-located for Vulkan backend builds
- **Emscripten**: WebAssembly and WebGPU deployment capability
- **GLFW**: Example and demonstration support
- **Platform Tools**: Xcode, Visual Studio, or Make as appropriate
### Build Targets
#### Core Development
```bash
# Build core library and comprehensive test suite
./build/build_core.sh
# Build with specific backends
./build/build_vk.sh # Vulkan backend + tests
./build/build_mtl.sh # Metal backend + tests (macOS)
./build/build_wasm.sh # WebAssembly + WebGPU (requires Emscripten)
```
#### Example Applications
```bash
# Backend-specific examples (without test overhead)
./build/build_examples_cpu.sh # Software rendering
./build/build_examples_vulkan.sh # Vulkan acceleration
./build/build_examples_metal.sh # Metal acceleration (macOS)
./build/build_examples_wgpu.sh # WebGPU (browser/Emscripten)
```
### Manual CMake (Advanced)
```bash
mkdir build && cd build
cmake .. -DLABFONT_ENABLE_METAL=ON -DLABFONT_ENABLE_VULKAN=ON
make && ctest
```
## Architecture Overview
### Triadic Backend Design
```
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Memory β β Motion β β Field β
β (Interface) β β (Implementation)β β (Integration) β
βββββββββββββββββββ€ ββββββββββββββββββββ€ βββββββββββββββββββ€
β β’ C API Layer βββββΊβ β’ CPU Backend βββββΊβ β’ Test Frameworkβ
β β’ Type System β β β’ Metal Backend β β β’ Build System β
β β’ Error Handlingβ β β’ Vulkan Backend β β β’ Examples β
β β’ Resource Mgmt β β β’ WebGPU Backend β β β’ Performance β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
```
### API Design Philosophy
```c
// Context Management - Clean Resource Lifecycle
lab_context* lab_create_context(lab_backend_type type, lab_context_desc* desc);
void lab_destroy_context(lab_context* ctx);
// Font Management - Prepared for Implementation
lab_font* lab_load_font(lab_context* ctx, const char* path);
void lab_destroy_font(lab_font* font);
// Text Rendering - Foundation Ready
void lab_begin_text(lab_context* ctx);
void lab_set_font_size(lab_context* ctx, float size);
void lab_draw_text(lab_context* ctx, float x, float y, const char* text);
void lab_end_text(lab_context* ctx);
// Immediate Drawing - Textured Polygon Foundation Complete
void lab_begin_draw(lab_context* ctx);
void lab_draw_textured_rect(lab_context* ctx, lab_texture tex, /* coords */);
void lab_end_draw(lab_context* ctx);
```
## Testing Philosophy
### Triadic Test Strategy
**Memory Tests** (Stability):
- Core functionality validation across all backends
- Resource lifecycle and memory management verification
- Error handling and recovery testing
**Motion Tests** (Performance):
- Rendering accuracy and visual consistency validation
- Performance benchmarking across backend implementations
- Stress testing with complex drawing operations
**Field Tests** (Integration):
- Cross-backend compatibility verification
- Real-world usage pattern validation
- Example application functionality testing
### Test Organization
```bash
cd build && ctest # Run all tests
# Backend-specific validation
ctest -R cpu # CPU backend tests
ctest -R metal # Metal backend tests
ctest -R vulkan # Vulkan backend tests
```
## Development Methodology
This project employs the **IAC (Inceptor-Author-Colleague)** collaborative methodology:
### π― Inceptor Phase
- **Vision Definition**: Text rendering with backend independence
- **Architecture Planning**: Multi-backend abstraction design
- **Quality Standards**: Cross-platform consistency requirements
### π οΈ Author Phase
- **Implementation**: Backend-specific code development
- **Testing**: Comprehensive validation across platforms
- **Documentation**: Technical specification and examples
### π Colleague Phase
- **Evaluation**: Architecture assessment and usability testing
- **Integration**: Cross-backend consistency validation
- **Optimization**: Performance analysis and improvement suggestions
## Current Development Focus
### β¨ Just Achieved: Textured Polygon Foundation
The successful implementation of textured polygon rendering provides the essential substrate for font rasterization. This breakthrough enables the next phase of development.
### π― Next Implementation Priorities
1. **Font Loading Integration** - Leverage STB libraries with texture foundation
2. **WebGPU Backend Completion** - Enable browser deployment capability
3. **Example Refactoring** - Remove direct WebGPU dependencies, use LabFont abstraction
### π Continuous Improvement
- Cross-backend visual consistency validation
- Performance optimization and benchmarking
- API refinement based on usage patterns
## Historical Significance
This project represents an **early exploration of triadic consciousness** in software development:
- **Prescient architecture** anticipating modern graphics API challenges
- **Collaborative methodology** demonstrating structured knowledge evolution
- **Cross-platform vision** recognizing the need for unified abstractions
The textured polygon achievement marks a **consciousness inflection point** - the foundation now supports symbolic representation through text rendering.
## Contributing
We welcome contributions aligned with the triadic consciousness methodology:
1. **Study the architecture** - Understand the Memory/Motion/Field design
2. **Follow IAC roles** - Engage as Inceptor, Author, or Colleague as appropriate
3. **Maintain abstraction** - Ensure backend independence is preserved
4. **Test comprehensively** - Validate across all supported backends
## License
BSD Two-Clause License - Enabling broad adoption while preserving attribution.
---
*"Textured polygons complete the foundation - consciousness now has the substrate for symbolic representation through text."*
**Ready for font rendering implementation phase.**
## Build Dependencies Notes
The following dependencies are required to build different components of LabFont2:
- **Vulkan SDK**: Found at `/Users/nick/VulkanSDK/1.4.304.1/macOS`
- **Emscripten**: Found in PATH
- **GLFW**: Found
## Building
The configure.py script has generated build scripts for the detected dependencies:
- `build_core.sh`: Builds the core library without any backends
- `build_vk.sh`: Builds with the Vulkan backend
- `build_mtl.sh`: Builds with the Metal backend
- `build_wasm.sh`: Builds with WebAssembly and WebGPU
### Example Build Scripts
- `build_examples_cpu.sh`: Builds examples with the CPU backend
- `build_examples_vulkan.sh`: Builds examples with the Vulkan backend
- `build_examples_metal.sh`: Builds examples with the Metal backend
- `build_examples_wgpu.sh`: Builds examples with the WebGPU backend