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:
-
The advance from the previous group,
i.e. the distance in 1/1000 EM between
the top-left coordinate (0,0) of the current group
and its equivalent in the previous group.
Within a group, all indicated positions are relative to this
coordinate (0,0).
The advance includes the space between the previous group
and the current one that corresponds to
an occurrence of operator '-' in RES.
The advance is normally 0 if the group is the first one of the fragment
(a nonzero value is treated as 0).
-
The conceptual length of the group, which is roughly the distance
in 1/1000 EM
between the left-most pixel in the group
and the pixel just right of the right-most pixel in the group
(for horizontal text directions) or
between the top-most pixel in the group
and the pixel just under the bottom-most pixel in the group
(for vertical text directions).
However RES allows
glyphs to be printed partly outside this area, and RESlite adopts
this possibility.
The length excludes the space between the current group and
the next that corresponds to
an occurrence of operator '-' in RES.
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:
-
The number of a font where the glyph is found.
Files containing fonts are numbered starting from 1.
See the description of the fonts file;
note that the mapping from Gardiner codes to fonts and
indexes within those fonts is unnecessary for RESlite
and can be omitted from the fonts file.
Also mnemonics are not used for processing RESlite.
-
The index of the glyph within the indicated font.
-
The number 1 if the glyph is to be mirrored, 0 otherwise.
-
Degrees of rotation, as in a
named_glyph in RES.
-
Code of the color, according to the table below.
-
Horizontal scaling factor, 1000 being the natural size.
-
Vertical scaling factor.
-
The x and y coordinates of the center point of the glyph (or the coordinates
just to the right of or below the center if the width or height are even),
in multiples of 1/1000 EM,
relative to the top-left corner of the group.
-
The x and y coordinates of the area that is to be
actually rendered of the glyph, relative to the
top-left corner and the width
and height of the glyph, so (0,0) is the top-left corner
and (1000,1000) is just next to the bottom-right corner.
These and the next two nums
are used e.g. to implement argument 'omit' of
a modify in RES.
-
The width and height of the area that is to be
actually rendered of the glyph, in 1/1000 of its natural
width and natural height, respectively.
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:
-
The number of a font from which the characters in the string
are to be taken, as in the definition of glyph above.
-
Code of the color, according to the table below.
-
The EM size of the characters, in multiples of 1/1000 EM. For example, 250
means that the EM size of the characters should be about one fourth
of the natural height of most hieroglyphs.
-
The x and y coordinates of the center point of the entire note (or the coordinates
just to the right of or below the center if the width or height are even),
in multiples of 1/1000 EM, relative to the top-left corner of the group.
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:
-
The x and y coordinates of the center point of the area of shading
(or the coordinates
just to the right of or below the center if the width or height are even),
in multiples of 1/1000 EM, relative to the top-left corner of the group.
-
The width and height of the area of shading, in multiples of 1/1000 EM.
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> |
' ' |
'\"'
'\\'
The color codes in glyphs represent
colors according to the following table:
0 | white
|
1 | silver
|
2 | gray
|
3 | yellow
|
4 | fuchsia
|
5 | aqua
|
6 | olive
|
7 | purple
|
8 | teal
|
9 | red
|
10 | lime
|
11 | blue
|
12 | maroon
|
13 | green
|
14 | navy
|
15 | black
|