Skip to content

Truetype support #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/file_utils.h"
"src/font_manager.cc"
"src/font_manager.h"
"src/freetype_manager.cc"
"src/freetype_manager.h"
"src/game_config.cc"
"src/game_config.h"
"src/game_dialog.cc"
Expand Down Expand Up @@ -374,6 +376,19 @@ target_include_directories(${EXECUTABLE_NAME} PRIVATE ${ZLIB_INCLUDE_DIRS})
target_link_libraries(${EXECUTABLE_NAME} ${SDL2_LIBRARIES})
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${SDL2_INCLUDE_DIRS})

add_subdirectory("third_party/freetype")
target_link_libraries(${EXECUTABLE_NAME} ${FREETYPE_LIBRARIES})
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${FREETYPE_INCLUDE_DIRS})

add_subdirectory("third_party/iconv")
target_link_libraries(${EXECUTABLE_NAME} ${ICONV_LIBRARIES})
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${ICONV_INCLUDE_DIRS})

message(status "${ZLIB_INCLUDE_DIRS}")
message(status "${SDL2_INCLUDE_DIRS}")
message(status "${FREETYPE_INCLUDE_DIRS}")
message(status "${ICONV_INCLUDE_DIRS}")

if(APPLE)
if(IOS)
install(TARGETS ${EXECUTABLE_NAME} DESTINATION "Payload")
Expand Down
55 changes: 55 additions & 0 deletions fonts/chs/font.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[font0]
maxHeight= 10
maxWidth= 10
lineSpacing=0
wordSpacing=4
letterSpacing=1
heightOffset=0
fileName=font.ttf
warpMode=0
encoding=GBK

[font1]
maxHeight= 12
maxWidth= 12
lineSpacing=1
wordSpacing=4
letterSpacing=1
heightOffset=1
fileName=zpix.ttf
warpMode=1
encoding=GBK

[font2]
maxHeight= 15
maxWidth= 15
lineSpacing=1
wordSpacing=3
letterSpacing=1
heightOffset=0
fileName=font.ttf
warpMode=0
encoding=GBK

[font3]
maxHeight= 15
maxWidth= 15
lineSpacing=1
wordSpacing=4
letterSpacing=1
heightOffset=0
fileName=font.ttf
warpMode=0
encoding=GBK

[font4]
maxHeight= 22
maxWidth= 22
lineSpacing=1
wordSpacing=12
letterSpacing=1
heightOffset=0
fileName=font.ttf
warpMode=0
encoding=GBK

Binary file added fonts/chs/font.ttf
Binary file not shown.
Binary file added fonts/chs/zpix.ttf
Binary file not shown.
Binary file added fonts/english/JH_FALLOUT.TTF
Binary file not shown.
Binary file added fonts/english/TT0807M_.TTF
Binary file not shown.
55 changes: 55 additions & 0 deletions fonts/english/font.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[font0]
maxHeight=10
maxWidth=10
lineSpacing=0
wordSpacing=4
letterSpacing=1
heightOffset=0
fileName=r_fallouty.ttf
warpMode=0
encoding=GBK

[font1]
maxHeight=12
maxWidth=12
lineSpacing=0
wordSpacing=4
letterSpacing=1
heightOffset=0
fileName=r_fallouty.ttf
warpMode=0
encoding=GBK

[font2]
maxHeight=15
maxWidth=15
lineSpacing=1
wordSpacing=3
letterSpacing=1
heightOffset=0
fileName=r_fallouty.ttf
warpMode=0
encoding=GBK

[font3]
maxHeight=15
maxWidth=15
lineSpacing=1
wordSpacing=4
letterSpacing=1
heightOffset=0
fileName=r_fallouty.ttf
warpMode=0
encoding=GBK

[font4]
maxHeight=24
maxWidth=24
lineSpacing=1
wordSpacing=12
letterSpacing=1
heightOffset=0
fileName=TT0807M_.TTF
warpMode=0
encoding=GBK

Binary file added fonts/english/r_fallouty.ttf
Binary file not shown.
94 changes: 70 additions & 24 deletions src/character_editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,9 @@ static void characterEditorDrawPcStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 32, stringBuffer, 640, 640, color);

// EXPERIENCE
y += fontGetLineHeight() + 1;
//y += fontGetLineHeight() + 1;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 10 + 1;
if (characterEditorSelectedItem != 8) {
color = _colorTable[992];
} else {
Expand All @@ -2404,7 +2406,9 @@ static void characterEditorDrawPcStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 32, stringBuffer, 640, 640, color);

// EXP NEEDED TO NEXT LEVEL
y += fontGetLineHeight() + 1;
//y += fontGetLineHeight() + 1;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 10 + 1;
if (characterEditorSelectedItem != 9) {
color = _colorTable[992];
} else {
Expand Down Expand Up @@ -2656,8 +2660,12 @@ static void characterEditorDrawDerivedStats()
snprintf(t, sizeof(t), "%d/%d", currHp, maxHp);
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 263, t, 640, 640, color);



// Poisoned
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_POISONED) {
color = critterGetPoison(gDude) != 0 ? _colorTable[32747] : _colorTable[15845];
Expand All @@ -2670,7 +2678,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 194, t, 640, 640, color);

// Radiated
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_RADIATED) {
color = critterGetRadiation(gDude) != 0 ? _colorTable[32747] : _colorTable[15845];
Expand All @@ -2683,7 +2693,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 194, t, 640, 640, color);

