RES home

RESlite 0.3

One major disadvantage of RES encoding is that conversion to graphical representations is relatively costly, and requires a complicated implementation. To allow fast processing of hieroglyphic texts in a wide range of settings, we have introduced RESlite next to RES. This is a much simpler format than RES and yet allows the same flexibility with regard to e.g. line breaks, device resolution, and the choice between say grayscale and bilevel pixel formats.

However, RESlite is font-dependent, and glyphs are in fact identified by positions within fonts. Furthermore, the text direction (especially a horizontal versus vertical direction) is also fixed in RESlite. This makes RESlite entirely unsuitable as a permanent format for storing hieroglyphic texts. Furthermore, because coordinates and scaling factors are rounded off in producing RESlite from RES, graphical representations obtained from RESlite may be of somewhat lower quality than those obtained directly from RES. Lastly, there are fewer possibilities in RESlite for elegantly representing colors by underlining or overlining, and for elegant padding between groups. Since there is no equivalent of argument fix in RESlite, a sequence of top_groups connected with fix in RES must be represented as one single group in RESlite, which allows fewer line breaks.

RESlite consists of a sequence of tokens, each of which cannot contain white space characters, and each pair of consecutive tokens is separated by one or more white space characters. The amount (one or two or more) and type of white space (e.g. tabs, newlines or spaces) have no significance. After possible initial white space characters, the first token in a fragment of RESlite is a '$'. As the first non-white space character in a RES fragment cannot be '$', it is unambiguous whether a given string of encoding is RES or RESlite, and the implementation should treat encodings according to whether the first (non-space) character is or is not '$'.

All numbers in RESlite are integers. Where we want to represent real numbers we use a fixed-point representation, in terms of a multiple of 1/1000.

In the description of RESlite below, we use the same notational conventions as in the annotated grammar describing RES.


Main definitions

A fragment of RESlite corresponds to a fragment of RES. The sequence of groups in RESlite corresponds to the sequence of top_groups separated by operator '-' in RES. The information attached to an occurrence of '-' in RES, in particular about areas of shading, is encoded with the preceding group in RESlite. In implementations, line breaks typically occur on the boundaries between groups. The areas of shading following a group that occurs just before a line break are not to be rendered in graphical representations.

Just after the '$' we find the text direction and a num indicating the unit size. The text direction is as in RES, but may not be overridden by the implementation, except left-to-right versus right-to-left. Where we write "left" or "right" in the below, we mean "right" of "left", respectively, if the direction is 'hrl' or 'vrl'. In other words, the description below assumes 'hlr' for 'hrl' and 'vlr' for 'vrl', but the entire graphical representation (except notes) is then mirrored after rendering if the actual direction is 'hrl' or 'vrl'.

The unit size is similar to the unit size in RES, but here it is an integer that indicates a multiple of 1/1000 EM. Hence, a unit size of 1000 indicates that the height of a line (when direction is 'hlr' or 'hrl') or width of a column (when direction is 'vlr' or 'vrl') is 1 EM.


fragment ->
	[ w ] '$' w direction w num w ( group )* 'e' [ w ]

direction ->
        'hlr' | 'hrl' | 'vlr' | 'vrl'

A group starts with 2 nums indicating, in this order: Then a list of expressions follows that specifies the collection of glyphs in the group. Then there is a list of notes. Then we have two lists of shades. The first indicates the areas of shading within the group itself, the second the areas of shading in the space between the current group and the next corresponding to an occurrence of operator '-' in RES. This second list is to be ignored if the group occurs just before a line break or at the end of a fragment.

group ->
	'g' w num w num w ( expression )* ( note )* ( shade )* 'i' w ( shade )*

An expression may be a glyph or a pair of lists of expressions, separated by 'o', and enclosed in brackets. By means of such pairs, we may represent the argument 'on' or 'under' of a stack in RES. The 'internal' pixels from the second list of expressions erase any pixels from the first list.

expression ->
	glyph |
	'(' w ( expression )* 'o' w ( expression )* ')' w 

A glyph is represented by 12 nums, in this order:

glyph ->
	'c' w num w num w num w num w num w num w num w num w num w num w num w num w num w

A note is represented by a string and 5 nums, in this order:

note ->
        'n' w string w num w num w num w num w num w

A shade represents an area of shading, specified by 4 nums, in this order:

shade ->
	's' w num w num w num w num w


Auxiliary definitions

Tokens are separated by one or more white space characters. There may but need not be white space at the beginning and end of a fragment of RESlite. For some applications, a fragment should occur on a single line, and then no line breaks are allowed. For applications where several fragments occur one after the other, there may but need not be white space characters between 'e' of one fragment and '$' of the next.

w ->
        ( whitespace )+

whitespace ->
        ' ' | <HORIZONTAL_TAB> | <NEWLINE> | <CARRIAGE_RETURN> | <FORM_FEED>

We do not specify exactly what a num is, except that it should be in decimal notation. The implementation should however allow for realistic ranges. For most nums, long ints (assuming C, at least 4 bytes) will be quite sufficient. The index in a font (in glyph) is however best implemented as unsigned long int.

num ->
	<DECIMAL_INTEGER>

The definition of string is the same as in the annotated grammar describing RES.

string ->
	'"' ( printable )+ '"'

printable ->
	<GRAPH_EXCEPT_DOUBLEQUOTE_AND_BACKSLASH> |
	' ' |
	'\"'
	'\\'


Color codes

The color codes in glyphs represent colors according to the following table:

0white
1silver
2gray
3yellow
4fuchsia
5aqua
6olive
7purple
8teal
9red
10lime
11blue
12maroon
13green
14navy
15black