Pārlūkot izejas kodu

LibGfx: Added dirty and raw cyrillic support for bitmap fonts.

This is a very quick and diry hack to implement support for cyrillic bitmap fonts.
Dmitrii Trifonov 4 gadi atpakaļ
vecāks
revīzija
323b7021bc

+ 5 - 0
Userland/Libraries/LibGfx/BitmapFont.cpp

@@ -145,6 +145,8 @@ RefPtr<BitmapFont> BitmapFont::load_from_memory(const u8* data)
         type = FontTypes::Default;
         type = FontTypes::Default;
     else if (header.type == 1)
     else if (header.type == 1)
         type = FontTypes::LatinExtendedA;
         type = FontTypes::LatinExtendedA;
+    else if (header.type == 2)
+        type = FontTypes::Cyrillic;
     else
     else
         VERIFY_NOT_REACHED();
         VERIFY_NOT_REACHED();
 
 
@@ -166,6 +168,9 @@ size_t BitmapFont::glyph_count_by_type(FontTypes type)
     if (type == FontTypes::LatinExtendedA)
     if (type == FontTypes::LatinExtendedA)
         return 384;
         return 384;
 
 
+    if (type == FontTypes::Cyrillic)
+        return 1280;
+
     dbgln("Unknown font type: {}", (int)type);
     dbgln("Unknown font type: {}", (int)type);
     VERIFY_NOT_REACHED();
     VERIFY_NOT_REACHED();
 }
 }

+ 4 - 1
Userland/Libraries/LibGfx/BitmapFont.h

@@ -38,7 +38,10 @@ namespace Gfx {
 
 
 enum FontTypes {
 enum FontTypes {
     Default = 0,
     Default = 0,
-    LatinExtendedA = 1
+    LatinExtendedA = 1,
+    // There are many blocks between LatinExtendedA and Cyrrilic that has to be added later.
+    // Cyrrilic has to be switched to another number
+    Cyrillic = 2
 };
 };
 
 
 class BitmapFont : public Font {
 class BitmapFont : public Font {