typeset 0.1.0
縦書き・横書きの日本語組版ライブラリ(JLReq 水準、ラスタ / PDF / SVG)
読み取り中…
検索中…
一致する文字列を見つけられません
typeset 名前空間

geom — 単位と幾何 [詳解]

名前空間

namespace  backend
 backend/pdf_writer — 表示リストを PDF へ
 
namespace  block
 block — ブロック(段落・見出し・罫線・ラベル付き段落・アキ・セクション)
 
namespace  dl
 dl — 表示リスト(Display List)
 
namespace  font
 font — フォント層(glyphware の薄い包み)
 
namespace  image
 image — 画像の読み込みとエンコード
 
namespace  inl
 inl/annotation — 行内に組み込む注記
 
namespace  obj
 obj — 外部生成オブジェクト(数式・グラフ・図など)の差し込み口
 
namespace  page
 page/flow_layouter — Flow をページ列へ流し込む
 
namespace  text
 text/char_class — JLReq の文字クラス
 

クラス

struct  BreakOptions
 
struct  Color
 色(非前乗算 RGBA) [詳解]
 
struct  FontSpec
 フォントの論理指定 [詳解]
 
struct  GradientStop
 グラデーションの停止点 [詳解]
 
struct  LogicalPoint
 論理座標。inline_ は行頭からの送り、block は行の中心線からのずれ (block 正方向は横組みで下、縦組み(rl)で左、縦組み(lr)で右…ではなく、 **縦組みでは常に右を正**とする。richtext の u 軸と同じ。行送りの向きとは独立) [詳解]
 
struct  Mat2
 2x2 行列(平行移動なし)。グリフ固有の変形に使う。 x' = xx*x + xy*y y' = yx*x + yy*y [詳解]
 
struct  Matrix
 2x3 アフィン行列(行優先) x' = xx*x + xy*y + dx y' = yx*x + yy*y + dy [詳解]
 
struct  Paint
 塗り — 単色または線形/放射グラデーション [詳解]
 
struct  ParagraphStyle
 段落スタイル [詳解]
 
struct  Path
 パス(moveTo / lineTo / quadTo / cubicTo / close) [詳解]
 
struct  Point
 
struct  Rect
 
struct  Size
 
struct  SpacingOptions
 
struct  Stroke
 線の描き方 [詳解]
 
struct  TabStop
 
struct  TextDecoration
 下線・打消し線(TextStyle::underline / strikethrough) [詳解]
 
struct  TextLayer
 文字の外観の 1 層(塗り・縁取り・影) [詳解]
 
struct  TextShadow
 影(TextStyle::shadow)。層の一番下に「塗り = color、offset、blur」の 1 層として置く糖衣 [詳解]
 
struct  TextStyle
 文字スタイル [詳解]
 

型定義

using Pt = float
 

列挙型

enum class  PaintKind : uint8_t { Solid , Linear , Radial }
 
enum class  PaintUnits : uint8_t { BoundingBox , UserSpace }
 グラデーションの座標系 [詳解]
 
enum class  StrokeJoin : uint8_t { Miter , Round , Bevel }
 
enum class  StrokeCap : uint8_t { Butt , Round , Square }
 
enum class  EmojiPresentation : uint8_t { Auto , Text , Emoji }
 絵文字の表示形式 [詳解]
 
enum class  KinsokuLevel : uint8_t { Strict , Normal , Loose }
 約物の詰め・和欧間・ぶら下げ [詳解]
 
enum class  LineBreakStrategy : uint8_t { Greedy , KnuthPlass }
 
enum class  WrapMode : uint8_t { Mixed , Char , Word , None }
 折返しの方式 [詳解]
 
enum class  Align : uint8_t { Start , End , Center , Justify }
 
enum class  BlockAlign : uint8_t { Start , Center , End }
 行送り方向の揃え(箱の中での段落の位置。inl::originInBox) [詳解]
 
enum class  TabAlign : uint8_t { Left , Center , Right , Decimal }
 タブストップの揃え [詳解]
 
