maxsem/hiero

Egyptian hieroglyphic text to SVG renderer

Maintainers

Package info

github.com/MaxSem/hiero

pkg:composer/maxsem/hiero

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-07-10 21:24 UTC

This package is auto-updated.

Last update: 2026-08-01 19:42:30 UTC


README

It renders Manuel de Codage markup.

Example output

Installation

composer install maxsem/hiero

Fonts

To render something, you need a font, which for this package is a set of SVG files along with some metadata. You can make one out of a TTF font:

bin/build-font.php path/to/font.ttf destination/dir

You'll need Python and FontForge module for it to export SVGs from fonts.

Usage

// All these parameters are optional
$options = new Options(
    throwOnErrors: true,       // See #Error handling
    logErrorBacktraces: false, // See #Error handling
    maxTokens: 1000,           // Maximum number of tokens to parse/render or null for no limit. MaxTokensException will be thrown if exceeded. Protects against resource exhaustion.
    color: 'black',            // Hieroglyph color: valid CSS color or null to not set and default to black.
    background: 'white',       // Background: CSS color or null for transparent.

    // Content of the rendered SVG's <style> tag or null to not set. Will be overridden by the options above.
    style: '.cartouche { color: red }' // color the cartouche red
);

$font = Font::fromPath('path/to/font');
// Or
$font = Font::fromComposerPackage('package/name');

$mdc = new ManuelDeCodage($options, $font);

$renderOutput = $mdc->parseAndRender('< D10:G16-A46\-C2-L1 >');

file_put_contents('result.svg', $renderOuptut->svg);

Error handling

All errors specific to the package are instanceof HieroException. For problems related to user input, both parsing and rendering stages can be configured to either throw exceptions or return a list of Error objects. If configuerd to throw exceptions, descendants of LocalizableException will be thrown. All these errors contain an error code and an optional list of parameters that can be fed into an external localization framework. See the ErrorCodes class for possible codes.

Development

  • If it isn't tested, it doesn't work.
  • Prefer immutable data classes with readonly properties to getters and setters.
  • Run all the tests with make.
  • Minimum supported PHP version is the one used by Wikimedia wikis.