0

This question is for (TeX) archaeologists

Notice: We have got better fonts for hieroglyphs these days stored in a single font file, or in SVG file(s), or in a series of GIFs covering all the Unicode hieroglyphs (Gardiner, New Gardiner, Gardiner in color, Aegyptus, Hieroglyphica project and probably some more), see U13000 for more details.

In old days, we needed more font files because there was a limitation of 256 glyphs per font. This is an example of it, we have got five font files for hieroglyphs, http://www.rockwellweb.com/hiero.htm. How can we map all the present hieroglyphs?

An example: when we enter \tohiero{A1-A2-A3} in TeX we should get first three hieroglyphs from the first font file (GARDAE__.TTF). The glyph positions are "F021, "F022 and "F023.

mwe

  • Using “glyph positions” F021 etc. seems to mean using Private Use code points and relying on specific fonts containing some hieroglyphs assigned to them. This does not sound particularly modern or robust. Using the current Unicode assignments would be the modern way, but then you need fonts that contain the hieroglyphs as properly coded, as well as tools that make use of them. – Jukka K. Korpela May 17 '14 at 16:55
0

I've dug deep enough and found this old problem. I am trying to solve it with new toys/tools.

I've downloaded and installed these five TTF files from http://www.rockwellweb.com/hiero.htm among my system fonts. We can notice that there are also mapping / sign tables which we are going to need. We can also find them at http://www.yare.org/egypt/gardiner%20fonts.htm. Our task is to replace hieroglyph codes by proper TeX commands.

I've tried to prepare a solution for XeTeX and LuaTeX users, I am generating a temporary TeX file which is processed by a standalone Lua script and the modified result is loaded in TeX later. The data files are these two.

The content of hiero-repl.lua is this:

-- We can get these for instance from Aegyptus.pdf, page 5...
replacements={
  { "i[-]i", "M17A" },
  { "A", "G1" },
  { "i", "M17" },
  { "y", "Z4" },
  { "a", "D36" },
  { "w", "G43" },
  { "b", "D58" },
  { "p", "Q3" },
  { "f", "I9" },
  { "m", "G17" },
  { "n", "N35" },
  { "r", "D21" },
  { "h", "O4" },
  { "H", "V28" },
  { "x", "J1" },
  { "X", "F32" },
  { "z", "O34" },
  { "s", "S29" },
  { "S", "N37" },
  { "q", "N29" },
  { "k", "V31" },
  { "g", "W11" },
  { "t", "X1" },
  { "T", "V13" },
  { "d", "D46" },
  { "D", "I10" },
  { "W", "Z7" },
  { "M", "J15" },
  { "N", "S3" },
  { "R", "D153" },
  { "K", "S56" },
  { "l", "E23" }, 
  }

The content of hiero-all.lua is as follows:

-- This is a list of hieroglyphs (first column), the font file (second column) and last two digits of glyph position, the real position is "F0xx.
hieroglyphs={
  {   "A1","AE","21" },
  {   "A2","AE","22" },
  {   "A3","AE","23" },
  {   "A4","AE","24" },
  {   "A5","AE","25" },
  {   "A6","AE","26" },
  {   "A7","AE","27" },
  {   "A8","AE","28" },
  {   "A9","AE","29" },
  {  "A10","AE","2A" },
  {  "A11","AE","2B" },
  {  "A12","AE","2C" },
  {  "A13","AE","2D" },
  {  "A14","AE","2E" },
  { "A14A","AE","2F" },
  {  "A15","AE","30" },
  {  "A16","AE","31" },
  {  "A17","AE","32" },
  { "A17A","AE","33" },
  {  "A18","AE","34" },
  {  "A19","AE","35" },
  {  "A20","AE","36" },
  {  "A21","AE","37" },
  {  "A22","AE","38" },
  {  "A23","AE","39" },
  {  "A24","AE","3A" },
  {  "A25","AE","3B" },
  {  "A59","AE","3C" },
  {  "A26","AE","3D" },
  {  "A27","AE","3E" },
  {  "A28","AE","3F" },
  {  "A29","AE","40" },
  {  "A30","AE","41" },
  {  "A31","AE","42" },
  {  "A32","AE","43" },
  {  "A33","AE","44" },
  {  "A34","AE","45" },
  {  "A35","AE","46" },
  {  "A36","AE","47" },
  {  "A37","AE","48" },
  {  "A38","AE","49" },
  {  "A39","AE","4A" },
  {  "A40","AE","4B" },
  {  "A41","AE","4C" },
  {  "A42","AE","4D" },
  {  "A43","AE","4E" },
  {  "A44","AE","4F" },
  {  "A45","AE","50" },
  {  "A46","AE","51" },
  {  "A47","AE","52" },
  {  "A48","AE","53" },
  {  "A49","AE","54" },
  {  "A50","AE","55" },
  {  "A51","AE","56" },
  {  "A52","AE","57" },
  {  "A53","AE","58" },
  {  "A54","AE","59" },
  {  "A55","AE","5A" },
  {   "B1","AE","5B" },
  {   "B2","AE","5C" },
  {   "B3","AE","5D" },
  {   "B4","AE","5E" },
  {   "B5","AE","5F" },
  {   "B6","AE","60" },
  {   "B7","AE","61" },
  {   "C1","AE","62" },
  {   "C2","AE","63" },
  {   "C3","AE","64" },
  {   "C4","AE","65" },
  {   "C5","AE","66" },
  {   "C6","AE","67" },
  {   "C7","AE","68" },
  {   "C8","AE","69" },
  {   "C9","AE","6A" },
  {  "C10","AE","6B" },
  {  "C11","AE","6C" },
  {  "C12","AE","6D" },
  {  "C17","AE","6E" },
  {  "C18","AE","6F" },
  {  "C19","AE","70" },
  {  "C20","AE","71" },
  {   "D1","AE","72" },
  {   "D2","AE","73" },
  {   "D3","AE","74" },
  {   "D4","AE","75" },
  {   "D5","AE","76" },
  {   "D6","AE","77" },
  {   "D7","AE","78" },
  {   "D8","AE","79" },
  {   "D9","AE","7A" },
  {  "D10","AE","7B" },
  {  "D11","AE","7C" },
  {  "D12","AE","7D" },
  {  "D13","AE","7E" },
  {  "D14","AE","A1" },
  {  "D15","AE","A2" },
  {  "D16","AE","A3" },
  {  "D17","AE","A4" },
  {  "D18","AE","A5" },
  {  "D19","AE","A6" },
  {  "D20","AE","A7" },
  {  "D21","AE","A8" },
  {  "D22","AE","A9" },
  {  "D23","AE","AA" },
  {  "D24","AE","AB" },
  {  "D25","AE","AC" },
  {  "D26","AE","AE" },
  {  "D27","AE","AF" },
  { "D27A","AE","B0" },
  {  "D28","AE","B1" },
  {  "D29","AE","B2" },
  {  "D30","AE","B3" },
  {  "D31","AE","B4" },
  {  "D32","AE","B5" },
  {  "D33","AE","B6" },
  {  "D34","AE","B7" },
  { "D34A","AE","B8" },
  {  "D35","AE","B9" },
  {  "D36","AE","BA" },
  {  "D37","AE","BB" },
  {  "D38","AE","BC" },
  {  "D39","AE","BD" },
  {  "D40","AE","BE" },
  {  "D41","AE","BF" },
  {  "D42","AE","C0" },
  {  "D43","AE","C1" },
  {  "D44","AE","C2" },
  {  "D45","AE","C3" },
  {  "D46","AE","C4" },
  {  "D47","AE","C5" },
  { "D46A","AE","C6" },
  {  "D48","AE","C7" },
  {  "D49","AE","C8" },
  {  "D50","AE","C9" },
  {  "D51","AE","CA" },
  {  "D52","AE","CB" },
  {  "D53","AE","CC" },
  {  "D54","AE","CD" },
  {  "D55","AE","CE" },
  {  "D56","AE","CF" },
  {  "D57","AE","D0" },
  {  "D58","AE","D1" },
  {  "D59","AE","D2" },
  {  "D60","AE","D3" },
  {  "D61","AE","D4" },
  {  "D62","AE","D5" },
  {  "D63","AE","D6" },
  {   "E1","AE","D7" },
  {   "E2","AE","D8" },
  {   "E3","AE","D9" },
  {   "E4","AE","DA" },
  {   "E5","AE","DB" },
  {   "E6","AE","DC" },
  {   "E7","AE","DD" },
  {   "E8","AE","DE" },
  {  "E8A","AE","DF" },
  {   "E9","AE","E0" },
  {  "E10","AE","E1" },
  {  "E11","AE","E2" },
  {  "E12","AE","E3" },
  {  "E13","AE","E4" },
  {  "E14","AE","E5" },
  {  "E15","AE","E6" },
  {  "E16","AE","E7" },
  {  "E17","AE","E8" },
  {  "E18","AE","E9" },
  {  "E19","AE","EA" },
  {  "E20","AE","EB" },
  {  "E21","AE","EC" },
  {  "E22","AE","ED" },
  {  "E23","AE","EE" },
  {  "E24","AE","EF" },
  {  "E25","AE","F0" },
  {  "E26","AE","F1" },
  {  "E27","AE","F2" },
  {  "E28","AE","F3" },
  {  "E29","AE","F4" },
  {  "E30","AE","F5" },
  {  "E31","AE","F6" },
  {  "E32","AE","F7" },
  {  "E33","AE","F8" },
  {  "E34","AE","F9" },
  {   "F1","FM","21" },
  {   "F2","FM","22" },
  {   "F3","FM","23" },
  {   "F4","FM","24" },
  {   "F5","FM","25" },
  {   "F6","FM","26" },
  {   "F7","FM","27" },
  {   "F8","FM","28" },
  {   "F9","FM","29" },
  {  "F10","FM","2A" },
  {  "F11","FM","2B" },
  {  "F12","FM","2C" },
  {  "F13","FM","2D" },
  {  "F14","FM","2E" },
  {  "F15","FM","2F" },
  {  "F16","FM","30" },
  {  "F17","FM","31" },
  {  "F18","FM","32" },
  {  "F19","FM","33" },
  {  "F20","FM","34" },
  {  "F21","FM","35" },
  {  "F22","FM","36" },
  {  "F23","FM","37" },
  {  "F24","FM","38" },
  {  "F25","FM","39" },
  {  "F26","FM","3A" },
  {  "F27","FM","3B" },
  {  "F28","FM","3C" },
  {  "F29","FM","3D" },
  {  "F30","FM","3E" },
  {  "F31","FM","3F" },
  {  "F32","FM","40" },
  {  "F33","FM","41" },
  {  "F34","FM","42" },
  {  "F35","FM","43" },
  {  "F36","FM","44" },
  {  "F37","FM","45" },
  {  "F38","FM","46" },
  {  "F39","FM","47" },
  {  "F40","FM","48" },
  {  "F41","FM","49" },
  {  "F42","FM","4A" },
  {  "F43","FM","4B" },
  {  "F44","FM","4C" },
  {  "F45","FM","4D" },
  {  "F46","FM","4E" },
  {  "F47","FM","4F" },
  {  "F48","FM","50" },
  {  "F49","FM","51" },
  {  "F50","FM","52" },
  {  "F51","FM","53" },
  {  "F52","FM","54" },
  {   "G1","FM","55" },
  {   "G2","FM","56" },
  {   "G3","FM","57" },
  {   "G4","FM","58" },
  {   "G5","FM","59" },
  {   "G6","FM","5A" },
  {   "G7","FM","5B" },
  {  "G7A","FM","5C" },
  {  "G7B","FM","5D" },
  {   "G8","FM","5E" },
  {   "G9","FM","5F" },
  {  "G10","FM","60" },
  {  "G11","FM","61" },
  {  "G12","FM","62" },
  {  "G13","FM","63" },
  {  "G14","FM","64" },
  {  "G15","FM","65" },
  {  "G16","FM","66" },
  {  "G17","FM","67" },
  {  "G18","FM","68" },
  {  "G19","FM","69" },
  {  "G20","FM","6A" },
  {  "G21","FM","6B" },
  {  "G22","FM","6C" },
  {  "G23","FM","6D" },
  {  "G24","FM","6E" },
  {  "G25","FM","6F" },
  {  "G26","FM","70" },
  { "G26A","FM","71" },
  {  "G27","FM","72" },
  {  "G28","FM","73" },
  {  "G29","FM","74" },
  {  "G30","FM","75" },
  {  "G31","FM","76" },
  {  "G32","FM","77" },
  {  "G33","FM","78" },
  {  "G34","FM","79" },
  {  "G35","FM","7A" },
  {  "G36","FM","7B" },
  {  "G37","FM","7C" },
  {  "G38","FM","7D" },
  {  "G39","FM","7E" },
  {  "G40","FM","A1" },
  {  "G41","FM","A2" },
  {  "G42","FM","A3" },
  {  "G43","FM","A4" },
  {  "G44","FM","A5" },
  {  "G45","FM","A6" },
  {  "G46","FM","A7" },
  {  "G47","FM","A8" },
  {  "G48","FM","A9" },
  {  "G49","FM","AA" },
  {  "G50","FM","AB" },
  {  "G51","FM","AC" },
  {  "G52","FM","AE" },
  {  "G53","FM","AF" },
  {  "G54","FM","B0" },
  {   "H1","FM","B1" },
  {   "H2","FM","B2" },
  {   "H3","FM","B3" },
  {   "H4","FM","B4" },
  {   "H5","FM","B5" },
  {   "H6","FM","B6" },
  {  "H6A","FM","B7" },
  {   "H7","FM","B8" },
  {   "H8","FM","B9" },
  {   "I1","FM","BA" },
  {   "I2","FM","BB" },
  {   "I3","FM","BC" },
  {  "I5A","FM","BD" },
  {   "I4","FM","BE" },
  {   "I5","FM","BF" },
  {   "I6","FM","C0" },
  {   "I7","FM","C1" },
  {   "I8","FM","C2" },
  {   "I9","FM","C3" },
  {  "I10","FM","C4" },
  {  "I11","FM","C5" },
  {  "I12","FM","C6" },
  {  "I13","FM","C7" },
  {  "I14","FM","C8" },
  {  "I15","FM","C9" },
  {   "K1","FM","CB" },
  {   "K2","FM","CC" },
  {   "K3","FM","CD" },
  {   "K4","FM","CE" },
  {   "K5","FM","CF" },
  {   "K7","FM","D0" },
  {   "K6","FM","D1" },
  {   "L1","FM","D2" },
  {   "L2","FM","D3" },
  {   "L3","FM","D4" },
  {   "L4","FM","D5" },
  {   "L5","FM","D6" },
  {   "L6","FM","D7" },
  {   "L7","FM","D8" },
  {   "M1","FM","D9" },
  {   "M2","FM","DA" },
  {   "M3","FM","DC" },
  {   "M4","FM","DD" },
  {   "M5","FM","DE" },
  {   "M6","FM","DF" },
  {   "M7","FM","E0" },
  {   "M8","FM","E1" },
  {   "M9","FM","E2" },
  {  "M10","FM","E3" },
  {  "M11","FM","E4" },
  {  "M12","FM","E5" },
  {  "M13","FM","E6" },
  {  "M14","FM","E7" },
  {  "M15","FM","E8" },
  {  "M16","FM","E9" },
  {  "M17","FM","EA" },
  {  "M18","FM","EB" },
  {  "M19","FM","EC" },
  {  "M20","FM","ED" },
  {  "M21","FM","EE" },
  {  "M22","FM","EF" },
  {  "M23","FM","F0" },
  {  "M24","FM","F1" },
  {  "M25","FM","F2" },
  {  "M26","FM","F3" },
  {  "M27","FM","F4" },
  {  "M28","FM","F5" },
  {  "M29","FM","F6" },
  {  "M30","FM","F7" },
  {  "M31","FM","F8" },
  {  "M32","FM","F9" },
  {  "M33","FM","FA" },
  {  "M34","FM","FB" },
  {  "M35","FM","FC" },
  {  "M36","FM","FD" },
  {  "M37","FM","FE" },
  {  "M38","FM","FF" },
  {  "M39","MS","21" },
  {  "M40","MS","22" },
  {  "M41","MS","23" },
  {  "M42","MS","24" },
  {  "M43","MS","25" },
  {  "M44","MS","26" },
  {   "N1","MS","27" },
  {   "N2","MS","28" },
  {   "N3","MS","29" },
  {   "N4","MS","2A" },
  {   "N5","MS","2B" },
  {   "N6","MS","2C" },
  {   "N7","MS","2D" },
  {   "N8","MS","2E" },
  {   "N9","MS","2F" },
  {  "N10","MS","30" },
  {  "N11","MS","31" },
  {  "N12","MS","32" },
  {  "N13","MS","33" },
  {  "N14","MS","34" },
  {  "N15","MS","35" },
  {  "N16","MS","36" },
  {  "N17","MS","37" },
  {  "N18","MS","38" },
  {  "N19","MS","39" },
  {  "N20","MS","3A" },
  {  "N21","MS","3B" },
  {  "N22","MS","3C" },
  {  "N23","MS","3D" },
  {  "N24","MS","3E" },
  {  "N25","MS","3F" },
  {  "N26","MS","40" },
  {  "N27","MS","41" },
  {  "N28","MS","42" },
  {  "N29","MS","43" },
  {  "N30","MS","44" },
  {  "N31","MS","45" },
  {  "N32","MS","46" },
  {  "N33","MS","47" },
  {  "N34","MS","48" },
  {  "N35","MS","49" },
  { "N35A","MS","4A" },
  {  "N36","MS","4B" },
  {  "N37","MS","4C" },
  {  "N38","MS","4D" },
  {  "N39","MS","4E" },
  {  "N40","MS","4F" },
  {  "N41","MS","50" },
  {  "N42","MS","51" },
  {   "O1","MS","52" },
  {   "O2","MS","53" },
  {   "O3","MS","54" },
  {   "O4","MS","55" },
  {   "O5","MS","56" },
  {   "O6","MS","57" },
  {   "O7","MS","58" },
  {   "O8","MS","59" },
  {   "O9","MS","5A" },
  {  "O10","MS","5B" },
  {  "O11","MS","5C" },
  {  "O12","MS","5D" },
  {  "O13","MS","5E" },
  {  "O14","MS","5F" },
  {  "O15","MS","60" },
  {  "O16","MS","61" },
  {  "O17","MS","62" },
  {  "O18","MS","63" },
  {  "O19","MS","64" },
  {  "O20","MS","65" },
  {  "O21","MS","66" },
  {  "O22","MS","67" },
  {  "O23","MS","68" },
  {  "O24","MS","69" },
  {  "O25","MS","6A" },
  {  "O26","MS","6B" },
  {  "O27","MS","6C" },
  {  "O28","MS","6D" },
  {  "O29","MS","6E" },
  {  "O30","MS","6F" },
  {  "O31","MS","70" },
  {  "O32","MS","71" },
  {  "O33","MS","72" },
  {  "O34","MS","73" },
  {  "O35","MS","74" },
  {  "O36","MS","75" },
  {  "O37","MS","76" },
  {  "O38","MS","77" },
  {  "O39","MS","78" },
  {  "O40","MS","79" },
  {  "O41","MS","7A" },
  {  "O42","MS","7B" },
  {  "O43","MS","7C" },
  {  "O44","MS","7D" },
  {  "O45","MS","7E" },
  {  "O46","MS","A1" },
  {  "O47","MS","A2" },
  {  "O48","MS","A3" },
  {  "O49","MS","A4" },
  {  "O50","MS","A5" },
  {  "O51","MS","A6" },
  {   "P1","MS","A7" },
  {   "P2","MS","A9" },
  {   "P3","MS","AA" },
  {   "P4","MS","AB" },
  {   "P5","MS","AC" },
  {   "P6","MS","AE" },
  {   "P7","MS","AF" },
  {   "P8","MS","B0" },
  {   "P9","MS","B1" },
  {  "P10","MS","B2" },
  {  "P11","MS","B3" },
  {   "Q1","MS","B4" },
  {   "Q2","MS","B5" },
  {   "Q3","MS","B6" },
  {   "Q4","MS","B7" },
  {   "Q5","MS","B8" },
  {   "Q6","MS","B9" },
  {   "Q7","MS","BA" },
  {   "R1","MS","BB" },
  {   "R2","MS","BC" },
  {   "R3","MS","BD" },
  {   "R4","MS","BE" },
  {   "R5","MS","BF" },
  {   "R6","MS","C0" },
  {   "R7","MS","C1" },
  {   "R8","MS","C2" },
  {   "R9","MS","C3" },
  {  "R10","MS","C4" },
  {  "R11","MS","C5" },
  {  "R12","MS","C6" },
  {  "R13","MS","C7" },
  {  "R14","MS","C8" },
  {  "R15","MS","C9" },
  {  "R16","MS","CA" },
  {  "R17","MS","CB" },
  {  "R18","MS","CC" },
  {  "R19","MS","CD" },
  {  "R20","MS","CE" },
  {  "R21","MS","CF" },
  {  "R22","MS","D0" },
  {  "R23","MS","D1" },
  {  "R24","MS","D2" },
  {  "R25","MS","D3" },
  {   "S1","MS","D4" },
  {   "S2","MS","D5" },
  {   "S3","MS","D6" },
  {   "S4","MS","D7" },
  {   "S5","MS","D8" },
  {   "S6","MS","D9" },
  {   "S7","MS","DA" },
  {   "S8","MS","DB" },
  {   "S9","MS","DC" },
  {  "S10","MS","DD" },
  {  "S11","MS","DE" },
  {  "S12","MS","DF" },
  {  "S13","MS","E0" },
  {  "S14","MS","E1" },
  { "S14A","MS","E2" },
  {  "S15","MS","E3" },
  {  "S16","MS","E4" },
  {  "S17","MS","E5" },
  {  "S18","MS","E6" },
  {  "S19","MS","E7" },
  {  "S20","MS","E8" },
  {  "S21","MS","E9" },
  {  "S22","MS","EA" },
  { "S17A","MS","EB" },
  {  "S23","MS","EC" },
  {  "S24","MS","ED" },
  {  "S25","MS","EE" },
  {  "S26","MS","EF" },
  {  "S27","MS","F0" },
  {  "S28","MS","F1" },
  {  "S29","MS","F2" },
  {  "S30","MS","F3" },
  {  "S31","MS","F4" },
  {  "S32","MS","F5" },
  {  "S33","MS","F6" },
  {  "S34","MS","F7" },
  {  "V39","MS","F8" },
  {  "S35","MS","F9" },
  {  "S36","MS","FA" },
  {  "S37","MS","FB" },
  {  "S38","MS","FC" },
  {  "S39","MS","FD" },
  {  "S40","MS","FE" },
  {  "S41","MS","FF" },
  {  "S42","SZ","21" },
  {  "S43","SZ","22" },
  {  "S44","SZ","23" },
  {  "S45","SZ","24" },
  {   "T1","SZ","25" },
  {   "T2","SZ","26" },
  {   "T3","SZ","27" },
  {   "T4","SZ","28" },
  {   "T5","SZ","29" },
  {   "T6","SZ","2A" },
  {   "T7","SZ","2B" },
  {  "T7A","SZ","2C" },
  {   "T8","SZ","2D" },
  {  "T8A","SZ","2E" },
  {   "T9","SZ","2F" },
  {  "T9A","SZ","30" },
  {  "T10","SZ","31" },
  { "Aa32","SZ","32" },
  {  "T11","SZ","33" },
  {  "T12","SZ","34" },
  {  "T13","SZ","35" },
  {  "T14","SZ","36" },
  {  "T15","SZ","37" },
  {  "T16","SZ","38" },
  {  "T17","SZ","39" },
  {  "T18","SZ","3A" },
  {  "T19","SZ","3B" },
  {  "T20","SZ","3C" },
  {  "T21","SZ","3D" },
  {  "T22","SZ","3E" },
  {  "T23","SZ","3F" },
  {  "T24","SZ","40" },
  {  "T25","SZ","41" },
  {  "T26","SZ","42" },
  {  "T27","SZ","43" },
  {  "T28","SZ","44" },
  {  "T29","SZ","45" },
  {  "T30","SZ","46" },
  {  "T31","SZ","47" },
  {  "T32","SZ","48" },
  {  "T33","SZ","49" },
  {  "T34","SZ","4A" },
  {  "T35","SZ","4B" },
  {   "U1","SZ","4C" },
  {   "U2","SZ","4D" },
  {   "U3","SZ","4E" },
  {   "U4","SZ","4F" },
  {   "U5","SZ","50" },
  {   "U6","SZ","51" },
  {   "U7","SZ","52" },
  {   "U8","SZ","53" },
  {   "U9","SZ","54" },
  {  "U10","SZ","55" },
  {  "U11","SZ","56" },
  {  "U12","SZ","57" },
  {  "U13","SZ","58" },
  {  "U14","SZ","59" },
  {  "U15","SZ","5A" },
  {  "U16","SZ","5B" },
  {  "U17","SZ","5C" },
  {  "U18","SZ","5D" },
  {  "U19","SZ","5E" },
  {  "U20","SZ","5F" },
  {  "U21","SZ","60" },
  {  "U22","SZ","61" },
  {  "U23","SZ","62" },
  {  "U24","SZ","63" },
  {  "U25","SZ","64" },
  {  "U26","SZ","65" },
  {  "U27","SZ","66" },
  {  "U28","SZ","67" },
  {  "U29","SZ","68" },
  {  "U30","SZ","69" },
  {  "U31","SZ","6A" },
  {  "U32","SZ","6B" },
  {  "U33","SZ","6C" },
  {  "U34","SZ","6D" },
  {  "U35","SZ","6E" },
  { "Aa23","SZ","6F" },
  { "Aa24","SZ","70" },
  {  "U36","SZ","71" },
  {  "U37","SZ","72" },
  {  "U38","SZ","73" },
  {  "U39","SZ","74" },
  {  "U40","SZ","75" },
  {  "U41","SZ","76" },
  {   "V1","SZ","77" },
  {   "V2","SZ","78" },
  {   "V3","SZ","79" },
  {   "V4","SZ","7A" },
  {   "V5","SZ","7B" },
  {   "V6","SZ","7C" },
  {   "V7","SZ","7D" },
  {   "V8","SZ","7E" },
  {   "V9","SZ","A1" },
  {  "V10","SZ","A2" },
  {  "V11","SZ","A3" },
  {  "V12","SZ","A4" },
  {  "V13","SZ","A5" },
  {  "V14","SZ","A6" },
  {  "V15","SZ","A7" },
  {  "V16","SZ","A8" },
  {  "V17","SZ","A9" },
  {  "V18","SZ","AA" },
  {  "V19","SZ","AB" },
  {  "V20","SZ","AC" },
  {  "V21","SZ","AE" },
  {  "V22","SZ","AF" },
  {  "V23","SZ","B0" },
  {  "V24","SZ","B1" },
  {  "V25","SZ","B2" },
  {  "V26","SZ","B3" },
  {  "V27","SZ","B4" },
  {  "V28","SZ","B5" },
  {  "V29","SZ","B6" },
  {  "V30","SZ","B7" },
  {  "V31","SZ","B8" },
  {  "V32","SZ","B9" },
  {  "V33","SZ","BA" },
  {  "V34","SZ","BB" },
  {  "V35","SZ","BC" },
  {  "V36","SZ","BD" },
  {  "V37","SZ","BE" },
  {  "V38","SZ","BF" },
  {   "W1","SZ","C0" },
  {   "W2","SZ","C1" },
  {   "W3","SZ","C2" },
  {   "W4","SZ","C3" },
  {   "W5","SZ","C4" },
  {   "W6","SZ","C5" },
  {   "W7","SZ","C6" },
  {   "W8","SZ","C7" },
  {   "W9","SZ","C8" },
  {  "W10","SZ","C9" },
  { "W10A","SZ","CA" },
  {  "Aa4","SZ","CB" },
  {  "W11","SZ","CC" },
  {  "W12","SZ","CD" },
  {  "W13","SZ","CE" },
  {  "W14","SZ","CF" },
  {  "W15","SZ","D0" },
  {  "W16","SZ","D1" },
  {  "W17","SZ","D2" },
  {  "W18","SZ","D3" },
  {  "W19","SZ","D4" },
  {  "W20","SZ","D5" },
  {  "W21","SZ","D6" },
  {  "W22","SZ","D7" },
  {  "W23","SZ","D8" },
  {  "W24","SZ","D9" },
  {  "W25","SZ","DA" },
  {   "X1","SZ","DB" },
  {   "X2","SZ","DC" },
  {   "X3","SZ","DD" },
  {   "X4","SZ","DE" },
  {  "N18","SZ","DF" },
  {   "X5","SZ","E0" },
  {   "X6","SZ","E1" },
  {   "X7","SZ","E2" },
  {   "X8","SZ","E3" },
  {   "Y1","SZ","E4" },
  {   "Y2","SZ","E5" },
  {   "Y3","SZ","E6" },
  {   "Y4","SZ","E7" },
  {   "Y5","SZ","E8" },
  {   "Y6","SZ","E9" },
  {   "Y7","SZ","EA" },
  {   "Y8","SZ","EB" },
  {   "Z1","SZ","EC" },
  {   "Z2","SZ","ED" },
  {   "Z3","SZ","EE" },
  {   "Z4","SZ","EF" },
  {   "Z5","SZ","F0" },
  {   "Z6","SZ","F1" },
  {   "Z7","SZ","F2" },
  {   "Z9","SZ","F4" },
  {  "Z10","SZ","F5" },
  {  "Z11","SZ","F6" },
  {  "Aa1","UN","21" },
  {  "Aa2","UN","22" },
  {  "Aa3","UN","23" },
  {  "Aa5","UN","24" },
  {  "Aa6","UN","25" },
  {  "Aa7","UN","26" },
  {  "Aa8","UN","27" },
  {  "Aa9","UN","28" },
  { "Aa10","UN","29" },
  { "Aa11","UN","2A" },
  { "Aa12","UN","2B" },
  { "Aa13","UN","2C" },
  { "Aa14","UN","2D" },
  { "Aa15","UN","2E" },
  { "Aa16","UN","2F" },
  { "Aa17","UN","30" },
  { "Aa18","UN","31" },
  { "Aa19","UN","32" },
  { "Aa20","UN","33" },
  { "Aa21","UN","34" },
  { "Aa22","UN","35" },
  { "Aa25","UN","36" },
  { "Aa26","UN","37" },
  { "Aa27","UN","38" },
  { "Aa28","UN","39" },
  { "Aa29","UN","3A" },
  { "Aa30","UN","3B" },
  { "Aa31","UN","3C" },
  }

