LoshSetter is a graphical user interface (GUI) for LoshDoc, a typesetting software designed to create documents using the Losh writing system. Users can define their documents using either Markdown or XML, and then export their documents to PNG, SVG, or PDF formats.
LoshSetter runs entirely within the browser. It uses the Canvas API for PNG generation and the PDFKit library for PDF generation. It has been confirmed to work in Firefox and Chrome, but results are typically better in Chromium-based browsers.
LoshSetter's GUI consists of five main parts: the Toolbar, Sidebar, Input Window, Preview Window, and Status Bar.
The toolbar is located at the top of the window, and has six buttons: Save, Export, Tools, Help, Documentation, and Credits.
The Save button saves the state of LoshSetter into the browser's local storage. This includes the settings in the sidebar, and the input in the input window. Upon reopening LoshSetter, the state of the editor will be restored.
The Export button exports the document to the user's computer. Depending on the current export settings, the document will be downloaded as a PDF file, or a set of PNG or SVG files. If the document fails to export, an error message will be shown in the status bar.
The Tools button allows the user to access EngLosh, a transliteration tool that converts
English text into the ASCII-based Phonetic Losh Alphabet. See the documentation for info on the
transliteration scheme.
The user can input American English text into the left window, and clicking the center button will cause
text to appear in the right window. Words with multiple recognized transliterations will appear as
dropdowns, where the desired transliteration can be selected. Words without recognized transliterations will
appear in all-caps, where they can be edited as text input fields. Pressing the button at the bottom of the
window will copy the transliteration to the user's keyboard as plaintext.
The Help button shows the user manual.
The Documentation button opens a dialog with more info about the XML format for Losh Documents.
The Credits button shows the credits.
The sidebar contains the document's Export Settings. In addition, it contains the document's Page Settings and Document Metadata in Markdown mode.
The Export Settings allow the user to change the filename and format used when exporting the document. In addition, when the document is set to export as a PNG, its resolution can be set using the DPI field.
The Page Settings specify the document's page size and margins. They can be set in units of inches, centimeters, or points. Page sizes can also be set to some presets from both the ANSI and ISO 216 standards.
The Document Metadata field can be used to specify document metadata for PDF exports, including the Title, Author, Subject, and Keywords.
To modify the document's page size or document metadata in XML mode, see the documentation.
The input window consists of three buttons and a text field. Pressing the buttons at the top switches the input mode between Markdown Mode (which can be either English Markdown mode or Phonetic Markdown mode) and XML Mode.
In Markdown Mode, the user can input Markdown and the document will generate directly from it. The following elements are supported:
*Italic*
**Bold**
`Unicode`
## Heading Level 2
In English Markdown mode, LoshSetter will automatically convert the English text into Losh by guessing at transliterations, or just using the input itself where transliterations are not found. In Phonetic Markdown mode, the user has to input the text in the Losh Phonetic Alphabet.
In XML Mode, the user inputs the document data according to the XML format found in the documentation.
The preview window has three buttons and a gray window. The Preview button renders an SVG preview of the document into the window. In the case that rendering the document fails, an error message will appear in the status bar. The other two buttons can be used to change the preview size. If the document does not fit within the window, it can be scrolled.
The status bar only changes when the document is previewed or exported. It shows either the time taken to render the document, or that the document failed to render.
This document contains the specification for the XML format used in LoshDoc (and LoshSetter by extension).
LoshDoc documents are written as XML text. A document consists of a single <document>
tag, which
functions similarly to the <html>
tag of an HTML document. This tag is
required—it is the
entry
point from which LoshDoc begins parsing the document.
The <document>
tag must contain a <body>
tag and may optionally
contain a
<head>
tag. Like in HTML, the <body>
tag contains the visible content
of the
document while the <head>
tag contains page data and metadata relating
to the document.
The <head>
tag may contain the following tags:
<title>
: The text contained within this tag is used as the
document's title when
exported
as a PDF.<author>
: The text contained within this tag is used as the
document's author
when
exported as a PDF.<subject>
: The text contained within this tag is used as the
document's subject
when
exported as a PDF.<keywords>
: The text contained within this tag is used as the
document's keywords
when
exported as a PDF.<page />
: This tag must have two attributes width
and
height
, both
of which must be numbers. They represent the document's page width and page height respectively, in
points.
<margins />
: This tag must have four attributes top
, left
,
right
, and bottom
, all of which must be
numbers. They represent the
document's page
margins in points.
In the case that the <head>
tag or any of the above tags are omitted,
the document is
generated
without the omitted metadata and the default page settings are as follows:
Page width: 612 pt
Page height: 792 pt
Top Margin: 72 pt
Left Margin: 72 pt
Right Margin: 72 pt
Bottom Margin: 72 pt
In other words, the default document contains no metadata and is a Letter size document (ANSI A) with 1-inch margins all around.
The <body>
tag contains the document's content, consisting of
plaintext and content
tags.
LoshDoc by default collapses whitespace; that is, all sequences of whitespace are consolidated down to a
single
space. Line breaks, paragraph breaks, and page breaks have content tags to handle them. Sequences of more
than one
space can be created using a non-breaking space (Unicode code U+00A0
).
LoshDoc by default parses text as if it were written in the Losh Phonetic Alphabet. The
Losh
Phonetic Alphabet is a system for transliterating English phonemes using ASCII text. It is case-insensitive
and can
express any sequence of Losh letters (and by extension, any sequence of English phonemes with the caveat
that
ɪ/j
and u/w
are not distinguished). Below is a
table of letters in the Losh
Phonetic
Alphabet:
Phoneme | Letter | Phoneme | Letter | Phoneme | Letter | Phoneme | Letter | Phoneme | Letter |
---|---|---|---|---|---|---|---|---|---|
/b/ | b | /d/ | d | /g/ | g | /s/ | s | /d͡ʒ/ | j |
/p/ | p | /t/ | t | /k/ | k | /z/ | z | /r/ | r |
/m/ | m | /n/ | n | /ŋ/ | ng | /ʃ/ | sh | /l/ | l |
/f/ | f | /θ/ | th | /h/ | h | /ʒ/ | zh | /j/ | y |
/v/ | v | /ð/ | dh | /ɦ/, /ʔ/ | gh | /t͡ʃ/ | c | /w/ | w |
Phoneme | Letter | Phoneme | Letter | Phoneme | Letter | Phoneme | Letter |
---|---|---|---|---|---|---|---|
/i/ | i | /a/ | a | /ʊ/ | oo | /aɪ/ | ai |
/ɪ/ | y | /ʌ/ | u | /u/ | w | /ɔɪ/ | oi |
/ɛ/ | e | /ɔ/ | oa | /ju/ | yu | /aʊ/ | au |
/æ/ | ae | /oʊ/ | o | /eɪ/ | ei | /ə/ | x |
To prevent ambiguities, e.g. the difference between /ʃ/
and /sh/
, the letter
q
can be placed to break any digraphs into their constituent letters. E.g.
sh
is
different
from sqh
.
When rendering the document, LoshDoc will first parse all non-escaped words into a sequence of phonemes, which it then uses to render Losh text.
This is a list of block-level tags that LoshDoc recognizes:
<h1>~<h6>
: Like their HTML counterparts, these represent
headings. By default
LoshDoc
renders these in bold at the following sizes, with linebreaks before and after:<h1>
: 2x body text size<h2>
: 1.50 x body text size<h3>
: 4 / 3 x body text size<h4>
: 1.25 x body text size<h5>
: 1.20 x body text size<h6>
: body text size<p>
: Represents a paragraph. LoshDoc breaks lines before and after a
paragraph, and
adds
margins on the top and/or bottom if the paragraph does not begin/end a page.This is a list of inline-level tags that LoshDoc recognizes:
<b>
: Marks bold text; that is, increases the font-weight to 700 if
it is lower than
700.<i>
: Marks italic text. Only affects Unicode text.<strong>
: Alias of <b>
.<em>
: Alias of <i>
.<unicode>
: Marks text within it as Unicode text. Unicode text is
printed as plain
text
instead of being parsed as Phonetic Losh.<span>
: Does not apply any styling by default, but can accept
attributes to style
text within
itself.This is a list of layout tags that LoshDoc recognizes:
<br />
: Marks a line break.<pbr />
: Marks a page break.Any block- or inline-level tag can have any of the following attributes, which affect the text rendered within them:
text-align
: Only supported by block-level elements. Specifies whether the
text within the
element
should be left-aligned, right-aligned, center-aligned, or justified. Accepts left
,
center
, right
, or justify
. Defaults to left
.
font-family
: Changes the font used to render Unicode text. Accepts the
name of a font.
Defaults to
CMU Serif
.
font-size
: Changes the font size. Accepts a number, in points. Defaults to
12
.
font-weight
: Changes the font weight. Accepts a number. For Losh fonts
this can be any
number, for
Unicode fonts the weight is rounded to the nearest weight supported by the font. Defaults to
300
. For
reference, common font weights are defined below.
font-style
: Changes the font style. Accepts normal
or italic
.
Defaults to
normal
.
line-height
: Changes the line height. Accepts a number. Defaults to 1.25
.color
: Changes the color of text. Accepts a string that can be parsed as a
color (hex, rgb,
color
name, etc.) Defaults to #000000
.Common Font Weights:
Number | Name |
---|---|
100 | Extra Light |
200 | Light |
300 | Thin |
400 | Normal |
500 | Medium |
600 | Semi Bold |
700 | Bold |
800 | Extra Bold |
900 | Black (Heavy) |
An overview of the 16-vowel (Younger) Losh alphabet can be found here.
Font weights for Losh text are expressed as numbers. This is because Losh text is rendered as a series of vector paths that are stroked in, and therefore the font weight tells LoshDoc what stroke width to render the strokes with. For reference, the default font in LoshDoc, LoshVect, uses the following formula to determine its stroke width:
strokeWidth = fontSize * (0.3 + 0.001 * weight)
where weight
is the input to the function. Losh fonts are designed so that
the width of
strokes scales
similarly to a traditional Unicode font between the range of 100-900.
The original implementation of LoshDoc, written in TypeScript, uses the fontmanager-redux
package from
npm to read the user's local font library to allow the usage of any font. In some implementations of
LoshDoc
(such as LoshSetter), there is no access to the user's local font library and therefore the program is
limited
to the fonts specified in the PDF specification. In these implentations, the default Unicode font is usually
Times
.
Because different Unicode fonts are different sizes, even at the same font size, Unicode text may not always appear to fit with Losh text size-wise. LoshVect was designed to scale properly with Computer Modern Serif, but it may appear too large or too small when used with other Unicode fonts.
In order to determine the spacing of Unicode fonts, LoshDoc uses text metrics to gather the size on the
page of
each Unicode word. The original implementation of LoshDoc uses the canvas
package from npm to
do this.
When done in the browser, different browsers may give different results.
In order to align Unicode fonts with Losh fonts, the hanging
setting of the
renderer's
vertical
text-alignment setting is used. In certain environments, this may cause the Unicode text to not be
vertically
aligned with Losh text.
At the time of writing, there is only one font designed for Losh, which is LoshVect. Therefore there are not any capabilities within LoshDoc to change Losh fonts. I might one day design new Losh fonts or write documentation for Losh fonts (which themselves are written in JSON), but at the moment there are no plans to do either.