prinsfrank/glyph-lists
PHP package that reformats Adobe Glyph List (AGL/AGLFN) data into easy-to-use PHP enum classes. Includes derived datasets from adobe-type-tools/agl-aglfn (BSD-3) while the code is MIT-licensed, with proper attribution.
Installation
composer require prinsfrank/glyph-lists
Ensure your project uses PHP 8.1+ (enums are required).
First Use Case: Validate a Glyph Check if a glyph exists in the Adobe Glyph List:
use PrinsFrank\GlyphLists\AdobeGlyphList;
if (AdobeGlyphList::A->value === 'A') {
// Glyph 'A' is valid
}
Or dynamically:
$isValid = AdobeGlyphList::tryFrom('A') !== null;
Where to Look First
vendor/prinsfrank/glyph-lists/src/Enums/ for available lists (e.g., AdobeGlyphList.php, AdobeGlyphListForNewNames.php).PrinsFrank\GlyphLists\Facades\GlyphLists for container-bound access:
$glyph = GlyphLists::get('AdobeGlyphList')->A;
Type-Safe Glyph Handling Replace raw strings with enums in validation, APIs, or business logic:
// Before (string-based)
if ($glyph === 'A') { ... }
// After (enum-based)
if ($glyphEnum === AdobeGlyphList::A) { ... }
Laravel Integration
AppServiceProvider:
public function register() {
$this->app->bind('glyphLists', function () {
return new \PrinsFrank\GlyphLists\GlyphLists();
});
}
use PrinsFrank\GlyphLists\AdobeGlyphList;
use Illuminate\Validation\Rule;
$validator->extend('valid_adobe_glyph', function ($attribute, $value, $parameters) {
return AdobeGlyphList::tryFrom($value) !== null;
});
Usage:
'glyph' => ['required', 'valid_adobe_glyph'],
PDF/Font Libraries
Use enums to ensure glyph compatibility in libraries like barryvdh/laravel-dompdf:
$dompdf = new \Dompdf\Dompdf();
$dompdf->loadHtml($html);
// Validate glyphs before rendering
$glyphsInHtml = extractGlyphsFromHtml($html);
foreach ($glyphsInHtml as $glyph) {
if (AdobeGlyphList::tryFrom($glyph) === null) {
throw new \InvalidArgumentException("Unsupported glyph: $glyph");
}
}
Dynamic Glyph Lookup Convert between Unicode code points and glyph names:
// Unicode to Glyph
$glyph = AdobeGlyphList::fromCode(0x41); // Returns AdobeGlyphList::A
// Glyph to Unicode
$code = AdobeGlyphList::A->code; // Returns 65 (Unicode for 'A')
Batch Operations Iterate over all glyphs for bulk processing (e.g., font generation):
foreach (AdobeGlyphList::cases() as $glyph) {
$this->fontRenderer->addGlyph($glyph->value, $glyph->code);
}
Font Validation Pipeline
AdobeGlyphList:
$validGlyphs = array_filter($extractedGlyphs, fn($glyph) =>
AdobeGlyphList::tryFrom($glyph) !== null
);
Unicode Normalization Ensure text uses only supported glyphs:
$normalizedText = str_replace(
array_map(fn($glyph) => $glyph->value, AdobeGlyphList::cases()),
array_map(fn($glyph) => $glyph->value, AdobeGlyphList::cases()),
$inputText
);
Localization Tools Map glyphs to locale-specific representations:
$localeGlyphs = match ($locale) {
'ar' => AdobeGlyphListForNewNames::cases(),
default => AdobeGlyphList::cases(),
};
$mockGlyph = $this->createMock(AdobeGlyphList::class);
$mockGlyph->method('value')->willReturn('A');
AdobeGlyphList:: shows all available glyphs).PHP Version Requirement
Fatal error: Class 'PrinsFrank\GlyphLists\AdobeGlyphList' not found
Static Data Limitations
class ExtendedGlyphList {
public static function all(): array {
return array_merge(
AdobeGlyphList::cases(),
[new CustomGlyphList('Z'), ...]
);
}
}
Case Sensitivity
AdobeGlyphList::A ≠ AdobeGlyphList::a).$normalizedGlyph = strtoupper($userInput);
Missing Glyphs
Facade Ambiguity
GlyphLists) may not be auto-discovered if not registered.AppServiceProvider:
$this->app->singleton('glyphLists', function () {
return new \PrinsFrank\GlyphLists\Facades\GlyphLists();
});
Enum Not Found Errors
AdobeGlyphList::a instead of AdobeGlyphList::A).AdobeGlyphList::cases() to list all valid glyphs:
print_r(array_column(AdobeGlyphList::cases(), 'value'));
Performance Bottlenecks
AdobeGlyphList::tryFrom() in loops.$cache = [];
$isValid = $cache[$glyph] ??= AdobeGlyphList::tryFrom($glyph) !== null;
Integration Issues
use PrinsFrank\GlyphLists\AdobeGlyphList as AdobeGlyphListEnum;
config/glyph-lists.php file.// config/glyph-lists.php
return [
'default_list' => 'AdobeGlyphList',
'custom_glyphs' => ['Z'
How can I help you explore Laravel packages today?