|
|
Donner 0.5.0
Embeddable browser-grade SVG2 engine
|
HarfBuzz + FreeType font backend. More...
#include "donner/svg/text/TextBackendFull.h"
Classes | |
| struct | HbFontEntry |
| Internal storage for a HarfBuzz font object backed by FreeType. The hb_font_t is created via hb_ft_font_create_referenced(), which holds a reference to the FT_Face. We also hold our own reference (from FT_New_Memory_Face). Destruction order: destroy hb_font first (decrefs FT_Face from 2->1), then FT_Done_Face (decrefs 1->0, frees). More... | |
Public Member Functions | |
| TextBackendFull (FontManager &fontManager, Registry ®istry) | |
| TextBackendFull (const TextBackendFull &)=delete | |
| TextBackendFull & | operator= (const TextBackendFull &)=delete |
| FontVMetrics | fontVMetrics (FontHandle font) const override |
| Vertical metrics (ascent, descent, lineGap) in font design units. | |
| float | scaleForPixelHeight (FontHandle font, float pixelHeight) const override |
| Scale factor: font design units → pixels, normalized to ascent−descent height. This is stbtt_ScaleForPixelHeight semantics. | |
| float | scaleForEmToPixels (FontHandle font, float pixelHeight) const override |
| Scale factor: em units → pixels. Differs from scaleForPixelHeight when ascent−descent != unitsPerEm. This is the correct scale for CSS font-size. | |
| std::optional< UnderlineMetrics > | underlineMetrics (FontHandle font) const override |
| Underline position/thickness from the 'post' table, in font design units. Returns std::nullopt if the table is missing. | |
| std::optional< UnderlineMetrics > | strikeoutMetrics (FontHandle font) const override |
| Strikeout position/thickness from the OS/2 table, in font design units. Returns std::nullopt if the table is missing. | |
| std::optional< SubSuperMetrics > | subSuperMetrics (FontHandle font) const override |
| Sub/superscript Y offsets from the OS/2 table, in font design units. Returns std::nullopt if the table is missing. | |
| Path | glyphOutline (FontHandle font, int glyphIndex, float scale) const override |
Extract a glyph outline as a Path. Coordinates are in font units scaled by scale, with Y flipped for SVG's y-down convention. | |
| bool | isBitmapOnly (FontHandle font) const override |
| Returns true if the font is bitmap-only (no vector outlines). | |
| bool | isCursive (uint32_t codepoint) const override |
| Returns true if letter-spacing should be suppressed for this codepoint (cursive/connected scripts like Arabic). Simple backends return false. | |
| bool | hasSmallCapsFeature (FontHandle font) const override |
| Returns true if the font has a native OpenType small-caps feature (smcp). If false, the engine synthesizes small-caps via uppercase + reduced size. | |
| std::optional< BitmapGlyph > | bitmapGlyph (FontHandle font, int glyphIndex, float scale) const override |
| Extract a bitmap glyph (CBDT/CBLC color emoji). Returns std::nullopt if the glyph is not a bitmap. Simple backends always return std::nullopt. | |
| ShapedRun | shapeRun (FontHandle font, float fontSizePx, std::string_view spanText, size_t byteOffset, size_t byteLength, bool isVertical, FontVariant fontVariant, bool forceLogicalOrder) const override |
| Shape a range of text, producing glyph IDs with advances and kerning. | |
| double | crossSpanKern (FontHandle prevFont, float prevSizePx, FontHandle curFont, float curSizePx, uint32_t prevCodepoint, uint32_t curCodepoint, bool isVertical) const override |
| Compute cross-span kerning between the last codepoint of the previous span and the first codepoint of the current span. | |
HarfBuzz + FreeType font backend.
Provides full OpenType shaping (GSUB/GPOS), FreeType glyph outlines, cursive script detection, native small-caps queries, and bitmap glyph extraction (CBDT/CBLC).
|
overridevirtual |
Extract a bitmap glyph (CBDT/CBLC color emoji). Returns std::nullopt if the glyph is not a bitmap. Simple backends always return std::nullopt.
Implements donner::svg::TextBackend.
|
overridevirtual |
Compute cross-span kerning between the last codepoint of the previous span and the first codepoint of the current span.
Implements donner::svg::TextBackend.
|
overridevirtual |
Vertical metrics (ascent, descent, lineGap) in font design units.
Implements donner::svg::TextBackend.
|
overridevirtual |
Extract a glyph outline as a Path. Coordinates are in font units scaled by scale, with Y flipped for SVG's y-down convention.
Implements donner::svg::TextBackend.
|
overridevirtual |
Returns true if the font has a native OpenType small-caps feature (smcp). If false, the engine synthesizes small-caps via uppercase + reduced size.
Implements donner::svg::TextBackend.
|
overridevirtual |
Returns true if the font is bitmap-only (no vector outlines).
Implements donner::svg::TextBackend.
|
overridevirtual |
Returns true if letter-spacing should be suppressed for this codepoint (cursive/connected scripts like Arabic). Simple backends return false.
Implements donner::svg::TextBackend.
|
overridevirtual |
Scale factor: em units → pixels. Differs from scaleForPixelHeight when ascent−descent != unitsPerEm. This is the correct scale for CSS font-size.
Implements donner::svg::TextBackend.
|
overridevirtual |
Scale factor: font design units → pixels, normalized to ascent−descent height. This is stbtt_ScaleForPixelHeight semantics.
Implements donner::svg::TextBackend.
|
overridevirtual |
Shape a range of text, producing glyph IDs with advances and kerning.
The full span text and a byte range within it are provided so context-aware backends (HarfBuzz) can use surrounding context for GSUB/GPOS.
| font | Font to shape with. |
| fontSizePx | Font size in pixels. |
| spanText | Full span text (UTF-8). |
| byteOffset | Start of the range to shape within spanText. |
| byteLength | Length of the range to shape. |
| isVertical | True for vertical writing mode. |
| fontVariant | Font variant (Normal or SmallCaps). |
| forceLogicalOrder | If true, return glyphs sorted by cluster (DOM order) rather than visual order. Used for per-character positioned RTL text. |
Implements donner::svg::TextBackend.
|
overridevirtual |
Strikeout position/thickness from the OS/2 table, in font design units. Returns std::nullopt if the table is missing.
Implements donner::svg::TextBackend.
|
overridevirtual |
Sub/superscript Y offsets from the OS/2 table, in font design units. Returns std::nullopt if the table is missing.
Implements donner::svg::TextBackend.
|
overridevirtual |
Underline position/thickness from the 'post' table, in font design units. Returns std::nullopt if the table is missing.
Implements donner::svg::TextBackend.