fop-types
Foundational types for the Apache FOP Rust implementation. This crate has no internal dependencies and is used by all other FOP crates.
Types
Length
Dimensional measurements stored as integer millipoints (1/1000 of a typographic point) for precision without floating-point errors.
use Length;
let a = from_pt; // 72 points
let b = from_inch; // 1 inch = 72 points
assert_eq!;
let c = from_mm; // A4 width
let d = from_cm; // Same thing
assert_eq!;
// Arithmetic
let sum = a + b;
let half = a / 2;
Color
RGBA color values with named color constants and hex parsing.
use Color;
let red = RED;
let custom = from_hex.unwrap;
let transparent = new;
Point, Size, Rect
2D geometry types using Length for coordinates.
use ;
let origin = new;
let size = new;
let rect = from_point_size;
assert!;
FontMetrics / FontRegistry
Font measurement data for layout calculations. Provides character widths, ascent, descent, and line height for built-in fonts (Helvetica, Times-Roman).
use FontRegistry;
let registry = with_defaults;
let helvetica = registry.get.unwrap;
let width = helvetica.string_width;
FopError / Result
Base error type used across all FOP crates.
Modules
| Module | Lines | Description |
|---|---|---|
length.rs |
268 | Length type with unit conversions |
color.rs |
194 | RGBA color with hex parsing and constants |
geometry.rs |
263 | Point, Size, Rect |
font_metrics.rs |
392 | FontMetrics, FontRegistry |
error.rs |
42 | FopError enum |
lib.rs |
19 | Re-exports |
| Total | 1,178 |
Tests
25 unit tests covering:
- Length unit conversions (pt, mm, cm, inch) and arithmetic
- Color hex parsing, named colors, edge cases
- Geometry containment, intersection, size calculations
- Font metrics string width computation
- Error type Display/Debug
Dependencies
thiserror2.0