--- nono/wx/fontmanager.cpp 2026/04/29 17:05:12 1.1.1.2 +++ nono/wx/fontmanager.cpp 2026/04/29 17:05:31 1.1.1.6 @@ -35,7 +35,7 @@ FontManager::SetFont(FontId fontid_) fontid = fontid_; // フォントデータを更新。 - // 6x12, 8x16 半角は X68030 CGROM にあるのでそれを使う。 + // 6x12, 8x16, 12x24 半角は X68030 CGROM にあるのでそれを使う。 const uint8 *base; switch (fontid) { case FontId::_6x12: @@ -44,6 +44,9 @@ FontManager::SetFont(FontId fontid_) case FontId::_8x16: base = Builtin::CGROM8x16(); break; + case FontId::_12x24: + base = Builtin::CGROM12x24(); + break; default: PANIC("fontid=%d", fontid); } @@ -61,7 +64,6 @@ FontManager::SetFont(FontId fontid_) // 制御文字領域を外字として使う。 ascii_glyph.resize(256 * font_bytes); - bold_glyph.resize(256 * font_bytes); // CGROM に収録されている文字のうち半角ひらがななど使わないものもあるが // 避けるのも手間なので気にせずデータを作っておく。 @@ -82,33 +84,22 @@ FontManager::SetFont(FontId fontid_) case FontId::_8x16: ptr = (const char *)pchar.data16; break; + case FontId::_12x24: + ptr = (const char *)pchar.data24; + break; default: - __unreachable(); + PANIC("corrupted fontid=%d", (int)fontid); } int idx = pchar.code * font_bytes; memcpy(&ascii_glyph[idx], ptr, font_bytes); } - - // 続いてボールドに加工 - for (int i = 0; i < bold_glyph.size(); i++) { - bold_glyph[i] = ascii_glyph[i] | (ascii_glyph[i] >> 1); - } } // ASCII のグリフを返す const uint8 * -FontManager::AsciiGlyph(uint8 code, uint attr) const +FontManager::AsciiGlyph(uint8 code) const { - const std::vector *glyph; - - // ボールドかどうかでテーブルが別 - if ((attr & TA::Em)) { - glyph = &bold_glyph; - } else { - glyph = &ascii_glyph; - } - // 変更可能なグリフ if (__predict_false(code == 0x5c)) { if (glyph_5c) { @@ -124,12 +115,12 @@ FontManager::AsciiGlyph(uint8 code, uint } } - return &((*glyph)[code * font_bytes]); + return &ascii_glyph[code * font_bytes]; } // 漢字のグリフを返す -std::vector -FontManager::KanjiGlyph(uint16 sjiscode, uint attr) const +const uint8 * +FontManager::KanjiGlyph(uint16 sjiscode) const { // Shift_JIS を JIS というかコードポイントに変換 uint sh = (sjiscode >> 8); @@ -176,23 +167,18 @@ FontManager::KanjiGlyph(uint16 sjiscode, // 16x16 は X680x0 CGROM のを使う。 base = Builtin::CGROM16x16(); break; + case FontId::_12x24: + // 24x24 は X680x0 CGROM のを使う。 + base = Builtin::CGROM24x24(); + break; default: // ここより先に必ず半角のほうでエラーが出るはず - __unreachable(); - } - - int bytes = (((font_width * 2) + 7) / 8) * font_height; - std::vector buf(bytes); - - memcpy(&buf[0], base + code * bytes, bytes); - - if (attr == TA::Em) { - for (int i = 0; i < bytes; i++) { - buf[i] |= buf[i] >> 1; - } + PANIC("corrupted fontid=%d", (int)fontid); } - return buf; + int stride = ((font_width * 2) + 7) / 8; + int bytes = stride * font_height; + return base + code * bytes; } // フォント種別一覧 @@ -201,4 +187,5 @@ FontManager::fontinfo = { // 順序はヘッダの FontId_* 識別子の順と揃えること FONT_6x12, FONT_8x16, + FONT_12x24, };