|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2021 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // フォント管理
9: //
10:
11: #pragma once
12:
13: #include "wxnono.h"
14: #include <array>
15: #include <vector>
16:
17: // フォント種別というかフォントサイズ。
18: // 配列のインデックスとして使うので有効な値を 0 から列挙する。
19: enum FontId {
20: None = -1,
21: _6x12 = 0,
22: _8x16,
1.1.1.2 root 23: _12x24,
1.1 root 24: Max,
25: };
26: #define FONT_6x12 wxSize(6, 12)
27: #define FONT_8x16 wxSize(8, 16)
1.1.1.2 root 28: #define FONT_12x24 wxSize(12, 24)
1.1 root 29:
30: // フォント管理
31: class FontManager
32: {
33: public:
34: FontManager();
35: ~FontManager();
36:
37: // フォントを変更(設定)
38: void SetFont(FontId);
39:
40: // 現在のフォント ID を取得
41: FontId GetFontId() const { return fontid; }
42:
43: // グリフを切り替える。
44: // 0x5c は false: 円記号 true: バックスラッシュ
45: // 0x7c は false: パイプ記号 true: パイプ記号(破線)
46: // 0x7e は false: オーバーライン true: チルダ
47: void SetGlyph5C(bool value) { glyph_5c = value; }
48: void SetGlyph7C(bool value) { glyph_7c = value; }
49: void SetGlyph7E(bool value) { glyph_7e = value; }
50:
51: // ASCII のグリフを返す
1.1.1.3 ! root 52: const uint8 *AsciiGlyph(uint8) const;
1.1 root 53:
54: // 漢字のグリフを返す
1.1.1.3 ! root 55: const uint8 *KanjiGlyph(uint16) const;
1.1 root 56:
57: int GetFontWidth() const { return font_width; }
58: int GetFontHeight() const { return font_height; }
59:
60: private:
61: // フォント種別(指定値)
62: // この値を元に各コントロールに指示を出す
63: FontId fontid {};
64:
65: // フォントの諸元
66: int font_width {}; // 幅 (ピクセル)
67: int font_height {}; // 高さ (ピクセル)
68: int font_stride {}; // 1行のバイト数
69: int font_bytes {}; // 1フォントのバイト数
70:
71: // グリフデータ
72: std::vector<uint8> ascii_glyph {};
73:
74: // 可変のグリフ
75: bool glyph_5c {};
76: bool glyph_7c {};
77: bool glyph_7e {};
78:
79: // フォント種別一覧
80: static const std::array<wxSize, FontId::Max> fontinfo;
81: };
82:
83: extern FontManager *gFontManager;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.