|
typeset 0.1.0
縦書き・横書きの日本語組版ライブラリ(JLReq 水準、ラスタ / PDF / SVG)
|
inl/annotation — 行内に組み込む注記 [詳解]
クラス | |
| struct | Annotation |
| struct | BreakLine |
| 確定した 1 行 [詳解] | |
| struct | CharBox |
| 組んだあとの 1 文字(クラスタのグリフ 1 つ)の箱。注記のグリフは含めない [詳解] | |
| class | ConstantLineShape |
| 全行同じ長さ [詳解] | |
| struct | FitResult |
| 自動縮小: 行数上限に収まるまで文字サイズ(と linePitch)を段階的に縮めて組み直す [詳解] | |
| struct | HitResult |
| 点 → 文字 [詳解] | |
| class | IndentedLineShape |
| 指定した行だけ行頭を下げる(一字下げ用) [詳解] | |
| struct | InlineRun |
| スタイルの付いたテキスト片。image / object / objectRef が付いていれば行内オブジェクト(text は U+FFFC 1 文字) [詳解] | |
| struct | ItemBuildContext |
| struct | LineBox |
| 確定した 1 行(論理座標) [詳解] | |
| struct | LineItem |
| struct | LineShape |
| 1 行の形(行長と行頭の下げ) [詳解] | |
| class | LineShapeProvider |
| struct | ObjectRef |
| 外部ハンドラで生成するオブジェクトの指定(組版時に obj::ObjectRegistry で解決する) [詳解] | |
| class | OffsetLineShape |
| 行ごとの実際の位置のずれを base に渡す(段落レイアウタが行送りの広がりを反映するのに使う) [詳解] | |
| struct | Paragraph |
| struct | ParagraphFragment |
| class | ParagraphLayouter |
| struct | PlacedGlyph |
| 配置済みグリフ 1 個(論理座標) [詳解] | |
| struct | PlaceholderRect |
| プレースホルダの位置(id と物理矩形)。id 未指定のものは "" [詳解] | |
| struct | ShapeContext |
| struct | ShapedCluster |
| シェイピング結果のクラスタ(組版の最小単位) [詳解] | |
| struct | ShapedText |
| struct | StyleMetrics |
| スタイルごとの、描くときに要るメトリクス(ParagraphFragment::styleMetrics。styles と同じ添字) [詳解] | |
| struct | StyleRun |
| スタイル区間([start, end) は UTF-16 位置) [詳解] | |
| struct | TagLink |
| リンクの範囲 [詳解] | |
| struct | TagMarker |
| タイミング等のマーカー(描かない。ホストが位置を使う) [詳解] | |
| struct | TagParseOptions |
| struct | TagParseResult |
| struct | TagPlaceholder |
<graph> で置いた行内プレースホルダ [詳解] | |
| struct | TextMetrics |
| 1 行計測(折り返さない) [詳解] | |
列挙型 | |
| enum class | AnnotationType : uint8_t { Ruby , TateChuYoko , Emphasis , Warichu , Jidori , Indent , MoveTo } |
| enum class | RubyMode : uint8_t { Group , Mono , Jukugo } |
| enum class | EmphasisMark : uint8_t { Sesame , OpenSesame , Dot , FilledCircle , OpenCircle } |
| enum class | ItemType : uint8_t { Box , Glue , Penalty } |
関数 | |
| char32_t | emphasisMarkCodePoint (EmphasisMark mark) |
| std::vector< LineItem > | buildLineItems (const ShapedText &shaped, const std::vector< Annotation > &annotations, const SpacingOptions &opts, const ItemBuildContext &ctx) |
| アイテム列を組み立てる。末尾には段落終端(無限に伸びる Glue + 強制ブレーク)を付ける | |
| float | annotationSide (WritingMode wm) |
| 注記の付く側(縦組み: +1 = 右、横組み: −1 = 上) | |
| std::vector< BreakLine > | breakLines (const std::vector< LineItem > &items, const LineShapeProvider &shape, const BreakOptions &opts, int firstLineIndex=0) |
| 行分割を実行する | |
| TextStyle | superscriptStyle (TextStyle s) |
| 上付き(脚注記号・指数用): 0.6 倍にして注記側へ 0.6em ずらす | |
| dl::Group | objectGroup (const obj::ObjectResult &ob, const Rect &box, bool sideways) |
| オブジェクトの描画命令を物理矩形 box に置く Group を作る(sideways: 時計回り 90° で横倒し) | |
| Point | lineOrigin (WritingMode wm, Point origin, int lineOffset, Pt linePitch, Pt indent) |
| 行 i の行頭(中心線上の点)の物理位置 | |
| Point | lineOriginAt (WritingMode wm, Point origin, Pt adv, Pt indent) |
| 行送り方向に adv 進んだ行頭 | |
| void | emitParagraph (dl::DisplayList &out, const ParagraphFragment &frag, WritingMode wm, Point origin, int lineOffset=0, size_t maxChars=static_cast< size_t >(-1)) |
| 段落を表示リストへ出す | |
| std::vector< CharBox > | charBoxes (const ParagraphFragment &frag, WritingMode wm, size_t lineIndex) |
| 行 lineIndex の文字の箱(送り方向の順。注記のグリフは含めない。wm は画像の箱の向きに使う) | |
| Point | lineOriginOf (const ParagraphFragment &frag, WritingMode wm, Point origin, size_t lineIndex, int lineOffset=0) |
| 行 lineIndex の行頭(物理)。emitParagraph と同じ origin / lineOffset を渡す | |
| std::vector< Rect > | rectsFor (const ParagraphFragment &frag, WritingMode wm, Point origin, size_t charStart, size_t charEnd, int lineOffset=0) |
| 文字範囲 [charStart, charEnd) を覆う矩形(行ごとに 1 つ。物理座標。縦組みは縦長)。 リンクの当たり判定・選択範囲の描画用。範囲に文字が無い行は出ない | |
| std::vector< PlaceholderRect > | placeholderRects (const ParagraphFragment &frag, WritingMode wm, Point origin, int lineOffset=0) |
| std::optional< HitResult > | hitTest (const ParagraphFragment &frag, WritingMode wm, Point origin, Point p, int lineOffset=0) |
| 行送りの箱の範囲に無い点は nullopt。行の前後の余白は最も近い文字(行頭/行末)に丸める | |
| std::optional< Rect > | caretRect (const ParagraphFragment &frag, WritingMode wm, Point origin, size_t charIndex, int lineOffset=0, Pt thickness=1.0f) |
| キャレット矩形: charIndex の文字の始端(charIndex が行末なら最後の文字の終端)に、行送り方向の em の高さで thickness 幅の矩形。文字が無い(範囲外)なら nullopt。行またぎの位置は前の行の行末側 | |
| Point | originInBox (const ParagraphFragment &frag, WritingMode wm, const Rect &box, BlockAlign blockAlign=BlockAlign::Start, Align align=Align::Start) |
| 箱の中での段落の位置: 行送り方向に blockAlign、行の方向に align(Justify は Start 扱い)で揃えた origin (emitParagraph に渡す 1 行目の行頭)を返す。段落は箱の行長で組んであること | |
| FitResult | fitParagraph (ParagraphLayouter &layouter, const Paragraph ¶, WritingMode wm, const LineShapeProvider &shape, int maxLines, float minScale=0.5f, float step=0.05f) |
| TextMetrics | measureText (font::FontSet &fonts, const std::u16string &text, const TextStyle &style, WritingMode wm=WritingMode::HorizontalTb, TextOrientation orientation=TextOrientation::Mixed) |
| ShapedText | shapeText (const std::u16string &text, const std::vector< StyleRun > &runs, const ShapeContext &ctx) |
| シェイピング実行 | |
| ShapedText | shapeText (const std::u16string &text, const TextStyle &style, font::FontSet &fonts, WritingMode wm, TextOrientation orientation=TextOrientation::Mixed) |
| 単一スタイル版 | |
| Pt | baselineOffset (const glyphware::Face &face, Pt size, WritingMode wm) |
| 横組みのベースラインのブロック位置(中心線から下向き正)/ 縦組み横倒しランのベースラインのブロック位置(中心線から右向き正) | |
| TagParseResult | parseTaggedText (const std::u16string &text, const TagParseOptions &options) |
| タグ付きテキストを段落にする | |
| std::u16string | stripTags (const std::u16string &text) |
| タグを取り除いた本文だけを返す(位置合わせの確認用) | |
変数 | |
| constexpr float | kInfinitePenalty = 10000.0f |
| constexpr float | kForcedBreakPenalty = -10000.0f |
inl/annotation — 行内に組み込む注記
inl/tag_parser — 軽量インラインタグ記法
inl/shaper — Itemizer + HarfBuzz シェイピング
inl/shaped — シェイピング結果(組版層の入力)
inl/paragraph — 段落の組版(入口)
inl/line_item — Box / Glue / Penalty
inl/line_breaker — TeX 型の行分割(Greedy / Knuth–Plass)
inl/item_builder — シェイピング結果 → Box / Glue / Penalty 列
ルビ・縦中横・圏点・割注・字取りを、本文の文字範囲に対する注記として表す。 組版層(item_builder)がこれを解釈して Box / Glue / Penalty 列に落とし込む ので、行分割・約物の詰め・両端揃えと矛盾しない。
範囲は本文の UTF-16 単位で [start, end)。範囲が重なる注記は、種類が違えば 併用できる(ルビと圏点など)が、同じ種類の重なりは未定義。
JLReq の文字クラスとアキ量表を使って、クラスタ列を組版アイテム列へ変換する。
行長は 1 つの値ではなく LineShapeProvider から**行ごとに**取る(TeX の \parshape)。回り込み・ラベル付き段落・将来の吹き出しはこれで表現する。 行が確定すると調整比 ratio が決まり、追い込み・追い出し・両端揃えが 「グルーの伸縮でどう行長に合わせるか」の 1 つの問題に統一される。
組版対象を TeX と同じ 3 種のアイテム列で表す。寸法は pt。
合法なブレーク点は TeX と同じ規則で決まる:
禁則は「Glue の直前に Penalty(kInfinitePenalty) を挟む」ことで表す。 ぶら下げは「幅が負の Penalty」(ブレーク時に行長から取り除かれる)。
Paragraph(InlineRun 列+注記) → shapeText(Itemizer + HarfBuzz) → buildLineItems(JLReq のアキ・禁則・注記) → breakLines(Greedy / Knuth–Plass、行ごとの行長) → LineBox(論理座標のグリフ列) → emitParagraph(書字方向で物理化して表示リストへ)
座標はすべて論理座標(writing_mode.hpp): inline_ … 行頭からの送り block … 行の中心線からのずれ(横組みは下が正、縦組みは右が正)
スタイル境界・フォントフォールバック(文字カバレッジ)・正立/横倒しで ランに分け、各ランを HarfBuzz で組む。
ブロック軸の位置は「em box の中心=行の中心線」の規則で決める(設計.md 2.6)。 横組みのベースラインは第一候補フォントの ascender/descender から求め、 フォールバック先のフォントも同じベースラインに乗せる。
richtext(krkr_richtext)のタグ記法を読んで inl::Paragraph(run の列+注記)にする。 ゲーム側のテキストをそのまま持ってこられるようにするための入口で、組版そのものには関わらない。
対応するタグ(richtext と同じ名前・属性):
文字スタイル <font size= weight= face= spacing= width= height= italic= language=> サイズ(pt)・ウェイト・family・字間(em)・平体/長体(倍率)・斜体・言語 <b> <strong> / <i> <em> 太字 / 斜体 <u> / <s> <strike> <del> 下線 / 打消し線 <sup> / <sub> 上付き / 下付き <color value="#rrggbb"> または <color r= g= b= a=> 文字色 <outline color= width= [add]> 縁取り(add で層を重ねる = 二重縁取り) <shadow color= x= y= [blur=] [add]> 影(blur は typeset の拡張) <style name="..."> 名前付きスタイル(TagParseOptions::namedStyles)
注記(typeset の拡張。richtext の <ruby> は同じ) <ruby text="かんじ">漢字</ruby> ルビ(mode= group|mono|jukugo、offset=) <emphasis mark= [opposite]> / <tcy> / <warichu text=> / <jidori em=>
そのほか <br> / <sp width=n> 改行 / 空白 <link name="...">…</link> リンク範囲(結果の links に文字範囲で返る) <graph name= width= height=> 行内プレースホルダ(描かない箱。B10) <start> <delay> <wait> <sync> <keywait> マーカー(結果の markers に位置で返る。B11) <eval name= alt=> 置換(TagParseOptions::evaluate で文字列を返す)
実体参照は < > & " ' と数値参照 &#nnn; &#xhhh;。 < で始まってもタグとして読めないもの(1 < 2 など)はそのままの文字として扱う。
|
strong |
annotation.hpp の 22 行目に定義があります。
|
strong |
annotation.hpp の 32 行目に定義があります。
|
strong |
| 列挙値 | |
|---|---|
| Sesame | ゴマ点 U+FE45 |
| OpenSesame | 白ゴマ点 U+FE46 |
| Dot | 中点 U+30FB |
| FilledCircle | ● U+25CF |
| OpenCircle | ○ U+25CB |
annotation.hpp の 41 行目に定義があります。
|
strong |
| 列挙値 | |
|---|---|
| Box | |
| Glue | |
| Penalty | |
line_item.hpp の 29 行目に定義があります。
| char32_t typeset::inl::emphasisMarkCodePoint | ( | EmphasisMark | mark | ) |
| std::vector< LineItem > typeset::inl::buildLineItems | ( | const ShapedText & | shaped, |
| const std::vector< Annotation > & | annotations, | ||
| const SpacingOptions & | opts, | ||
| const ItemBuildContext & | ctx | ||
| ) |
アイテム列を組み立てる。末尾には段落終端(無限に伸びる Glue + 強制ブレーク)を付ける
|
inline |
| std::vector< BreakLine > typeset::inl::breakLines | ( | const std::vector< LineItem > & | items, |
| const LineShapeProvider & | shape, | ||
| const BreakOptions & | opts, | ||
| int | firstLineIndex = 0 |
||
| ) |
行分割を実行する
| items | 組版アイテム列(末尾に段落終端が付いていること) |
| shape | 行ごとの行長 |
| firstLineIndex | 最初の行の行番号 |
上付き(脚注記号・指数用): 0.6 倍にして注記側へ 0.6em ずらす
paragraph.hpp の 123 行目に定義があります。
参照先 typeset::TextStyle::baselineShift, typeset::TextStyle::size.
| dl::Group typeset::inl::objectGroup | ( | const obj::ObjectResult & | ob, |
| const Rect & | box, | ||
| bool | sideways | ||
| ) |
オブジェクトの描画命令を物理矩形 box に置く Group を作る(sideways: 時計回り 90° で横倒し)
| Point typeset::inl::lineOrigin | ( | WritingMode | wm, |
| Point | origin, | ||
| int | lineOffset, | ||
| Pt | linePitch, | ||
| Pt | indent | ||
| ) |
行 i の行頭(中心線上の点)の物理位置
| origin | 1 行目の行頭。横組みでは (左端, 1 行目の中心線 y)、 縦組みでは (1 列目の中心線 x, 上端) |
| Point typeset::inl::lineOriginAt | ( | WritingMode | wm, |
| Point | origin, | ||
| Pt | adv, | ||
| Pt | indent | ||
| ) |
行送り方向に adv 進んだ行頭
| void typeset::inl::emitParagraph | ( | dl::DisplayList & | out, |
| const ParagraphFragment & | frag, | ||
| WritingMode | wm, | ||
| Point | origin, | ||
| int | lineOffset = 0, |
||
| size_t | maxChars = static_cast< size_t >(-1) |
||
| ) |
段落を表示リストへ出す
| origin | 1 行目の行頭(lineOrigin 参照) |
| lineOffset | fragment の 0 行目に対応する行番号(続きを別の位置から描くとき) |
| maxChars | 元テキストのこの位置(UTF-16)より前の文字だけ描く(段階表示。注記は親文字に従う)。 組版はやり直さないので、全文で組んだ行分割のまま途中まで出る |
| std::vector< CharBox > typeset::inl::charBoxes | ( | const ParagraphFragment & | frag, |
| WritingMode | wm, | ||
| size_t | lineIndex | ||
| ) |
行 lineIndex の文字の箱(送り方向の順。注記のグリフは含めない。wm は画像の箱の向きに使う)
| Point typeset::inl::lineOriginOf | ( | const ParagraphFragment & | frag, |
| WritingMode | wm, | ||
| Point | origin, | ||
| size_t | lineIndex, | ||
| int | lineOffset = 0 |
||
| ) |
行 lineIndex の行頭(物理)。emitParagraph と同じ origin / lineOffset を渡す
| std::vector< Rect > typeset::inl::rectsFor | ( | const ParagraphFragment & | frag, |
| WritingMode | wm, | ||
| Point | origin, | ||
| size_t | charStart, | ||
| size_t | charEnd, | ||
| int | lineOffset = 0 |
||
| ) |
文字範囲 [charStart, charEnd) を覆う矩形(行ごとに 1 つ。物理座標。縦組みは縦長)。 リンクの当たり判定・選択範囲の描画用。範囲に文字が無い行は出ない
| std::vector< PlaceholderRect > typeset::inl::placeholderRects | ( | const ParagraphFragment & | frag, |
| WritingMode | wm, | ||
| Point | origin, | ||
| int | lineOffset = 0 |
||
| ) |
| std::optional< HitResult > typeset::inl::hitTest | ( | const ParagraphFragment & | frag, |
| WritingMode | wm, | ||
| Point | origin, | ||
| Point | p, | ||
| int | lineOffset = 0 |
||
| ) |
行送りの箱の範囲に無い点は nullopt。行の前後の余白は最も近い文字(行頭/行末)に丸める
| std::optional< Rect > typeset::inl::caretRect | ( | const ParagraphFragment & | frag, |
| WritingMode | wm, | ||
| Point | origin, | ||
| size_t | charIndex, | ||
| int | lineOffset = 0, |
||
| Pt | thickness = 1.0f |
||
| ) |
キャレット矩形: charIndex の文字の始端(charIndex が行末なら最後の文字の終端)に、行送り方向の em の高さで thickness 幅の矩形。文字が無い(範囲外)なら nullopt。行またぎの位置は前の行の行末側
| Point typeset::inl::originInBox | ( | const ParagraphFragment & | frag, |
| WritingMode | wm, | ||
| const Rect & | box, | ||
| BlockAlign | blockAlign = BlockAlign::Start, |
||
| Align | align = Align::Start |
||
| ) |
箱の中での段落の位置: 行送り方向に blockAlign、行の方向に align(Justify は Start 扱い)で揃えた origin (emitParagraph に渡す 1 行目の行頭)を返す。段落は箱の行長で組んであること
| FitResult typeset::inl::fitParagraph | ( | ParagraphLayouter & | layouter, |
| const Paragraph & | para, | ||
| WritingMode | wm, | ||
| const LineShapeProvider & | shape, | ||
| int | maxLines, | ||
| float | minScale = 0.5f, |
||
| float | step = 0.05f |
||
| ) |
| TextMetrics typeset::inl::measureText | ( | font::FontSet & | fonts, |
| const std::u16string & | text, | ||
| const TextStyle & | style, | ||
| WritingMode | wm = WritingMode::HorizontalTb, |
||
| TextOrientation | orientation = TextOrientation::Mixed |
||
| ) |
| ShapedText typeset::inl::shapeText | ( | const std::u16string & | text, |
| const std::vector< StyleRun > & | runs, | ||
| const ShapeContext & | ctx | ||
| ) |
シェイピング実行
| text | 1 段落分(改行は含めない) |
| runs | スタイル区間(text 全体を覆うこと) |
| ShapedText typeset::inl::shapeText | ( | const std::u16string & | text, |
| const TextStyle & | style, | ||
| font::FontSet & | fonts, | ||
| WritingMode | wm, | ||
| TextOrientation | orientation = TextOrientation::Mixed |
||
| ) |
単一スタイル版
| Pt typeset::inl::baselineOffset | ( | const glyphware::Face & | face, |
| Pt | size, | ||
| WritingMode | wm | ||
| ) |
横組みのベースラインのブロック位置(中心線から下向き正)/ 縦組み横倒しランのベースラインのブロック位置(中心線から右向き正)
| TagParseResult typeset::inl::parseTaggedText | ( | const std::u16string & | text, |
| const TagParseOptions & | options | ||
| ) |
タグ付きテキストを段落にする
| std::u16string typeset::inl::stripTags | ( | const std::u16string & | text | ) |
タグを取り除いた本文だけを返す(位置合わせの確認用)
|
constexpr |
line_item.hpp の 26 行目に定義があります。
|
constexpr |
line_item.hpp の 27 行目に定義があります。