Annotation of nono/wx/fontmanager.h, revision 1.1.1.2

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 のグリフを返す
                     52:        const uint8 *AsciiGlyph(uint8, uint attr) const;
                     53: 
                     54:        // 漢字のグリフを返す
                     55:        std::vector<uint8> KanjiGlyph(uint16, uint attr) const;
                     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:        std::vector<uint8> bold_glyph {};
                     74: 
                     75:        // 可変のグリフ
                     76:        bool glyph_5c {};
                     77:        bool glyph_7c {};
                     78:        bool glyph_7e {};
                     79: 
                     80:        // フォント種別一覧
                     81:        static const std::array<wxSize, FontId::Max> fontinfo;
                     82: };
                     83: 
                     84: extern FontManager *gFontManager;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.