typeset 0.1.0
縦書き・横書きの日本語組版ライブラリ(JLReq 水準、ラスタ / PDF / SVG)
読み取り中…
検索中…
一致する文字列を見つけられません
glyph_transform.hpp
[詳解]
1#ifndef TYPESET_DL_GLYPH_TRANSFORM_HPP
2#define TYPESET_DL_GLYPH_TRANSFORM_HPP
3
4#include <cmath>
5
6#include "typeset/geom.hpp"
7
15namespace typeset::dl {
16
18inline constexpr float kFakeItalicSkew = -0.25f;
19
31inline Mat2 glyphMatrix(float rotation, float scaleX = 1.0f, float scaleY = 1.0f,
32 float skewX = 0.0f, float fakeScaleX = 1.0f) {
33 Mat2 m;
34 m.xx = fakeScaleX;
35 m.xy = skewX; // y-down 座標では pt.x += skewX * pt.y
36 m.yx = 0.0f;
37 m.yy = 1.0f;
38
39 if (scaleX != 1.0f || scaleY != 1.0f) {
40 Mat2 s;
41 s.xx = scaleX;
42 s.yy = scaleY;
43 m = multiply(s, m);
44 }
45 if (rotation != 0.0f) {
46 // 角度は y-up の反時計回りが正。描画先が y-down なので Y 反転で
47 // 共役を取った形になり、シアー成分の符号が入れ替わる。
48 const float c = std::cos(rotation);
49 const float s = std::sin(rotation);
50 Mat2 r;
51 r.xx = c; r.xy = s;
52 r.yx = -s; r.yy = c;
53 m = multiply(r, m);
54 }
55 return m;
56}
57
59inline Pt fakeBoldWidth(Pt fontSize) { return fontSize / 24.0f; }
60
61} // namespace typeset::dl
62
63#endif // TYPESET_DL_GLYPH_TRANSFORM_HPP
dl — 表示リスト(Display List)
Pt fakeBoldWidth(Pt fontSize)
フェイクボールドのストローク幅(フォントサイズの 1/24)
constexpr float kFakeItalicSkew
フェイクイタリックのシアー係数(Android と同じ -0.25 ≒ 14度)
Mat2 glyphMatrix(float rotation, float scaleX=1.0f, float scaleY=1.0f, float skewX=0.0f, float fakeScaleX=1.0f)
グリフ固有の変形を 1 つの 2x2 へ畳む(ペン原点・y-down)
float Pt
Definition geom.hpp:17
Matrix multiply(const Matrix &a, const Matrix &b)
a を後から適用する合成(結果 = a ∘ b。b で写してから a)
2x2 行列(平行移動なし)。グリフ固有の変形に使う。 x' = xx*x + xy*y y' = yx*x + yy*y
Definition geom.hpp:54
float xx
Definition geom.hpp:55
float xy
Definition geom.hpp:55
float yy
Definition geom.hpp:56
float yx
Definition geom.hpp:56