typeset 0.1.0
縦書き・横書きの日本語組版ライブラリ(JLReq 水準、ラスタ / PDF / SVG)
読み取り中…
検索中…
一致する文字列を見つけられません
page.hpp
[詳解]
1#ifndef TYPESET_PAGE_PAGE_HPP
2#define TYPESET_PAGE_PAGE_HPP
3
4#include <map>
5#include <optional>
6#include <string>
7#include <vector>
8
10#include "typeset/geom.hpp"
13
17namespace typeset::page {
18
19namespace paper {
20constexpr Size A4{210.0f * kMm, 297.0f * kMm};
21constexpr Size A5{148.0f * kMm, 210.0f * kMm};
22constexpr Size B5{182.0f * kMm, 257.0f * kMm};
23constexpr Size B6{128.0f * kMm, 182.0f * kMm};
24constexpr Size Bunko{105.0f * kMm, 148.0f * kMm};
25constexpr Size Shinsho{103.0f * kMm, 182.0f * kMm};
26inline Size landscape(Size s) { return Size{s.h, s.w}; }
27} // namespace paper
28
29struct Margins {
30 Pt top = 20.0f * kMm;
31 Pt bottom = 20.0f * kMm;
32 Pt inner = 20.0f * kMm;
33 Pt outer = 20.0f * kMm;
34};
35
45 Pt offset = 0.0f;
47 bool mirrorOnEven = false;
48};
49
50struct PageMaster {
54 int columns = 1;
55 Pt columnGap = 0.0f;
56 std::optional<RunningText> header;
57 std::optional<RunningText> footer;
59 bool duplex = false;
60
62 Rect bodyRect(int pageNumber) const;
63
65 std::vector<Rect> columnRects(const Rect& body, int cols, Pt gap) const;
66};
67
72
76struct Region {
79 Pt used = 0.0f;
81 std::vector<Rect> exclusions;
83 Pt reserved = 0.0f;
84 std::vector<inl::Paragraph> footnotes;
85
87 Pt lineLength() const { return isVertical(writingMode) ? area.h : area.w; }
89 Pt blockExtent() const { return isVertical(writingMode) ? area.w : area.h; }
90 Pt remaining() const { return blockExtent() - used - reserved; }
91 bool fresh() const { return used <= 0.0f; }
92
94 Point lineOrigin(Pt blockOffset, Pt pitch, Pt inlineOffset = 0.0f) const;
95
101 Rect toRect(Pt inline0, Pt inline1, Pt block0, Pt block1) const;
102
106 void freeInlineRange(Pt block0, Pt block1, Pt& start, Pt& end) const;
107};
108
113public:
114 RegionLineShape(const Region& region, Pt startBlock, Pt pitch, Pt baseIndent = 0.0f)
115 : region_(region), startBlock_(startBlock), pitch_(pitch), baseIndent_(baseIndent) {}
116 inl::LineShape at(int lineIndex) const override { return at(lineIndex, 0.0f); }
117 inl::LineShape at(int lineIndex, Pt extraBlock) const override;
118private:
119 const Region& region_;
120 Pt startBlock_;
121 Pt pitch_;
122 Pt baseIndent_;
123};
124
128struct Page {
129 int number = 1;
131};
132
133} // namespace typeset::page
134
135#endif // TYPESET_PAGE_PAGE_HPP
段の排除領域を避ける行の形(回り込み)。行 i は startBlock + i × pitch の帯
Definition page.hpp:112
RegionLineShape(const Region &region, Pt startBlock, Pt pitch, Pt baseIndent=0.0f)
Definition page.hpp:114
inl::LineShape at(int lineIndex) const override
lineIndex 行目の形(段落の先頭を 0 とは限らない。呼び出し側が firstLineIndex を渡す)
Definition page.hpp:116
inl::LineShape at(int lineIndex, Pt extraBlock) const override
行送りが広がった行の後ろでの形。extraBlock は「行番号 × 行送り」に対して実際の行位置が ずれている量(前の行までの追加の送り)。排除領域を見る実装だけが使う。既定は at(lineInde...
constexpr Size A4
Definition page.hpp:20
constexpr Size Bunko
文庫(A6)
Definition page.hpp:24
constexpr Size Shinsho
新書
Definition page.hpp:25
constexpr Size B5
Definition page.hpp:22
constexpr Size A5
Definition page.hpp:21
constexpr Size B6
Definition page.hpp:23
Size landscape(Size s)
Definition page.hpp:26
page/flow_layouter — Flow をページ列へ流し込む
float Pt
Definition geom.hpp:17
bool isVertical(WritingMode wm)
constexpr Pt kMm
Definition geom.hpp:20
@ HorizontalTb
横組み
@ VerticalRl
縦組み・行は右から左へ(日本語の既定)
1 ページ分の表示リスト
1 行の形(行長と行頭の下げ)
Pt outer
小口側
Definition page.hpp:33
Pt inner
ノド側(綴じ側)
Definition page.hpp:32
std::optional< RunningText > footer
Definition page.hpp:57
WritingMode writingMode
Definition page.hpp:53
std::optional< RunningText > header
Definition page.hpp:56
std::vector< Rect > columnRects(const Rect &body, int cols, Pt gap) const
版面を段に分ける(縦組みは上下、横組みは左右)
Rect bodyRect(int pageNumber) const
版面(pageNumber は 1 始まり。duplex のとき偶奇で inner/outer が入れ替わる)
bool duplex
見開きで内・外の余白を左右ページで入れ替える
Definition page.hpp:59
出来上がったページ
Definition page.hpp:128
dl::DisplayList dl
Definition page.hpp:130
段 — 流し込み先
Definition page.hpp:76
Pt lineLength() const
行の長さ(縦組みなら段の高さ、横組みなら幅)
Definition page.hpp:87
Pt reserved
段末に確保した量(脚注)と、段末に置く脚注(FlowLayouter がページを閉じるときに描く)
Definition page.hpp:83
Pt used
行送り方向に使った量
Definition page.hpp:79
std::vector< inl::Paragraph > footnotes
Definition page.hpp:84
Rect toRect(Pt inline0, Pt inline1, Pt block0, Pt block1) const
論理矩形 → 物理矩形
bool fresh() const
Definition page.hpp:91
WritingMode writingMode
Definition page.hpp:78
Point lineOrigin(Pt blockOffset, Pt pitch, Pt inlineOffset=0.0f) const
used + offset の位置に始まる、行送り pitch の 1 行目の行頭(中心線上の点)
void freeInlineRange(Pt block0, Pt block1, Pt &start, Pt &end) const
行送り方向 [block0, block1) の帯で、排除領域を避けて使える行の方向の最大区間
Pt remaining() const
Definition page.hpp:90
Pt blockExtent() const
行送り方向の全長
Definition page.hpp:89
std::vector< Rect > exclusions
回り込みの排除領域(ページ座標)。段が変わると消える
Definition page.hpp:81
柱・ノンブル(横組みで版面の上/下に置く。縦組みの本でも横に置くのが慣例)
Definition page.hpp:42
inl::Paragraph para
Definition page.hpp:43
bool mirrorOnEven
見開き(duplex)で偶数ページの揃えを左右反転する(柱・ノンブルを小口側に置く)
Definition page.hpp:47
Pt offset
版面の端から行の中心線までの距離(上の柱は版面上端から上へ、下は下端から下へ)
Definition page.hpp:45