A library for rendering egyptian hieroglyphic texts by using the GlyphX format.
This library only handles the calculation of the position and scale of each hieroglyph. The rendering and storing of the images are not included. Besides the library uses the GlyphX code for encoding the hieroglyphic texts.
A library for converting GlyphX to MdC and back is stored here: GlyphConverter.
Tip
You don't want to handle all the images by yourself?
Try the THOTH library which uses the MAAT library and handles all the images.
It contains an android custom view which renders everything for you. You only have to adjust a few parameters!
Add this to your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Then add this dependency to your build.gradle.kts file:
dependencies {
implementation("com.github.cristmasbox:MAAT:1.0.0")
}
Note
For the implementation for other build systems like Groovy see here
Download the MAAT_debug_versionname.aar file from this repository, create a libs folder in your project directory and paste the file there. Then add this dependency to your build.gradle.kts file:
dependencies {
implementation(files("../libs/MAAT_debug_versionname.aar"))
}
Important
If you renamed the .aar file you also have to change the name in the dependencies
First add this code to get the ids of all hieroglyphs used in the GlyphX document.
String GlyphXContent = ""; // Save your GlyphX string here
// Convert your string to an XML Document
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); // Parser that produces DOM object trees from XML content
DocumentBuilder builder; // API to obtain DOM Document instance
builder = factory.newDocumentBuilder(); // Create DocumentBuilder with default configuration
Document GlyphXDocument = builder.parse(new InputSource(new StringReader(GlyphXContent))); // Parse the content to Document object
BoundCalculation boundCalculation = new BoundCalculation(GlyphXDocument); // Create an object of the BoundCalculation class
ArrayList<String> ids = boundCalculation.getIds(); // Get the ids of all the hieroglyphs e.g. ["sn","n","nw","w","A1"]
The ids are either codes from Gardiner's Sign List like A1, Z1, A1B or O34 or their phonetic alternates like sn, zA, xAst or ra.
In the next step you have to find the right images representing the ids. When you found them, you have to get their dimensions and store them in an ArrayList<ValuePair<Float, Float>>. The first Float-value is the width and the second is the height of the image.
Caution
The width and height values in the ArrayList must be in the same order like the equivalent ids.
Now you have to setup the BoundProperty. This class is included in the library and there you store all the settings for the library.
BoundProperty property = new BoundProperty(x, y, textSize,
verticalOrientation, writingDirection, writingLayout);
Here is the explanation for the parameters:
xThis value defines the gobal x-position for the whole text. With help of this value, you can move the text as a whole.yThis value defines the gobal y-position for the whole text. With help of this value, you can move the text as a whole.textSizeThis defines the height of a line in pixels. If thewritingLayoutis set toWRITING_LAYOUT_COLUMNSthis value defines the width of a column in pixels.verticalOrientationThis parameter can only have three values and defines the vertical position of smaller signs (liken):BoundProperty.VERTICAL_ORIENTATION_UPPut signs to the top of the lineBoundProperty.VERTICAL_ORIENTATION_MIDDLECenter signs verticallyBoundProperty.VERTICAL_ORIENTATION_DOWNDrop signs on Baseline
writingDirectionThis parameter can only have two values and defines the direction of writing:BoundProperty.WRITING_DIRECTION_LTRWrite from left to rightBoundProperty.WRITING_DIRECTION_RTLWrite from right to left
writingLayoutThis parameter also have two possible values and determines if signs should be written in lines or in columns:BoundProperty.WRITING_LAYOUT_LINESWrite signs in linesBoundProperty.WRITING_LAYOUT_COLUMNSWrite signs in columns
Warning
Currently in RTL-mode the signs are still written in LTR when positioned in an <h>-group
Finally get the calculated bounds:
ArrayList<ValuePair<Float, Float>> dimensions = new ArrayList<>(); // Store the dimensions of the signs here
ArrayList<Rect> bounds = boundCalculation.getBounds(dimensions, property);
Now you can use the position and scale values stored in the Rect instances and apply them to your images.
This is the first release of the MAAT library.
13.09.2025@1.0.0