typeset 0.1.0
縦書き・横書きの日本語組版ライブラリ(JLReq 水準、ラスタ / PDF / SVG)
読み取り中…
検索中…
一致する文字列を見つけられません
line_item.hpp
[詳解]
1#ifndef TYPESET_INL_LINE_ITEM_HPP
2#define TYPESET_INL_LINE_ITEM_HPP
3
4#include <cstddef>
5#include <cstdint>
6#include <limits>
7#include <vector>
8
11
24namespace typeset::inl {
25
26constexpr float kInfinitePenalty = 10000.0f;
27constexpr float kForcedBreakPenalty = -10000.0f;
28
29enum class ItemType : uint8_t { Box, Glue, Penalty };
30
31struct LineItem {
33
35 Pt width = 0.0f;
36
38 Pt natural = 0.0f;
39 Pt stretch = 0.0f;
40 Pt shrink = 0.0f;
41
42 float penalty = 0.0f;
43
46
49
51 size_t charIndex = 0;
52
54 int level = -1;
55
56 // --- インライン注記 ---
57
63 std::vector<PlacedGlyph> glyphs;
64 bool ownGlyphs = false;
65
67 Pt extentMin = 0.0f;
68 Pt extentMax = 0.0f;
69
71 std::vector<PlacedGlyph> breakGlyphs;
72
73 static constexpr uint32_t kNoCluster = std::numeric_limits<uint32_t>::max();
74
75 static LineItem box(Pt w, uint32_t cluster, size_t charIndex) {
76 LineItem it;
78 it.width = w;
79 it.clusterIndex = cluster;
81 return it;
82 }
83 static LineItem glue(const text::GlueSpec& spec, Pt em, size_t charIndex) {
84 return gluePt(spec.natural * em, spec.stretch * em, spec.shrink * em, charIndex);
85 }
87 LineItem it;
89 it.natural = natural;
90 it.stretch = stretch;
91 it.shrink = shrink;
93 return it;
94 }
95 static LineItem penaltyItem(float cost, Pt width, size_t charIndex) {
96 LineItem it;
98 it.penalty = cost;
99 it.width = width;
100 it.charIndex = charIndex;
101 return it;
102 }
103
104 bool isBox() const { return type == ItemType::Box; }
105 bool isGlue() const { return type == ItemType::Glue; }
106 bool isPenalty() const { return type == ItemType::Penalty; }
108};
109
110} // namespace typeset::inl
111
112#endif // TYPESET_INL_LINE_ITEM_HPP
inl/annotation — 行内に組み込む注記
constexpr float kForcedBreakPenalty
Definition line_item.hpp:27
constexpr float kInfinitePenalty
Definition line_item.hpp:26
float Pt
Definition geom.hpp:17
static LineItem gluePt(Pt natural, Pt stretch, Pt shrink, size_t charIndex)
Definition line_item.hpp:86
std::vector< PlacedGlyph > breakGlyphs
Penalty: そこで行が終わったときに行末へ足すグリフ(ハイフネーションのハイフン)。inline_ は行末からの相対
Definition line_item.hpp:71
static constexpr uint32_t kNoCluster
Definition line_item.hpp:73
uint32_t clusterIndex
Box が指すクラスタ(Box 以外では kNoCluster)
Definition line_item.hpp:48
bool isForcedBreak() const
static LineItem penaltyItem(float cost, Pt width, size_t charIndex)
Definition line_item.hpp:95
static LineItem box(Pt w, uint32_t cluster, size_t charIndex)
Definition line_item.hpp:75
Pt width
Box: ボディ幅/Penalty: ブレークしたときにその位置に現れる幅(ぶら下げは負)
Definition line_item.hpp:35
Pt extentMin
この Box が要求するブロック軸の張り出し(既定の ±0.5em を超える分だけ)
Definition line_item.hpp:67
Pt natural
Glue の伸縮
Definition line_item.hpp:38
std::vector< PlacedGlyph > glyphs
Box に紐づくグリフ列。inline_ は Box の先頭からの相対、block は中心線から。
Definition line_item.hpp:63
static LineItem glue(const text::GlueSpec &spec, Pt em, size_t charIndex)
Definition line_item.hpp:83
int level
UAX #9 の埋め込みレベル(欧文間隔のグルーに付ける。-1 なら未設定で、行の並べ替えでは直前の箱に従う)
Definition line_item.hpp:54
Pt glyphOffset
Box: 仮想ボディを詰めたときのグリフの描画オフセット(始め括弧で負)
Definition line_item.hpp:45
size_t charIndex
元テキストでの位置(UTF-16)
Definition line_item.hpp:51
伸縮するアキ(em 単位)