Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
SfntUtils.h File Reference
#include <cstddef>
#include <cstdint>
#include <memory>
#include <optional>
#include <span>
#include <string_view>
#include "donner/base/fonts/CffOutlineComplexity.h"
Include dependency graph for SfntUtils.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::fonts::SfntValidationOptions
 Caller-selected limits for one sfnt validation. More...
struct  donner::fonts::SfntValidationMetrics
 Work and limiting outcome observed while validating one sfnt. More...
class  donner::fonts::SfntFont
 Validated, allocation-bounded index for one sfnt font. More...
struct  donner::fonts::SfntFont::TableRecord
 A table location validated against the original font byte span. More...
struct  donner::fonts::SfntFont::GlyphOutlineComplexity
 Allocation and CPU-work ceiling proved for one glyph outline. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

uint16_t donner::fonts::ReadBe16 (const uint8_t *p)
 Read a 16-bit big-endian unsigned integer from p.
uint32_t donner::fonts::ReadBe32 (const uint8_t *p)
 Read a 32-bit big-endian unsigned integer from p.
uint32_t donner::fonts::SfntTag (std::string_view tag)
 Convert a four-byte sfnt tag to its big-endian integer representation.
bool donner::fonts::ValidateSfnt (std::span< const uint8_t > data)
 Return true when data passes the bounded sfnt and outline validation policy.
std::optional< std::span< const uint8_t > > donner::fonts::FindSfntTable (std::span< const uint8_t > data, std::string_view tag)
 Return a bounded sfnt table by its four-byte tag.

Variables

constexpr size_t donner::fonts::kMaximumSfntTables = 4096
 Maximum number of entries accepted in an sfnt table directory.
constexpr size_t donner::fonts::kMaximumCompoundGlyphDepth = 32
 Maximum number of glyph frames reached while expanding a TrueType compound glyph.
constexpr size_t donner::fonts::kMaximumCompoundComponentRecords = 65536
 Maximum component records stored or expanded by one accepted TrueType font.
constexpr size_t donner::fonts::kMaximumSimpleGlyphPoints = 16 * 1024 * 1024
 Maximum simple-glyph points examined while validating one TrueType font.
constexpr size_t donner::fonts::kMaximumExpandedGlyphVertices = 1024 * 1024
 Maximum vertices that stb_truetype may allocate while expanding one TrueType glyph.
constexpr size_t donner::fonts::kMaximumGlyphOutlineWork = 16 * 1024 * 1024
 Maximum decode, transform, and prefix-copy work allowed for one TrueType glyph outline.

Class Documentation

◆ donner::fonts::SfntFont::TableRecord

struct donner::fonts::SfntFont::TableRecord

A table location validated against the original font byte span.

Class Members
uint32_t length = 0
uint32_t offset = 0
uint32_t tag = 0

◆ donner::fonts::SfntFont::GlyphOutlineComplexity

struct donner::fonts::SfntFont::GlyphOutlineComplexity

Allocation and CPU-work ceiling proved for one glyph outline.

Class Members
uint32_t maximumVertices = 0
uint32_t work = 0

Function Documentation

◆ FindSfntTable()

std::optional< std::span< const uint8_t > > donner::fonts::FindSfntTable ( std::span< const uint8_t > data,
std::string_view tag )

Return a bounded sfnt table by its four-byte tag.

This compatibility helper performs a fresh, explicitly bounded validation. Repeated callers should retain an SfntFont and call SfntFont::findTable instead.