This is the main TeX file (hieros.tex):

% run: xelatex or lualatex hieros.tex
% followed by texlua and one more run of TeX...
\documentclass[a4paper]{article}
\pagestyle{empty}
\parindent=0pt
\usepackage{fontspec}
\usepackage{xcolor}
\newfontfamily\fontAE{GARDAE__.TTF}
\newfontfamily\fontFM{GARDFM__.TTF}
\newfontfamily\fontMS{GARDMSL_.TTF}
\newfontfamily\fontSZ{GARDSZ__.TTF}
\newfontfamily\fontUN{GARDU___.TTF}
\newcount\malc 
\malc=0 % Initializating a counter...
\newwrite\hiero % One I/O slot for saving temporary data...
\openout\hiero=hieros-input.tex % a file generated by TeX
\def\malfile{hieros-output.tex} % a file generated by Lua
\def\tohiero#1{%
  \write\hiero{#1}%
  \advance\malc by 1%
  \IfFileExists{\malfile}%
    {\input{\malfile}}% 2+ runs of TeX...
    {{\color{red}#1}}% First run of TeX...
  }% End of \tohiero...
\begin{document}
\frenchspacing
% A single test of loaded fonts...
%{\fontAE\char"F030}{\fontFM\char"F030}{\fontMS\char"F030}{\fontSZ\char"F030}{\fontUN\char"F030}
Text before. \tohiero{A10-B3-p-i-y-a-w}
Some text.\par \tohiero{A12-A23-M23-M40-Aa30}
More text. \tohiero{U1-T33-Aa15} Text after.
\closeout\hiero % Formal closing of the file...
\end{document}

After the first run of TeX (lualatex or xelatex) we are getting:

mwe input file

The generated TeX file with three lines (hieros-input.tex) looks like this:

A10-B3-p-i-y-a-w
A12-A23-M23-M40-Aa30
U1-T33-Aa15

This file is processed by a standalone Lua script (hiero-script.lua) by running this command texlua hiero-script.lua:

-- Loading data files...
-- The files are large, I am not including them in this script directly.
require"hiero-all"
require"hiero-repl"
local bonusrepl={
  { "[*][*]", "B" },
  { "[*]", "A" },
  { "J", "Aa" },
  { "[Aa][Aa]", "Aa" },     
  }

-- The main function...
function testme(mstring)
--print(mstring)
local toTeX=""

-- Several replacements...
for i=1,#bonusrepl do -- change any J and any AA/Aa/aA/aa
mstring=mstring:gsub(bonusrepl[i][2],bonusrepl[i][2])
end -- of i
--print(mstring)
for i=1,#replacements do
mstring=mstring:gsub("([^0-9])"..replacements[i][3].."([^a0-9])", "%1"..replacements[i][2].."%2")
end -- of for i
--print(mstring)

-- Search in hiero-all and replace the longest search by a TeX command...
-- Repeat space, but delete dash...
repeat

local tempfound=""
local tempcounter=0
for j=1,#hieroglyphs do
templeft=string.sub(mstring,1,string.len(hieroglyphs[j][4]))
if templeft==hieroglyphs[j][5] then
  if string.len(templeft)>string.len(tempfound) then 
    tempfound=templeft
    tempcounter=j
  end -- of string.len...
end -- of if
end -- of for j
--print(tempfound.." "..tempcounter)

-- Do what you must to do!
if tempcounter~=0 then
toTeX=toTeX.."{\\font"..hieroglyphs[tempcounter][2].."\\char\"F0"..hieroglyphs[tempcounter][3].."}"
mstring=mstring:sub(string.len(tempfound)+1)
else
-- save space as it is, ignore other characters
if mstring:sub(1,1)==" " then toTeX=toTeX.." " end
mstring=mstring:sub(1+1)
end -- of if string.len
--print(mstring)
until mstring==""
whereto:write(toTeX)

end -- of function testme

-- A single test...
--testme("A17-A-B3**-B5A B6B-p-q-r AA1-C4-J3 i-i B35")

whereto=io.open("hieros-output.tex","w")
io.write("Processing entry:")
local counter=0
for line in io.lines("hieros-input.tex") do
counter=counter+1
io.write(" "..counter)
whereto:write("\\ifnum\\malc="..counter.." ")
testme(line.."-") 
-- without "-" A10 would be recognized, but not "w" at the end of entry.
whereto:write("\\fi\n")
end -- of for line
io.write("\n")

-- Close the file and end the script...
whereto:close()

The new TeX file (hieros-output.tex) is generated and there is a message (Processing entry: 1 2 3) at the terminal. The content of the file is as follows:

\ifnum\malc=1 {\fontAE\char"F02A}{\fontAE\char"F05D}{\fontMS\char"F0B6}{\fontFM\char"F0EA}{\fontSZ\char"F0EF}{\fontAE\char"F0BA}{\fontFM\char"F0A4}\fi
\ifnum\malc=2 {\fontAE\char"F02C}{\fontAE\char"F039}{\fontFM\char"F0F0}{\fontMS\char"F022}{\fontUN\char"F03B}\fi
\ifnum\malc=3 {\fontSZ\char"F04C}{\fontSZ\char"F049}{\fontUN\char"F02E}\fi

After the next run of TeX we are getting this snippet in the PDF file. Each hieroglyph is displayed independently of other hieroglyphs. Each line represented one TeX entry (\tohiero command).

Displaying hieroglyphs is quite complex area, the example covers only one direction as we know it from regular typesetting.

mwe output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.