Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\SvgToPdf\Text;
6
7/**
8 * Seam that lets an embedding document hand its own already-registered
9 * fonts to SVG text painting.
10 *
11 * Standalone SVG rendering has no font machinery beyond the 14 standard
12 * PDF fonts (see {@see FontResolver}). But when an SVG is embedded in an
13 * HTML document — inline `<svg>`, or an SVG `background-image` — that
14 * document has already parsed its `@font-face` rules, matched families
15 * per CSS Fonts 4 §6, and embedded the chosen faces in the PDF. SVG text
16 * inherits the same `font-family` cascade as the surrounding HTML
17 * (SVG 2 §11.5 defers font selection wholesale to CSS Fonts), so it must
18 * resolve to the same face — otherwise `<div>Hi</div>` and
19 * `<svg><text>Hi</text></svg>` in one document render in different
20 * typefaces.
21 *
22 * Implementations return `null` when they cannot satisfy the request;
23 * the translator then falls back to its built-in standard-14 resolver.
24 */
25interface DocumentFontProvider
26{
27    /**
28     * @param list<string> $families Ordered `font-family` list, as
29     *                               authored (unquoted, untrimmed of case).
30     * @param string|null  $weight   Raw CSS `font-weight` (`bold`, `600`, …).
31     * @param string|null  $style    Raw CSS `font-style` (`italic`, …).
32     */
33    public function resolveDocumentFont(array $families, ?string $weight, ?string $style): ?DocumentFont;
34}