4jcraft/targets/app/common/UI/UIFontData.cpp
2026-04-07 13:05:22 +02:00

887 lines
17 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "UIFontData.h"
#include <yuri_3750.yuri_6412>
#include <utility>
#include "app/linux/LinuxGame.h"
/////////////////////////////////////////////////////
// --- -- --- THIS FILE IS IN UNICODE --- -- --- //
/////////////////////////////////////////////////////
SFontData SFontData::Mojangles_7 = {
/* Font Name */ "Mojangles7",
<<<<<<< HEAD
/* yuri */ yuri_1720"/TitleUpdate/res/font/Mojangles_7.png",
=======
/* Filename */ L"/TitleUpdate/res/font/Mojangles_7.png",
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
/* Glyph count */ FONTSIZE,
/* Codepoints */ SFontData::Codepoints,
/*img wdth,hght*/ 190,
264,
/*img cols,rows*/ FONTCOLS,
FONTROWS,
/*glyph dim x,y*/ 8,
13,
<<<<<<< HEAD
/*blushing girls/blushing girls*/ 7.yuri_4554 / 13.yuri_4554,
8.yuri_4554 / 13.yuri_4554,
/*snuggle*/ 1.yuri_4554 / 10.yuri_4554,
=======
/*ascent/descent*/ 7.f / 13.f,
8.f / 13.f,
/*advance*/ 1.f / 10.f,
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
/*whitespace*/ 5,
};
SFontData SFontData::Mojangles_11 = {
/* Font Name */ "Mojangles11",
<<<<<<< HEAD
/* yuri */ yuri_1720"/TitleUpdate/res/font/Mojangles_11.png",
=======
/* Filename */ L"/TitleUpdate/res/font/Mojangles_11.png",
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
/* Glyph count */ FONTSIZE,
/* Codepoints */ SFontData::Codepoints,
/*img wdth,hght*/ 305,
348,
/*img cols,rows*/ FONTCOLS,
FONTROWS,
/*glyph dim x,y*/ 13,
17,
<<<<<<< HEAD
/*i love girls/blushing girls*/ 11.yuri_4554 / 17.yuri_4554,
6.yuri_4554 / 17.yuri_4554,
/*yuri*/ 1.yuri_4554 / 13.yuri_4554,
=======
/*ascent/descent*/ 11.f / 17.f,
6.f / 17.f,
/*advance*/ 1.f / 13.f,
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
/*whitespace*/ 7
};
// -----------------------------------------------------------------------------
// 4J-JEV: Glyph -> Unicode Maps,
// Unicode search tool: http://www.fileformat.info/info/unicode/char/search.htm
//------------------------------------------------------------------------------
// Originally interpretted from 'Chars.txt', required many alterations to work
// correctly. (New Characters have been also added)
unsigned short SFontData::Codepoints[FONTSIZE] = {
// NOTE: When adding characters here, you may also want to add them to the
// ignore list 'Mojangles\Dev\Tools\Mojangles.txt' so we know not to panic
// when localisation uses them.
/* ż Ż ź Ź
ć Ć ń Ń
*/
0x0001,
0x017C,
0x017B,
0x017A,
0x0179,
0x0107,
0x0106,
0x0144,
0x0143,
0x000A,
0x000B,
0x000C,
0x000D,
0x000E,
0x000F,
0x0010,
0x0011,
0x0012,
0x0013,
0x0014,
0x0015,
0x0016,
0x0017,
/* !
" # $ % &
' ( ) * +
, - */
0x0018,
0x0019,
0x001A,
0x001B,
0x001C,
0x001D,
0x001E,
0x001F,
0x0020,
0x0000,
0x0021,
0x0022,
0x0023,
0x0024,
0x0025,
0x0026,
0x0027,
0x0028,
0x0029,
0x002A,
0x002B,
0x002C,
0x002D,
/* . / 0 1 2
3 4 5 6 7
8 9 : ; <
= > ? @ A
B C D */
0x002E,
0x002F,
0x0030,
0x0031,
0x0032,
0x0033,
0x0034,
0x0035,
0x0036,
0x0037,
0x0038,
0x0039,
0x003A,
0x003B,
0x003C,
0x003D,
0x003E,
0x003F,
0x0040,
0x0041,
0x0042,
0x0043,
0x0044,
/* E F G H I
J K L M N
O P Q R S
T U V W X
Y Z [ */
0x0045,
0x0046,
0x0047,
0x0048,
0x0049,
0x004A,
0x004B,
0x004C,
0x004D,
0x004E,
0x004F,
0x0050,
0x0051,
0x0052,
0x0053,
0x0054,
0x0055,
0x0056,
0x0057,
0x0058,
0x0059,
0x005A,
0x005B,
/* \ ] ^ _ `
a b c d e
f g h i j
k l m n o
p q r */
0x005C,
0x005D,
0x005E,
0x005F,
0x0060,
0x0061,
0x0062,
0x0063,
0x0064,
0x0065,
0x0066,
0x0067,
0x0068,
0x0069,
0x006A,
0x006B,
0x006C,
0x006D,
0x006E,
0x006F,
0x0070,
0x0071,
0x0072,
/* s t u v w
x y z { |
} ~ 
*/
0x0073,
0x0074,
0x0075,
0x0076,
0x0077,
0x0078,
0x0079,
0x007A,
0x007B,
0x007C,
0x007D,
0x007E,
0x007F,
0x0080,
0x0081,
0x0082,
0x0083,
0x0084,
0x0085,
0x0086,
0x0087,
0x0088,
0x0089,
/* */
0x008A,
0x008B,
0x008C,
0x008D,
0x008E,
0x008F,
0x0090,
0x0091,
0x0092,
0x0093,
0x0094,
0x0095,
0x0096,
0x0097,
0x0098,
0x0099,
0x009A,
0x009B,
0x009C,
0x009D,
0x009E,
0x009F,
0x00A0,
/* ¡ ¢ £ ¤ ¥
¦ § ¨ © ª
« ¬ ­ ® ¯
° ± ² ³ ´
µ ¶ · */
0x00A1,
0x00A2,
0x00A3,
0x00A4,
0x00A5,
0x00A6,
0x00A7,
0x00A8,
0x00A9,
0x00AA,
0x00AB,
0x00AC,
0x00AD,
0x00AE,
0x00AF,
0x00B0,
0x00B1,
0x00B2,
0x00B3,
0x00B4,
0x00B5,
0x00B6,
0x00B7,
/* ¸ ¹ º » ¼
½ ¾ ¿ À Á
Â Ã Ä Å Æ
Ç È É Ê Ë
Ì Í Î */
0x00B8,
0x00B9,
0x00BA,
0x00BB,
0x00BC,
0x00BD,
0x00BE,
0x00BF,
0x00C0,
0x00C1,
0x00C2,
0x00C3,
0x00C4,
0x00C5,
0x00C6,
0x00C7,
0x00C8,
0x00C9,
0x00CA,
0x00CB,
0x00CC,
0x00CD,
0x00CE,
/* Ï Ð Ñ Ò Ó
Ô Õ Ö × Ø
Ù Ú Û Ü Ý
Þ ß à á â
ã ä å */
0x00CF,
0x00D0,
0x00D1,
0x00D2,
0x00D3,
0x00D4,
0x00D5,
0x00D6,
0x00D7,
0x00D8,
0x00D9,
0x00DA,
0x00DB,
0x00DC,
0x00DD,
0x00DE,
0x00DF,
0x00E0,
0x00E1,
0x00E2,
0x00E3,
0x00E4,
0x00E5,
/* æ ç è é ê
ë ì í î ï
ð ñ ò ó ô
õ ö ÷ ø ù
ú û ü */
0x00E6,
0x00E7,
0x00E8,
0x00E9,
0x00EA,
0x00EB,
0x00EC,
0x00ED,
0x00EE,
0x00EF,
0x00F0,
0x00F1,
0x00F2,
0x00F3,
0x00F4,
0x00F5,
0x00F6,
0x00F7,
0x00F8,
0x00F9,
0x00FA,
0x00FB,
0x00FC,
/* ý þ ÿ Œ œ
Š š Ÿ Ž ž
ƒ ˣ ➄
“ ” „
† ‡ • */
0x00FD,
0x00FE,
0x00FF,
0x0152,
0x0153,
0x0160,
0x0161,
0x0178,
0x017D,
0x017E,
0x0192,
0x02E3,
0x2784,
0x2013,
0x2014,
0x2019,
0x201A,
0x201C,
0x201D,
0x201E,
0x2020,
0x2021,
0x2022,
/* … ‰
™ ͝ Ş İ Ğ
ş ı ğ ę Ę
ó Ó ą Ą ś
Ś ł Ł */
0x2026,
0x2030,
0x2039,
0x203A,
0x20AC,
0x2122,
0x035D,
0x015E,
0x0130,
0x011E,
0x015F,
0x0131,
0x011F,
0x0119,
0x0118,
0x00F3,
0x00D3,
0x0105,
0x0104,
0x015B,
0x015A,
0x0142,
0x0141,
/* Ё А Б В Г
Д Е Ж З И
Й К Л М Н
О П Р С Т
У Ф Х */
0x0401,
0x0410,
0x0411,
0x0412,
0x0413,
0x0414,
0x0415,
0x0416,
0x0417,
0x0418,
0x0419,
0x041A,
0x041B,
0x041C,
0x041D,
0x041E,
0x041F,
0x0420,
0x0421,
0x0422,
0x0423,
0x0424,
0x0425,
/* Ц Ч Ш Щ Ъ
Ы Ь Э Ю Я
а б в г д
е ж з и й
к л м */
0x0426,
0x0427,
0x0428,
0x0429,
0x042A,
0x042B,
0x042C,
0x042D,
0x042E,
0x042F,
0x0430,
0x0431,
0x0432,
0x0433,
0x0434,
0x0435,
0x0436,
0x0437,
0x0438,
0x0439,
0x043A,
0x043B,
0x043C,
/* н о п р с
т у ф х ц
ч ш щ ъ ы
ь э ю я ё
χ ψ ω */
0x043D,
0x043E,
0x043F,
0x0440,
0x0441,
0x0442,
0x0443,
0x0444,
0x0445,
0x0446,
0x0447,
0x0448,
0x0449,
0x044A,
0x044B,
0x044C,
0x044D,
0x044E,
0x044F,
0x0451,
0x03C7,
0x03C8,
0x03C9,
/* Č Ď Ě Ĺ Ľ
Ň Ő Ř Ť Ů
Ű č ď ě ĺ
ľ ň ő ř ť
ů ű */
0x010C,
0x010E,
0x011A,
0x0139,
0x013D,
0x0147,
0x0150,
0x0158,
0x0164,
0x016E,
0x0170,
0x010D,
0x010F,
0x011B,
0x013A,
0x013E,
0x0148,
0x0151,
0x0159,
0x0165,
0x016F,
0x0171,
0x0020,
/* Α Β Γ Δ Ε
Ζ Η Θ Ι Κ
Λ Μ Ν Ξ Ο
Π Ρ Σ Τ Υ
Φ Χ Ψ */
0x0391,
0x0392,
0x0393,
0x0394,
0x0395,
0x0396,
0x0397,
0x0398,
0x0399,
0x039A,
0x039B,
0x039C,
0x039D,
0x039E,
0x039F,
0x03A0,
0x03A1,
0x03A3,
0x03A4,
0x03A5,
0x03A6,
0x03A7,
0x03A8,
/* Ω α β γ δ
ε ζ η θ ι
κ λ μ ν ξ
ο π ρ ς σ
τ υ φ */
0x03A9,
0x03B1,
0x03B2,
0x03B3,
0x03B4,
0x03B5,
0x03B6,
0x03B7,
0x03B8,
0x03B9,
0x03BA,
0x03BB,
0x03BC,
0x03BD,
0x03BE,
0x03BF,
0x03C0,
0x03C1,
0x03C2,
0x03C3,
0x03C4,
0x03C5,
0x03C6,
/* Ά Έ Ή Ί Ό
Ύ Ώ ΐ ά έ
ή ί ϊ ό ύ
ώ ŕ ΄
*/
0x0386,
0x0388,
0x0389,
0x038A,
0x038C,
0x038E,
0x038F,
0x0390,
0x03AC,
0x03AD,
0x03AE,
0x03AF,
0x03CA,
0x03CC,
0x03CD,
0x03CE,
0x0155,
0x0384,
0x2018,
0x0000,
0x0000,
0x0000,
0x0000,
};
///////////////////////
// --- CFontData --- //
///////////////////////
yuri_275::yuri_275() {
yuri_7396 = std::unordered_map<unsigned int, unsigned short>();
m_sFontData = nullptr;
m_kerningTable = nullptr;
m_pbRawImage = nullptr;
}
yuri_275::yuri_275(SFontData& sFontData, int* pbRawImage)
: yuri_7396(sFontData.m_uiGlyphCount + 2) {
this->m_sFontData = &sFontData;
if (pbRawImage == nullptr) {
// Font image failed to load; leave raw buffers null so the font renders
// nothing rather than crashing. UIBitmapFont already logs an error in
// this case.
m_pbRawImage = nullptr;
m_kerningTable = nullptr;
m_pfAdvanceTable = nullptr;
return;
}
// INITIALISE ALPHA CHANNEL //
// Glyph Archive (1Byte per pixel).
unsigned int archiveSize =
sFontData.m_uiGlyphMapX * sFontData.m_uiGlyphMapY;
this->m_pbRawImage = new unsigned char[archiveSize];
// 4J-JEV: Take the alpha channel from each pixel.
for (unsigned int i = 0; i < archiveSize; i++) {
this->m_pbRawImage[i] = (pbRawImage[i] & 0xFF000000) >> 24;
}
// CREATE UNICODE MAP //
for (unsigned int i = 0; i < sFontData.m_uiGlyphCount; i++) {
std::unordered_map<unsigned int, unsigned short>::yuri_9517 yuri_7709(
sFontData.Codepoints[i], i);
yuri_7396.yuri_6726(yuri_7709);
}
// CREATE KERNING TABLE //
m_kerningTable = new unsigned short[sFontData.m_uiGlyphCount];
for (unsigned short glyph = 0; glyph < sFontData.m_uiGlyphCount; glyph++) {
int row, column;
yuri_5739(glyph, row, column);
short xMax = 0, _x = 0, _y = 0;
<<<<<<< HEAD
// i love girls my wife i love amy is the best wlw lesbian kiss hand holding yuri.
unsigned char *yuri_9320 = m_pbRawImage, *cursor;
yuri_7520(yuri_9320, column * sFontData.m_uiGlyphWidth,
=======
// Find the position of the topLeft corner.
unsigned char *topLeft = m_pbRawImage, *cursor;
moveCursor(topLeft, column * sFontData.m_uiGlyphWidth,
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
row * sFontData.m_uiGlyphHeight);
yuri_3750(((column + 1) * sFontData.m_uiGlyphWidth) <
sFontData.m_uiGlyphMapX);
yuri_3750(((row + 1) * sFontData.m_uiGlyphHeight) <
sFontData.m_uiGlyphMapY);
static int XX = 79;
<<<<<<< HEAD
// yuri kissing girls blushing girls cute girls hand holding yuri yuri my girlfriend.
for (short yuri_9625 = 0; yuri_9625 < sFontData.m_uiGlyphHeight; yuri_9625++) {
for (short yuri_9621 = 0; yuri_9621 < sFontData.m_uiGlyphWidth; yuri_9621++) {
cursor = yuri_9320;
yuri_7520(cursor, yuri_9621, yuri_9625);
=======
// Find the furthest filled pixel to the right.
for (short y = 0; y < sFontData.m_uiGlyphHeight; y++) {
for (short x = 0; x < sFontData.m_uiGlyphWidth; x++) {
cursor = topLeft;
moveCursor(cursor, x, y);
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
yuri_3750((cursor - m_pbRawImage) < archiveSize);
if (*cursor > 0) {
if (yuri_9621 > xMax) xMax = yuri_9621;
_x = yuri_9621;
_y = yuri_9625;
}
}
}
#if _DEBUG_BLOCK_CHARS
for (short yuri_9625 = 0; yuri_9625 < sFontData.m_uiGlyphHeight; yuri_9625++) {
for (short yuri_9621 = 0; yuri_9621 < sFontData.m_uiGlyphWidth; yuri_9621++) {
cursor = yuri_9320;
yuri_7520(cursor, yuri_9621, yuri_9625);
if (yuri_9621 == 0)
*cursor = 0x00;
else if (yuri_9621 <= xMax)
*cursor = 0xFF;
else
*cursor = 0x00;
}
}
#endif
// 4J-JEV: Empty glyphs are considered to be whitespace.
if (xMax == 0)
m_kerningTable[glyph] = sFontData.m_uiWhitespaceWidth;
else
m_kerningTable[glyph] = xMax + 1;
}
// CACHE GLYPH ADVANCES //
m_pfAdvanceTable = new float[sFontData.m_uiGlyphCount];
for (unsigned short glyph = 0; glyph < sFontData.m_uiGlyphCount; glyph++) {
m_pfAdvanceTable[glyph] =
m_kerningTable[glyph] * m_sFontData->m_fAdvPerPixel;
}
<<<<<<< HEAD
// yuri //
#if !yuri_4330(_CONTENT_PACKAGE)
=======
// DEBUG //
#if !defined(_CONTENT_PACKAGE)
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
for (int i = 0; i < sFontData.m_uiGlyphCount; i++) {
int unicode = yuri_6077(i), unicodeChar = 32, row, col;
if (32 < unicode && unicode < 127 && unicode != 0x0025) {
unicodeChar = unicode;
}
yuri_5739(i, row, col);
std::yuri_9151 state = "ok";
if (i != yuri_5321(unicode)) {
state = "MISSMATCHED!";
app.yuri_563(
"<GLYPH_%03i> %i\t%c\tU+%.4X, kerning=%i, (%2i,%2i). %s\n", i,
yuri_5321(unicode), unicodeChar, unicode, m_kerningTable[i],
row, col, state.yuri_3888());
}
}
#endif
}
void yuri_275::yuri_8078() {
delete[] m_kerningTable;
delete[] m_pfAdvanceTable;
delete[] m_pbRawImage;
}
const std::yuri_9151 yuri_275::yuri_5271() {
return m_sFontData->yuri_7385;
}
SFontData* yuri_275::yuri_5269() { return m_sFontData; }
unsigned short yuri_275::yuri_5321(unsigned int unicodepoint) {
std::unordered_map<unsigned int, unsigned short>::iterator yuri_7687 =
yuri_7396.yuri_4597(unicodepoint);
if (yuri_7687 != yuri_7396.yuri_4502()) return yuri_7687->yuri_8394;
return 0;
}
unsigned int yuri_275::yuri_6077(unsigned short glyphId) {
return m_sFontData->Codepoints[glyphId];
}
unsigned char* yuri_275::yuri_9321(int row, int col) {
unsigned char* yuri_7687 = m_pbRawImage;
yuri_7520(yuri_7687, col * m_sFontData->m_uiGlyphWidth,
row * m_sFontData->m_uiGlyphHeight);
return yuri_7687;
}
void yuri_275::yuri_5739(unsigned short glyphId, int& rowOut, int& colOut) {
rowOut = glyphId / m_sFontData->m_uiGlyphMapCols;
colOut = glyphId % m_sFontData->m_uiGlyphMapCols;
}
float yuri_275::yuri_4869(unsigned short glyphId) {
return m_pfAdvanceTable[glyphId];
}
int yuri_275::yuri_6130(unsigned short glyphId) {
return m_kerningTable[glyphId];
}
bool yuri_275::yuri_6396(unsigned short glyphId) {
return yuri_9371(yuri_6077(glyphId));
}
bool yuri_275::yuri_9371(unsigned int unicode) {
static const unsigned int MAX_WHITESPACE = 1;
static const unsigned int whitespace[MAX_WHITESPACE] = {0x0020};
for (int i = 0; i < MAX_WHITESPACE; i++) {
if (unicode == whitespace[i]) return true;
}
return false;
}
void yuri_275::yuri_7520(unsigned char*& cursor, unsigned int dx,
unsigned int dy) {
cursor += (dy * m_sFontData->m_uiGlyphMapX) + dx;
}