// Eye Damage
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_EYE_DAMAGE) {
color = (conditions & DAM_BLIND) ? _colorTable[32747] : _colorTable[15845];
Expand All @@ -2696,7 +2708,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 194, t, 640, 640, color);

// Crippled Right Arm
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_CRIPPLED_RIGHT_ARM) {
color = (conditions & DAM_CRIP_ARM_RIGHT) ? _colorTable[32747] : _colorTable[15845];
Expand All @@ -2709,7 +2723,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 194, t, 640, 640, color);

// Crippled Left Arm
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_CRIPPLED_LEFT_ARM) {
color = (conditions & DAM_CRIP_ARM_LEFT) ? _colorTable[32747] : _colorTable[15845];
Expand All @@ -2722,7 +2738,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 194, t, 640, 640, color);

// Crippled Right Leg
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_CRIPPLED_RIGHT_LEG) {
color = (conditions & DAM_CRIP_LEG_RIGHT) ? _colorTable[32747] : _colorTable[15845];
Expand All @@ -2735,7 +2753,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 194, t, 640, 640, color);

// Crippled Left Leg
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_CRIPPLED_LEFT_LEG) {
color = (conditions & DAM_CRIP_LEG_LEFT) ? _colorTable[32747] : _colorTable[15845];
Expand Down Expand Up @@ -2766,7 +2786,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 288, t, 640, 640, color);

// Action Points
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_ACTION_POINTS) {
color = _colorTable[32747];
Expand All @@ -2782,7 +2804,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 288, t, 640, 640, color);

// Carry Weight
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_CARRY_WEIGHT) {
color = _colorTable[32747];
Expand All @@ -2798,7 +2822,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 288, t, 640, 640, critterIsEncumbered(gDude) ? _colorTable[31744] : color);

// Melee Damage
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_MELEE_DAMAGE) {
color = _colorTable[32747];
Expand All @@ -2820,7 +2846,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 288, t, 640, 640, color);

// Damage Resistance
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_DAMAGE_RESISTANCE) {
color = _colorTable[32747];
Expand All @@ -2836,7 +2864,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 288, t, 640, 640, color);

// Poison Resistance
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_POISON_RESISTANCE) {
color = _colorTable[32747];
Expand All @@ -2852,7 +2882,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 288, t, 640, 640, color);

// Radiation Resistance
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_RADIATION_RESISTANCE) {
color = _colorTable[32747];
Expand All @@ -2868,7 +2900,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 288, t, 640, 640, color);

// Sequence
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_SEQUENCE) {
color = _colorTable[32747];
Expand All @@ -2884,7 +2918,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 288, t, 640, 640, color);

// Healing Rate
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_HEALING_RATE) {
color = _colorTable[32747];
Expand All @@ -2900,7 +2936,9 @@ static void characterEditorDrawDerivedStats()
fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 288, t, 640, 640, color);

// Critical Chance
y += fontGetLineHeight() + 3;
//y += fontGetLineHeight() + 3;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
y += 13;

if (characterEditorSelectedItem == EDITOR_FIRST_DERIVED_STAT + EDITOR_DERIVED_STAT_CRITICAL_CHANCE) {
color = _colorTable[32747];
Expand Down Expand Up @@ -2994,11 +3032,15 @@ static void characterEditorDrawSkills(int a1)

fontDrawText(gCharacterEditorWindowBuffer + 640 * y + 573, valueString, 640, 640, color);

y += fontGetLineHeight() + 1;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
//y += fontGetLineHeight() + 1;
y += 10 + 1;
}

if (!gCharacterEditorIsCreationMode) {
y = gCharacterEditorCurrentSkill * (fontGetLineHeight() + 1);
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
//y = gCharacterEditorCurrentSkill * (fontGetLineHeight() + 1);
y = gCharacterEditorCurrentSkill * (10 + 1);
gCharacterEditorSkillValueAdjustmentSliderY = y + 27;

blitBufferToBufferTrans(
Expand Down Expand Up @@ -5132,7 +5174,9 @@ static void characterEditorHandleInfoButtonPressed(int eventCode)
double mouseY = gCharacterEditorMouseY;
double fontLineHeight = fontGetLineHeight();
double y = 353.0;
double step = fontGetLineHeight() + 3 + 0.56;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
//double step = fontGetLineHeight() + 3 + 0.56;
double step = 10 + 3 + 0.56;
int index;
for (index = 0; index < 8; index++) {
if (mouseY >= y - 4.0 && mouseY <= y + fontLineHeight) {
Expand Down Expand Up @@ -5397,7 +5441,9 @@ static void characterEditorDrawOptionalTraits()

traitsSetSelected(gCharacterEditorTempTraits[0], gCharacterEditorTempTraits[1]);

step = fontGetLineHeight() + 3 + 0.56;
//step = fontGetLineHeight() + 3 + 0.56;
// Adapt to other languages, because the pixels here are fixed, so the calculation of LineHeight brings trouble - replaces it with fixed pixel values
step = 10 + 3 + 0.56;
y = 353;
for (i = 0; i < 8; i++) {
if (i == v0) {
Expand Down Expand Up @@ -6300,8 +6346,8 @@ static int perkDialogDrawPerks()
qsort(gPerkDialogOptionList, count, sizeof(*gPerkDialogOptionList), perkDialogOptionCompare);

int v16 = count - gPerkDialogTopLine;
if (v16 > 11) {
v16 = 11;
if (v16 > 11 * 12 / (fontGetLineHeight() + 2)) {
v16 = 11 * 12 / (fontGetLineHeight() + 2);
}

v16 += gPerkDialogTopLine;
Expand Down
Loading