Skip to content
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
5 changes: 5 additions & 0 deletions .github/actions/build-phobos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ inputs:
runs:
using: "composite"
steps:
- name: Checkout with submodules and LFS
uses: actions/checkout@v6
with:
submodules: recursive
lfs: true
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.1
with:
Expand Down
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[submodule "YRpp"]
path = YRpp
url = https://github.com/Phobos-developers/YRpp.git
[submodule "harfbuzz"]
path = harfbuzz
url = https://github.com/G-LimeJuice/harfbuzz
[submodule "fribidi"]
path = fribidi
url = https://github.com/G-LimeJuice/fribidi
[submodule "freetype"]
path = freetype
url = https://github.com/G-LimeJuice/freetype
12 changes: 10 additions & 2 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<ClCompile Include="src\Ext\EBolt\Hooks.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.SimpleDeployer.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.Unload.cpp" />
<ClCompile Include="src\TextRenderer\Hooks.cpp" />
<ClCompile Include="src\TextRenderer\TextRenderer.cpp" />
<ClCompile Include="src\New\Entity\Ares\RadarJammerClass.cpp" />
<ClCompile Include="src\New\Type\Affiliated\CreateUnitTypeClass.cpp" />
<ClCompile Include="src\Blowfish\blowfish.cpp" />
Expand Down Expand Up @@ -225,6 +227,7 @@
<ClInclude Include="src\Commands\DeselectObject.h" />
<ClInclude Include="src\Ext\EBolt\Body.h" />
<ClInclude Include="src\Ext\Event\Body.h" />
<ClInclude Include="src\TextRenderer\TextRenderer.h" />
<ClInclude Include="src\New\Entity\Ares\RadarJammerClass.h" />
<ClInclude Include="src\New\Type\Affiliated\CreateUnitTypeClass.h" />
<ClInclude Include="src\Blowfish\blowfish.h" />
Expand Down Expand Up @@ -502,7 +505,7 @@
<ConformanceMode>true</ConformanceMode>
<DiagnosticsFormat>Caret</DiagnosticsFormat>
<OmitFramePointers>false</OmitFramePointers>
<PreprocessorDefinitions>DEBUG;SYR_VER=2;HAS_EXCEPTIONS=0;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0601;NTDDI_VERSION=0x06010000;%(PreprocessorDefinitions);%(AdditionalDefinitions);PHOBOS_DLL="$(ProjectName).dll"</PreprocessorDefinitions>
<PreprocessorDefinitions>DEBUG;SYR_VER=2;HAS_EXCEPTIONS=0;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0601;NTDDI_VERSION=0x06010000;%(PreprocessorDefinitions);%(AdditionalDefinitions);PHOBOS_DLL="$(ProjectName).dll";HAV_HB_STATIC</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
Expand All @@ -521,15 +524,20 @@
<EnableModules>true</EnableModules>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OpenMPSupport>true</OpenMPSupport>
<AdditionalIncludeDirectories>$(ProjectDir)hbftfr\include;$(ProjectDir)hbftfr\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dbghelp.lib;onecore.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dbghelp.lib;onecore.lib;harfbuzz.lib;
fribidi.lib;freetype.lib;
bz2.lib;
zs.lib;libpng16.lib;brotlidec.lib;brotlienc.lib;brotlicommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
<ProfileGuidedDatabase>$(IntDir)$(TargetName).pgd</ProfileGuidedDatabase>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
<AdditionalLibraryDirectories>$(ProjectDir)hbftfr\lib;$(ProjectDir)hbftfr\include;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>
Expand Down
1 change: 1 addition & 0 deletions freetype
Submodule freetype added at b6bcd2
1 change: 1 addition & 0 deletions fribidi
Submodule fribidi added at 5c85a1
1 change: 1 addition & 0 deletions harfbuzz
Submodule harfbuzz added at 5ee942
102 changes: 102 additions & 0 deletions src/TextRenderer/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@

#include <utility>
#include <Helpers/Macro.h>
#include "TextRenderer.h"
#include <CCINIClass.h>
#include <BitFont.h>
#include <BitText.h>
#include <Phobos.h>
#include <Utilities/GeneralUtils.h>
#include <Utilities/Debug.h>

static bool IsTTFEnabled()
{
static CCINIClass ini_uimd;
ini_uimd.LoadFromFile(GameStrings::UIMD_INI);
return ini_uimd.ReadBool("Render", "EnableTTF", false);
}
// Best fix Unicode
DEFINE_HOOK(0x5D3BA0, sub_433F50, 7)
{

GET_STACK(const wchar_t*, pText, 0xC);
std::wstring wtext = TextRenderer::FixUtf8InWchar(pText);
R->Stack(0xC, wtext.c_str());

return 0;

}

// 43393A
DEFINE_HOOK(0x433880, BitFont_CTOR, 8)
{

if (IsTTFEnabled())
return 0;
GET(BitFont*, pFont, ECX);
CCINIClass ini_uimd {};
ini_uimd.LoadFromFile(GameStrings::UIMD_INI);
ini_uimd.ReadString("Font", "FileName", "default.ttf", Phobos::readBuffer);
std::string fontPath = std::string("Fonts\\") + Phobos::readBuffer;
pFont = TextRenderer::BitFont_CTOR_(pFont, fontPath.c_str());

return pFont ? 0x43393A : 0;
}


DEFINE_HOOK(0x433CF0, BitFont_GetTextDimension, 8)
{
if (IsTTFEnabled())
return 0;
GET(BitFont*, pFont, ECX);
GET_STACK(const wchar_t*, pText, 0x4);
GET_STACK(int*, pWidth, 0x8);
GET_STACK(int*, pHeight, 0xC);
GET_STACK(int, nMaxWidth, 0x10);
std::wstring arabicShaped;


R->EAX((DWORD)TextRenderer::BitFont_GetTextDimension_(pFont, pText, pWidth, pHeight, nMaxWidth));

return 0x433EA2;
}
DEFINE_HOOK(0x434CD0, BitText_DrawText, 10)
{
if (IsTTFEnabled())
return 0;
GET_STACK(BitFont*, pFont, 0x4);
GET_STACK(Surface*, pSurface, 0x8);
GET_STACK(const wchar_t*, pWideString, 0xC);
GET_STACK(int, X, 0x10);
GET_STACK(int, Y, 0x14);
GET_STACK(int, W, 0x18);
GET_STACK(int, H, 0x1C);
GET_STACK(int, a8, 0x20);
GET_STACK(int, a9, 0x24);
GET_STACK(int, nColorAdjust, 0x28);

bool handled = TextRenderer::BitText_DrawText_(pFont, pSurface, pWideString, X, Y, W, H, a8, a9, nColorAdjust);

return handled ? 0x435310 : 0;
}

DEFINE_HOOK(0x434500, sub_434500, 7)
{
if (IsTTFEnabled())
return 0;
GET(BitFont*, pFont, ECX);
GET_STACK(wchar_t*, pText, 0x4);
GET_STACK(int, xLeft, 0x8);
GET_STACK(int, yTop, 0xC);
GET_STACK(int, charCount, 0x10);
GET_STACK(int, nColorAdjust, 0x14);

if (!TextRenderer::GetFTFace(pFont))
return 0;

R->EAX(TextRenderer::BitFont_434500_(pFont, pText, xLeft, yTop, charCount, nColorAdjust));
return 0x4346B4;
}



Loading
Loading