kriskowal / tengwarjs

A Tengwar (J.R.R. Tolkien’s Elvish alphabet) transcriber for ES5 and HTML5
http://tengwar.3rin.gs
MIT License
58 stars 9 forks source link

This is a Tengwar transcriber suitable for transcribing Sindarin Elvish from a phonetic encoding of the Latin alphabet, to the General Use mode of the Tengwar. It is written in JavaScript and is suitable for use as:

Using the Script

The script searches the document for elements with the tengwar class. The class must also include either parmaite or annatar to select the rendering font. This is not merely for the purpose of applying the appropriate web font, but also instructs the script on which bindings to use for kerning tehtar. The body of a tengwar class must be rendered with the included Tengar Annatar variant webfont or Tengwar Parmaitë using the included tengwar-annatar.css or tengwar-parmaite.css.

If the element has a data-tengwar property, that property is expected to contain phonetic letters from the latin alphabet and gets transcribed into bindings for the Tengwar Anntar font in the General Use mode, popular for Sindarin and English. The script populates the element's inner HTML with the font bindings, rendering the desired tengwar text visible.

class="tengwar annatar"

If the element has a data-mode property, the latin letters are instead transcribed into key bindings through the Classical mode, popular for Quenya, or the mode of Beleriand. Various options can also be applied.

data-mode="general-use no-ach-laut reverse-curls"
data-mode="classical reverse-curls"
data-mode="beleriand"
data-mode="general-use black-speech"

If the element has a data-encoded property, the value is expected to be a description of the tengwar and tehtar to display like romen:a;ungwe:a;romen:o;numen for "Aragorn" in the General Use mode.

data-encoded="romen:a;ungwe:a;romen:o;numen"

Of course, a page can bypass the whole automated transcription process by statically populating the element with the desired key bindings and using neither of these data properties.

The script checks for modern browser features and stops if the necessary features are not present.

Using the Modules

Tengwar Notation

Tengwar Notation is useful for succinctly representing the first stage of transcription, before translation to key bindings for a particular font. The notation uses the names of the tengwa followed by a list of tehtar in a consistent order:

The notation is useful for manually describing a transcription, either to override the transcriber, or for testing a transcriber.

Tengwar Object Notation

Tengwar Object Notation represents a word of Tengwar as an array of objects. Each object has properties,

Words are wrapped in an array to make a sentence. Sentences are wrapped to make paragraphs. Paragraphs are wrapped to make sections. Somehow I’ve neglected stanzas within paragraphs. This will be remedied in a future version, and the nodes will probably be revised to be more sophisticated than merely nested arrays.

A font module must have a makeColumn function that produces objects with these properties and the attendant methods as described for the Tengwar Annatar module above.