typeset 0.1.0
縦書き・横書きの日本語組版ライブラリ(JLReq 水準、ラスタ / PDF / SVG)
読み取り中…
検索中…
一致する文字列を見つけられません
annotation.hpp
[詳解]
1#ifndef TYPESET_INL_ANNOTATION_HPP
2#define TYPESET_INL_ANNOTATION_HPP
3
4#include <cstddef>
5#include <cstdint>
6#include <string>
7
8#include "typeset/geom.hpp"
9
20namespace typeset::inl {
21
22enum class AnnotationType : uint8_t {
23 Ruby,
25 Emphasis,
26 Warichu,
27 Jidori,
28 Indent,
29 MoveTo,
30};
31
32enum class RubyMode : uint8_t {
33 Group,
34 Mono,
38 Jukugo,
39};
40
41enum class EmphasisMark : uint8_t {
42 Sesame,
44 Dot,
47};
48
50
51struct Annotation {
53 size_t start = 0;
54 size_t end = 0;
55 std::u16string text;
57 float scale = 0.5f;
59 bool oppositeSide = false;
60 float jidoriEm = 0.0f;
61 float offset = 0.0f;
62 float indentEm = 0.0f;
63 Pt position = 0.0f;
64
66 static Annotation indent(size_t start, size_t end, float indentEm) {
67 Annotation a;
69 a.start = start;
70 a.end = end;
72 return a;
73 }
75 static Annotation moveTo(size_t start, Pt position) {
76 Annotation a;
78 a.start = start;
79 a.end = start + 1;
81 return a;
82 }
83
84 static Annotation ruby(size_t start, size_t end, std::u16string text,
85 RubyMode mode = RubyMode::Group, float scale = 0.5f) {
86 Annotation a;
88 a.start = start; a.end = end;
89 a.text = std::move(text);
90 a.rubyMode = mode;
91 a.scale = scale;
92 return a;
93 }
94 static Annotation tateChuYoko(size_t start, size_t end) {
95 Annotation a;
97 a.start = start; a.end = end;
98 return a;
99 }
100 static Annotation emphasis(size_t start, size_t end,
102 bool oppositeSide = false) {
103 Annotation a;
105 a.start = start; a.end = end;
106 a.mark = mark;
107 a.scale = scale;
109 return a;
110 }
111 static Annotation warichu(size_t start, size_t end, std::u16string text, float scale = 0.5f) {
112 Annotation a;
114 a.start = start; a.end = end;
115 a.text = std::move(text);
116 a.scale = scale;
117 return a;
118 }
119 static Annotation jidori(size_t start, size_t end, float em) {
120 Annotation a;
122 a.start = start; a.end = end;
123 a.jidoriEm = em;
124 return a;
125 }
126};
127
128} // namespace typeset::inl
129
130#endif // TYPESET_INL_ANNOTATION_HPP
inl/annotation — 行内に組み込む注記
@ Emphasis
圏点(縦組みでは親文字の右、横組みでは上)
@ Indent
途中からの字下げ: 行頭が [start, end) にある行を indentEm だけ下げる(KAG3 [indent])
@ Warichu
割注(行内に 2 行の子ブロックを組む)
@ Jidori
字取り(指定 em 数へ均等割り付け)
@ Ruby
ルビ(振り仮名)
@ MoveTo
行内の絶対位置: start の文字を行頭から position(pt)の位置から始める(KAG3 [locate])
@ TateChuYoko
縦中横(半角数字等を 1em 角に正立で収める。横組みでは無視)
@ Group
グループルビ。親文字列全体に 1 つのルビを中付きで配置する
@ Jukugo
熟語ルビ。text を | で区切って親文字 1 文字ずつに対応させるが、はみ出す部分は 熟語内の隣の親文字に掛ける(JLReq 3.3.8)。全部が親に収まればモノルビと同じ、 熟語全体でも収まらなけ...
@ Mono
モノルビ。text を | で区切って親文字 1 文字ずつに対応させる
@ OpenSesame
白ゴマ点 U+FE46
@ Sesame
ゴマ点 U+FE45
char32_t emphasisMarkCodePoint(EmphasisMark mark)
float Pt
Definition geom.hpp:17
static Annotation warichu(size_t start, size_t end, std::u16string text, float scale=0.5f)
float jidoriEm
字取りの長さ(em)
float offset
ルビ・圏点と親文字の間隔(親文字の em)。既定はベタ付け
float scale
ルビ・割注・圏点の文字サイズ倍率
static Annotation moveTo(size_t start, Pt position)
行内の絶対位置。start の文字を行頭から position(pt)から始める(手前なら空きを入れ、既に超えていれば何もしない)
static Annotation emphasis(size_t start, size_t end, EmphasisMark mark=EmphasisMark::Sesame, float scale=0.5f, bool oppositeSide=false)
static Annotation ruby(size_t start, size_t end, std::u16string text, RubyMode mode=RubyMode::Group, float scale=0.5f)
bool oppositeSide
圏点を注記側の反対(縦組み: 左、横組み: 下)に付ける
static Annotation indent(size_t start, size_t end, float indentEm)
途中からの字下げ。行頭が [start, end) にある行を indentEm 下げる(end は npos で段落末まで)
Pt position
MoveTo の位置(pt)
float indentEm
Indent の字下げ(em)
std::u16string text
ルビ文字列 / 割注の内容
static Annotation jidori(size_t start, size_t end, float em)
static Annotation tateChuYoko(size_t start, size_t end)