typeset 0.1.0
縦書き・横書きの日本語組版ライブラリ(JLReq 水準、ラスタ / PDF / SVG)
読み取り中…
検索中…
一致する文字列を見つけられません
object.hpp
[詳解]
1#ifndef TYPESET_OBJ_OBJECT_HPP
2#define TYPESET_OBJ_OBJECT_HPP
3
4#include <functional>
5#include <map>
6#include <memory>
7#include <string>
8#include <vector>
9
10#include <glyphware/Face.h>
11
14
31namespace typeset::obj {
32
34 std::string handler;
35 std::u16string source;
36 std::map<std::string, std::string> params;
37 Pt maxInline = 0.0f;
38 Pt maxBlock = 0.0f;
39 Pt fontSize = 10.0f;
41 bool inlineContext = false;
42};
43
46 Pt baseline = 0.0f;
47 bool hasBaseline = false;
48 std::vector<dl::Item> items;
49 std::vector<std::shared_ptr<glyphware::Face>> fonts;
50 std::string error;
51
52 bool ok() const { return error.empty() && size.w > 0.0f && size.h > 0.0f; }
53};
54
55using ObjectHandler = std::function<ObjectResult(const ObjectRequest&)>;
56
58public:
61
63 void add(const std::string& name, ObjectHandler handler);
64
69 void addCommand(const std::string& name, const std::string& commandLine,
70 const std::string& workDir = std::string());
71
72 bool has(const std::string& name) const;
73
75 std::shared_ptr<const ObjectResult> render(const ObjectRequest& req);
76
77 void clearCache();
78 size_t cacheSize() const;
79
81 const std::vector<std::string>& errors() const { return errors_; }
82
83private:
84 struct Impl;
85 std::unique_ptr<Impl> impl_;
86 std::vector<std::string> errors_;
87};
88
90std::string requestToJson(const ObjectRequest& req);
91
93ObjectResult makeResult(Size size, Pt baseline, std::vector<dl::Item> items);
94
95} // namespace typeset::obj
96
97#endif // TYPESET_OBJ_OBJECT_HPP
std::shared_ptr< const ObjectResult > render(const ObjectRequest &req)
ハンドラを呼ぶ(キャッシュあり)。未登録なら error 付きの結果
bool has(const std::string &name) const
void add(const std::string &name, ObjectHandler handler)
関数ハンドラを登録する
void addCommand(const std::string &name, const std::string &commandLine, const std::string &workDir=std::string())
外部コマンドを登録する。commandLine <request.json> を実行し、標準出力の SVG を読む
const std::vector< std::string > & errors() const
直近のエラー(未登録・失敗)
Definition object.hpp:81
obj — 外部生成オブジェクト(数式・グラフ・図など)の差し込み口
Definition object.hpp:31
ObjectResult makeResult(Size size, Pt baseline, std::vector< dl::Item > items)
表示リスト要素を ObjectResult に詰める補助
std::function< ObjectResult(const ObjectRequest &)> ObjectHandler
Definition object.hpp:55
std::string requestToJson(const ObjectRequest &req)
要求を JSON にする(外部コマンドの入力。UTF-8)
float Pt
Definition geom.hpp:17
@ HorizontalTb
横組み
bool inlineContext
行内(true)か別行立て(false)か
Definition object.hpp:41
std::map< std::string, std::string > params
Definition object.hpp:36
std::u16string source
Definition object.hpp:35
Pt maxInline
置ける行方向の最大(段の幅など。0 = 制限なし)
Definition object.hpp:37
Pt maxBlock
行送り方向の最大(0 = 制限なし)
Definition object.hpp:38
Pt fontSize
周囲の本文のサイズ
Definition object.hpp:39
Size size
箱の大きさ(pt)
Definition object.hpp:45
std::vector< std::shared_ptr< glyphware::Face > > fonts
items 内の GlyphRun が使う face(寿命保持)
Definition object.hpp:49
std::vector< dl::Item > items
オブジェクト座標系(左上原点、y-down、pt)
Definition object.hpp:48
std::string error
空なら成功
Definition object.hpp:50
Pt baseline
上端からベースラインまで(行内で本文のベースラインに揃える。0 なら中心揃え)
Definition object.hpp:46