A simple set of rules for placement of Ruby text in Japanese typography.
This document was initially written in Japanese and translated to English by the Japanese Writing Technology Working Group of the Advanced Publishing Laboratory of Keio University.
It represents the subjective view of its authors and contributors as to one possible approach to address the problem, and does not claim to be the only possible solution. It is submitted to present a non-Japanese speaking audience with this particular approach, and to encourage discussion of this topic.
The original Japanese version is available in PDF format.
When the ruby annotation is wider than its base text, whether it can be allowed to overhang the characters preceding or following, and whether this affects the position of the base text.
When the ruby annotation is wider than its base text and the base text is at the start or the end of the line, whether the base text or the ruby annotation should be aligned with the line edge.
When there are multiple base characters, whether there can be a line wrap opportunity between them.
Here are the fundamental assumptions underlying the simple placement rules. In this document we refer to the ruby annotation and its base text, collectively, as the ruby block.
Ruby is used to display the reading or the meaning of the base characters. Therefore, the number one priority here is to avoid misreadings. Specifically, this method does not allow a ruby annotation which is wider than its base text to overhang the characters preceding or following the ruby block, whether they are kanji or kana characters.
Ruby in Japanese may be divided into the following 3 different types, based on the relationship between the ruby and the base characters (see JLReq “3.3.1 Usage of Ruby”).
Which one to use depends on the relationship between the ruby and the base characters. Mono-ruby is used to connect ruby to a single base character, Jukugo-ruby is used when multiple base characters each have a corresponding ruby and at the same time the whole group needs to be processed together, and group-ruby is used when ruby is attached to a group of base characters together (see ). Each is used when specified.
The size of the ruby annotation characters and their placement in the inline direction relative to the base characters is as follows:
The following sections describe in detail the placement of mono-ruby, jukugo-ruby, and group-ruby. However, since jukugo-ruby is more complex, it is explained last.
To align the following items to the two-step processing method described in [[[#matters-considered-by-the-placement-rules]]], points 1, 2, and 3 belong to the first step, and points 4 and 5 belong to the second.
When the ruby annotation consists of two or more characters, each character in the annotation is placed immediately next to its neighboring character, without any inter-character spacing. Furthermore, when the ruby annotation is composed of characters such as Grouped numerals (cl-24), Unit symbols (cl-25), Western word space (cl-26), or Western characters (cl-27) which have their own individual width, they are placed according to each character’s metrics.
When the ruby annotation is wider than its base text, the part of the annotation that extends beyond the base text must not overhang the characters preceding or following (see [[[#mono-ex-1]]]). Spacing is introduced accordingly between these preceding or following characters and the base characters.
However, in the following cases, where punctuation marks like Full stops (cl-06) have blank space before or after the letter face, ruby annotation characters do overhang the preceding or following characters (see [[[#mono-ex-2]]]). (Here, the difference in the processing of punctuation marks, etc. is that they play an important role as sentence breaks, and there is blank space before and after them. It is preferable to maintain constant spacing for such preceding or following characters, as far as possible, especially because when these blank spaces become large, the meaning of the break may change. Also there are no issues like those described in the note in [[[#the-difficulties-of-ruby-processing]]], therefore, this method can use a different approach to layout on punctuation marks like Full stops (cl-06).)
When the ruby annotation is wider than its base text, and the annotation falls at the start of the line, then the start of the ruby annotation is aligned with the line’s start edge (see [[[#line-start-mono]]]), while if the annotation falls at the end of the line, then the end of the ruby annotation is aligned with the line’s end edge (see [[[#line-end-mono]]]).
This section describes placement rules for group-ruby in terms of two groups of characters. Western characters have proportional width and include characters like Grouped numerals (cl-24), Unit symbols (cl-25), Western word space (cl-26), and Western characters (cl-27). Japanese characters have fixed fullwidth size and includes characters like Hiragana (cl-15), Katakana (cl-16), and Ideographic characters (cl-19) (see also 2.1.2 Kanji, Hiragana and Katakana). Western characters are read as clusters of multiple characters, and it is desirable to avoid adding spacing between characters for justification. The way items are positioned depends on how their respective lengths would compare if they were each laid out without any inter-character spacing. When their respective lengths are the same, both are laid out without inter-character spacing and placed such that their respective centers are aligned in the inline direction (see [[[#group-ruby]]]). For other cases, the placement depends on the following.
In terms of the above-mentioned two-step processing method described in [[[#matters-considered-by-the-placement-rules]]], points (1), (2) and (3) belong to the first step, and (4) and (5) to the second.
When both the ruby annotation and its base text contain Japanese characters, the placement depends on the following:
When their respective lengths are the same, both are laid out without inter-letter spacing and placed such that their respective centers in the inline direction are aligned (see [[[#group-ruby]]]).
When the ruby annotation is less wide than its base text, spacing is inserted between every character in the ruby annotation as well as at the start and the end of the ruby annotation so that it becomes the same width as the base text, then their centers in the inline direction are aligned. The size of the spacing inserted between each of the ruby characters is twice the size of the spacing inserted at the end and at the start (see [[[#group-2]]]).
However, the size of the spacing inserted at the start and the end must be capped at no more than half the size of one base character, and the spacing inserted between each ruby character is enlarged to compensate (see [[[#group-3]]]).
When the ruby annotation is wider than its base text, spacing is inserted between every character in the base text as well as at the start and the end of the base text so that it becomes the same length as the ruby annotation, then their centers in the inline direction are aligned. The size of the spacing inserted between each of the base characters is twice the size of the spacing inserted at the end and at the start (see [[[#group-4]]]).
Where a ruby annotation consists of Japanese characters and its ruby base text consists of Western characters, the placement depends on the following (see [[[#ruby-west]]]):
Where a ruby annotation consists of Western characters and its ruby base text consists of Japanese characters, the placement depends on the following (see [[[#ruby-west]]]):
When the ruby annotation is wider than its base text and extends beyond it, whether and how it hangs over characters preceding or following the base text is handled in the same way as for mono-ruby (see [[[#protruding-group]]]). Also, when the ruby annotation is wider than its base character string and extends beyond it and is located at the start or the end of the line, the resulting layout is also identical to that for mono-ruby.
In the case of group-ruby, the base text and its associated ruby annotation are treated as a unit, so there is no line wrapping opportunity inside either string.
In terms of the above-mentioned two-step processing method described in [[[#matters-considered-by-the-placement-rules]]], points (1), (2) and (3) belong to the first step, and (4) to the second.
With jukugo-ruby, each base text is associated with its own ruby annotation. When the length of all of these ruby annotations laid out without inter-character spacing is less wide than the length of all their corresponding base texts, placement is determined as follows:
When the ruby annotation associated with an individual base text is 1 character long, the ruby annotation and the base text are placed such that their respective centers in the inline direction are aligned (see [[[#jukugo-1]]]).
When the ruby annotation associated with an individual base character is 2 characters long or more, the ruby annotation is laid out without inter-character spacing, and placed such that its center and the center of its base text are aligned in the inline direction (see [[[#jukugo-1]]]).
For simple ruby implementations, if even a single ruby annotation is longer than its corresponding base text when laid out without inter-character spacing, the resulting layout would look identical to group-ruby (see [[[#jukugo-2]]] and [[[#jukugo-3]]]).
With jukugo-ruby, individual base texts and their associated ruby annotations are treated as a unit, and line wrap opportunities are allowed between two base texts. When such a line wrap occurs, if a single base text that is part of the jukugo-ruby is placed alone at the end or at the start of a line, it is laid out identically to mono-ruby; conversely when several base texts that are part of the jukugo are placed together at the end or the start of a line, they are laid out together as has been described in this section about jukugo-ruby (see [[[#wrap-jukugo]]]).
Quite complex methods are required to apply the full rules for placement of double-sided ruby. For simple placement of double-sided ruby, rules can be written for each of the combinations of mono-ruby, group-ruby, and jukugo-ruby for two sides. As we are using two-step processing, consideration of ruby annotations that extend beyond the ruby base text and their relationship with preceding and following characters, or placement at the line head or the line end, are processed in the same way as when the ruby string is annotations on one side only.
When two adjacent rows have double-sided ruby, the configuration of the inter-line spacing could cause an undesirable overlap of two ruby annotations. The following methods could be applied to avoid such cases:
In letterpress printing, the first method was used for cases where the document had a large number of ruby or many reference marks. The second or third method was used for cases where a document has less ruby. In automatic processing used for the Web documents, the third method might be suitable. Using the third method in an area with an integral number of line spaces around it (for example, centering across a two line space) limits the disruption to that line, and maintains the alignment of lines against those in any adjacent column. (See also JLReq "Adjustment of Processing of Realm in Block Direction".)
Double-sided ruby can be classified into five combinations:
[[JISX4051]] provides procedures for handling (1), (2), and (3) (see a note in JLReq). But (3) is actually handled as (2) by first concatenating mono-ruby strings to form a single group-ruby.
We propose to handle (4) as (1) by first converting jukugo-ruby to mono-ruby, and to handle (5) as (2) by first converting jukugo-ruby to group-ruby.
This document, therefore, provides rules for simple placement of double-sided ruby using cases (1) and (2).
Which side the ruby annotations should be placed depends on the specification.
In the combination mono-ruby plus mono-ruby, ruby annotations are set solid, and are placed so that their center aligns with that of the ruby base text (see [[[#double-mono]]]). For other points, follow the rules for placement of mono-ruby described in [[[#placement-of-mono-ruby]]].
When both of the ruby annotations are less wide than the ruby base text, follow the rules for placement of group-ruby described in [[[#placement-of-group-ruby]]]. When the ruby annotation consists of Japanese characters, defined in [[[#placement-of-group-ruby]]], spacing is inserted between every character in the ruby string as well as the start and the end of the ruby string (see [[[#double-group-1]]]).
When one of the ruby annotations is wider than its base text, pick up the ruby annotation with longer length and place that ruby annotation following the rules for placement of group-ruby, as described in [[[#placement-of-group-ruby]]]. When the ruby base text consists of Japanese characters, as defined in [[[#placement-of-group-ruby]]], spacing is inserted between every character in the ruby base text as well as at the start and the end of the ruby base text. Following placement of the ruby base text, place the shorter ruby annotations based on the length of the ruby base text without spacing at the start and the end but with inter-character spacing when the ruby base text is Japanese characters.
When the width of the shorter ruby annotation is longer than its ruby base text with inter-character spacing, the shorter ruby annotation is set solid and is placed so that its center matches that of its base text (see [[[#double-group-2]]]).
When the width of the shorter ruby annotation is shorter than its base text with inter-character spacing, follow the rules for the placement of group-ruby described in [[[#placement-of-group-ruby]]], using the length of the ruby base text with inter-character spacing. When the shorter ruby string consists of Japanese characters, as described in [[[#placement-of-group-ruby]]], spacing is inserted between every character in the ruby annotation as well as at the start and the end of the ruby annotations (see [[[#double-group-3]]]).
For other points, follow the same rules as for the placement of group-ruby described in [[[#placement-of-group-ruby]]].