feat: FontSignature (Magic Bytes) und FontNameRules (Namensregeln eigener Schriften)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-19 18:02:29 +02:00
co-authored by Claude Sonnet 5.5
parent 172a703903
commit 775d611cfa
4 changed files with 201 additions and 0 deletions
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
use LIT\MCP\Integrations\Divi\Design\FontSignature;
use PHPUnit\Framework\TestCase;
final class FontSignatureTest extends TestCase
{
public function testTheFourFormatsAreRecognizedByTheirFirstFourBytes(): void
{
self::assertSame('woff2', FontSignature::detect("wOF2\x00\x01\x00\x00\x00\x00\x12\x34"));
self::assertSame('woff', FontSignature::detect("wOFF\x00\x01\x00\x00"));
self::assertSame('ttf', FontSignature::detect("\x00\x01\x00\x00\x00\x0c\x00\x80"));
self::assertSame('ttf', FontSignature::detect('true' . "\x00\x0c"), 'Apple TrueType');
self::assertSame('otf', FontSignature::detect("OTTO\x00\x0a\x00\x80"));
}
public function testEverythingElseIsNoFont(): void
{
self::assertNull(FontSignature::detect(''));
self::assertNull(FontSignature::detect('wOF'), 'too short');
self::assertNull(FontSignature::detect('wof2'), 'case matters');
self::assertNull(FontSignature::detect('ttcf'), 'font collections are not accepted');
self::assertNull(FontSignature::detect("\x89PNG\r\n\x1a\n"));
self::assertNull(FontSignature::detect('<?php evil();'));
self::assertNull(FontSignature::detect("\x00wOF2"), 'the magic must start at byte 0');
}
}