enum class  Direction : uint8_t { Auto , Ltr , Rtl }
 段落の基底方向(UAX #9)。Auto は最初の強い文字で決める(和文・欧文は LTR) [詳解]
 
enum class  WritingMode : uint8_t { HorizontalTb , VerticalRl , VerticalLr }
 
enum class  TextOrientation : uint8_t { Mixed , Upright , Sideways }
 縦組み中の文字の正立/横倒し(CSS text-orientation 相当) [詳解]
 

関数

Matrix multiply (const Matrix &a, const Matrix &b)
 a を後から適用する合成(結果 = a ∘ b。b で写してから a)
 
Mat2 multiply (const Mat2 &a, const Mat2 &b)
 
Matrix invert (const Matrix &m, bool *ok=nullptr)
 逆行列。特異なら単位行列を返し ok=false
 
std::vector< std::vector< Point > > flattenPath (const Path &path, float tolerance, std::vector< bool > *closedFlags=nullptr)
 曲線を折れ線に平坦化した閉/開多角形列を得る(tolerance は pt)
 
bool isVertical (WritingMode wm)
 
Point toPhysical (WritingMode wm, LogicalPoint p, Point lineOrigin)
 論理座標 → 物理座標
 
LogicalPoint toLogical (WritingMode wm, Point p, Point lineOrigin)
 物理座標 → 論理座標(toPhysical の逆)
 

変数

constexpr Pt kInch = 72.0f
 
constexpr Pt kMm = 72.0f / 25.4f
 
constexpr Pt kCm = kMm * 10.0f
 
constexpr float kSidewaysRotation = -1.5707963267948966f
 横倒しグリフの回転角(ラジアン)
 

詳解

geom — 単位と幾何

writing_mode — 書字方向と論理座標

style — 文字・段落のスタイル

文書内部の長さはすべて pt(1/72 inch)の float。ラスタ backend が dpi/72 を 掛けてピクセルにする。座標はページ左上原点・y-down。

CSS エンジンにはしない。明示フィールドの構造体で、継承は親からのコピー。

行内は「インライン軸(行の進む方向=送り)」と「ブロック軸(行に直交)」の 2 軸で組む。richtext 縦組みの (u, v) をすべての書字方向へ一般化したもの。

横組み inline = +x(右) block = +y(下) 縦組み(rl) inline = +y(下) block = −x(左) ※行は右から左へ進む 縦組み(lr) inline = +y(下) block = +x(右)

ブロック軸の原点は「行の中心線」(縦組みなら列の中心線、横組みなら行の中心線)。 文字の仮想ボディ(em box)の中心をここへ合わせるのが全書字方向共通の規則。

型定義詳解

◆ Pt

using typeset::Pt = typedef float

geom.hpp17 行目に定義があります。

列挙型詳解

◆ PaintKind

enum class typeset::PaintKind : uint8_t
strong
列挙値
Solid 
Linear 
Radial 

geom.hpp143 行目に定義があります。

◆ PaintUnits

enum class typeset::PaintUnits : uint8_t
strong

グラデーションの座標系

  • BoundingBox: 描く対象(GlyphRun なら run 全体、PathItem ならパス)の外接矩形を 0〜1 に正規化した座標
  • UserSpace: ページ座標(pt、y-down)
列挙値
BoundingBox 
UserSpace 

geom.hpp150 行目に定義があります。

◆ StrokeJoin

enum class typeset::StrokeJoin : uint8_t
strong
列挙値
Miter 
Round 
Bevel 

geom.hpp231 行目に定義があります。

◆ StrokeCap

enum class typeset::StrokeCap : uint8_t
strong
列挙値
Butt 
Round 
Square 

geom.hpp232 行目に定義があります。

◆ EmojiPresentation

enum class typeset::EmojiPresentation : uint8_t
strong

絵文字の表示形式

  • Auto: 異体字セレクタ(VS15 = U+FE0E で字形、VS16 = U+FE0F で絵文字)に従い、無ければフォントの解決順のまま
  • Text: モノクロの字形を優先する(カラーフォントは最後に回し、選ばれてもカラーでは描かない)
  • Emoji: カラー絵文字を優先する
列挙値
Auto 
Text 
Emoji 

style.hpp81 行目に定義があります。

◆ KinsokuLevel

enum class typeset::KinsokuLevel : uint8_t
strong

約物の詰め・和欧間・ぶら下げ

禁則の強さ(CSS の line-break 相当)

  • Strict: JLReq 附属書 A のまま(小書きの仮名・長音・繰返し記号・ハイフン類も行頭に置かない)
  • Normal: 小書きの仮名・長音・繰返し記号・ハイフン類は「弱い禁則」(有限のペナルティ。他に切れる所が無ければ行頭に来る)
  • Loose: さらに句読点・終わり括弧・中点・区切り約物も弱い禁則にする(狭い段用)
列挙値
Strict 
Normal 
Loose 

style.hpp177 行目に定義があります。

◆ LineBreakStrategy

enum class typeset::LineBreakStrategy : uint8_t
strong
列挙値
Greedy 

各ブレーク候補で即断。画面のリアルタイム描画向け

KnuthPlass 

段落全体でデメリットを最小化。組版品質が要る用途向け

style.hpp202 行目に定義があります。

◆ WrapMode

enum class typeset::WrapMode : uint8_t
strong

折返しの方式

  • Mixed: 和文は字ごと、欧文は語(UAX #14)で切る(既定)
  • Char: 欧文の語の途中でも切る(CSS word-break: break-all)
  • Word: 和文も語(UAX #14 の機会があり、かつ和字同士でない所)でだけ切る(CSS word-break: keep-all)
  • None: 折り返さない(改行以外で切らない。行長を超えてはみ出す)
列挙値
Mixed 
Char 
Word 
None 

style.hpp214 行目に定義があります。

◆ Align

enum class typeset::Align : uint8_t
strong
列挙値
Start 
End 
Center 
Justify 

style.hpp239 行目に定義があります。

◆ BlockAlign

enum class typeset::BlockAlign : uint8_t
strong

行送り方向の揃え(箱の中での段落の位置。inl::originInBox)

列挙値
Start 
Center 
End 

style.hpp242 行目に定義があります。

◆ TabAlign

enum class typeset::TabAlign : uint8_t
strong

タブストップの揃え

列挙値
Left 
Center 
Right 
Decimal 

style.hpp245 行目に定義があります。

◆ Direction

enum class typeset::Direction : uint8_t
strong

段落の基底方向(UAX #9)。Auto は最初の強い文字で決める(和文・欧文は LTR)

列挙値
Auto 
Ltr 
Rtl 

style.hpp253 行目に定義があります。

◆ WritingMode

enum class typeset::WritingMode : uint8_t
strong
列挙値
HorizontalTb 

横組み

VerticalRl 

縦組み・行は右から左へ(日本語の既定)

VerticalLr 

縦組み・行は左から右へ

writing_mode.hpp21 行目に定義があります。

◆ TextOrientation

enum class typeset::TextOrientation : uint8_t
strong

縦組み中の文字の正立/横倒し(CSS text-orientation 相当)

列挙値
Mixed 

和文は正立、欧文は横倒し(既定)

Upright 

すべて正立

Sideways 

すべて横倒し

writing_mode.hpp32 行目に定義があります。

関数詳解

◆ multiply() [1/2]

Matrix typeset::multiply ( const Matrix a,
const Matrix b 
)

a を後から適用する合成(結果 = a ∘ b。b で写してから a)

参照元 typeset::dl::glyphMatrix().

◆ multiply() [2/2]

Mat2 typeset::multiply ( const Mat2 a,
const Mat2 b 
)

◆ invert()

Matrix typeset::invert ( const Matrix m,
bool *  ok = nullptr 
)

逆行列。特異なら単位行列を返し ok=false

◆ flattenPath()

std::vector< std::vector< Point > > typeset::flattenPath ( const Path path,
float  tolerance,
std::vector< bool > *  closedFlags = nullptr 
)

曲線を折れ線に平坦化した閉/開多角形列を得る(tolerance は pt)

◆ isVertical()

bool typeset::isVertical ( WritingMode  wm)
inline

◆ toPhysical()

Point typeset::toPhysical ( WritingMode  wm,
LogicalPoint  p,
Point  lineOrigin 
)
inline

論理座標 → 物理座標

引数
wm書字方向
p論理座標(inline_ = 行頭からの送り、block = 中心線からのずれ)
lineOrigin行頭の物理位置(行の中心線上の点)

writing_mode.hpp54 行目に定義があります。

参照先 typeset::LogicalPoint::block, HorizontalTb, typeset::LogicalPoint::inline_, typeset::Point::x, typeset::Point::y.

◆ toLogical()

LogicalPoint typeset::toLogical ( WritingMode  wm,
Point  p,
Point  lineOrigin 
)
inline

物理座標 → 論理座標(toPhysical の逆)

writing_mode.hpp63 行目に定義があります。

参照先 HorizontalTb, typeset::Point::x, typeset::Point::y.

変数詳解

◆ kInch

constexpr Pt typeset::kInch = 72.0f
constexpr

geom.hpp19 行目に定義があります。

◆ kMm

constexpr Pt typeset::kMm = 72.0f / 25.4f
constexpr

geom.hpp20 行目に定義があります。

◆ kCm

constexpr Pt typeset::kCm = kMm * 10.0f
constexpr

geom.hpp21 行目に定義があります。

◆ kSidewaysRotation

constexpr float typeset::kSidewaysRotation = -1.5707963267948966f
inlineconstexpr

横倒しグリフの回転角(ラジアン)

角度は数学慣習(y-up)の反時計回りが正。描画先は y-down なので、画面上では 時計回りに 90 度倒れる(欧文の天が右を向く)。

writing_mode.hpp76 行目に定義があります。