--- nono/wx/fontmanager.cpp 2026/04/29 17:05:12 1.1.1.2 +++ nono/wx/fontmanager.cpp 2026/04/29 17:05:27 1.1.1.5 @@ -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); } @@ -82,8 +85,11 @@ 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; @@ -103,7 +109,7 @@ FontManager::AsciiGlyph(uint8 code, uint const std::vector *glyph; // ボールドかどうかでテーブルが別 - if ((attr & TA::Em)) { + if ((attr & TA::Bold)) { glyph = &bold_glyph; } else { glyph = &ascii_glyph; @@ -176,23 +182,38 @@ FontManager::KanjiGlyph(uint16 sjiscode, // 16x16 は X680x0 CGROM のを使う。 base = Builtin::CGROM16x16(); break; + case FontId::_12x24: + // 24x24 は X680x0 CGROM のを使う。 + base = Builtin::CGROM24x24(); + break; default: // ここより先に必ず半角のほうでエラーが出るはず - __unreachable(); + PANIC("corrupted fontid=%d", (int)fontid); } - int bytes = (((font_width * 2) + 7) / 8) * font_height; - std::vector buf(bytes); + int stride = ((font_width * 2) + 7) / 8; + int bytes = stride * font_height; + std::vector data(bytes); - memcpy(&buf[0], base + code * bytes, bytes); - - if (attr == TA::Em) { - for (int i = 0; i < bytes; i++) { - buf[i] |= buf[i] >> 1; + if (__predict_true((attr & TA::Bold) == 0)) { + memcpy(&data[0], base + code * bytes, bytes); + } else { + // ボールドなら1ラインずつ取り出して重ね合わせる + const uint8 *s = base + code * bytes; + int i = 0; + for (int y = 0; y < font_height; y++) { + uint64 buf = 0; + for (int x = 0; x < stride; x++) { + buf = (buf << 8) | *s++; + } + buf |= buf >> 1; + for (int x = stride - 1; x >= 0; x--) { + data[i++] = (buf >> (x * 8)) & 0xff; + } } } - return buf; + return data; } // フォント種別一覧 @@ -201,4 +222,5 @@ FontManager::fontinfo = { // 順序はヘッダの FontId_* 識別子の順と揃えること FONT_6x12, FONT_8x16, + FONT_12x24, };