Add Roboto font, misc icons and text things

This commit is contained in:
elasota
2019-12-23 17:43:10 -05:00
parent e089cabf98
commit 7ab4c8960d
120 changed files with 2995 additions and 743 deletions

View File

@@ -0,0 +1,217 @@
#include <string>
#include <stdio.h>
uint16_t g_toUnicode[256];
uint8_t g_toUpper[256];
uint8_t g_toLower[256];
uint8_t g_stripDiacritic[256];
std::string g_charDescs[256];
template<class T>
void DumpListing(FILE *outF, const T *buf, const char *hexFormat, const char *title)
{
fprintf(outF, "\t\tconst %s[256] =\n", title);
fprintf(outF, "\t\t{");
for (int i = 0; i < 256; i++)
{
if (i % 16 == 0)
fprintf(outF, "\n\t\t\t");
fprintf(outF, hexFormat, static_cast<int>(buf[i]));
fputc(',', outF);
if (i % 16 != 15)
fputc(' ', outF);
}
fprintf(outF, "\n\t\t};\n");
}
uint32_t ParseHexCode(const std::string &str)
{
if (str.substr(0, 2) != "0x")
return 0;
uint32_t result = 0;
for (size_t i = 2; i < str.length(); i++)
{
const char c = str[i];
result = result * 16;
if (c >= 'a' && c <= 'f')
result += (c - 'a') + 0xA;
else if (c >= 'A' && c <= 'F')
result += (c - 'A') + 0xA;
else if (c >= '0' && c <= '9')
result += (c - '0');
else
result = result / 16;
}
return result;
}
bool ParseLatinDesc(const std::string &str, bool &isSmall, bool &isCapital, std::string &remainder)
{
if (str.substr(0, 6) != "LATIN ")
return false;
isCapital = false;
isSmall = false;
if (str.substr(6, 6) == "SMALL ")
{
isSmall = true;
remainder = str.substr(12);
}
else if (str.substr(6, 8) == "CAPITAL ")
{
isCapital = true;
remainder = str.substr(14);
}
else
remainder = str.substr(6);
return true;
}
void ProcessLine(const std::string &lineStr)
{
std::string comment;
std::string contents;
size_t commentPos = lineStr.find('#');
if (commentPos == std::string::npos)
contents = lineStr;
else
{
comment = lineStr.substr(commentPos);
contents = lineStr.substr(0, commentPos);
}
size_t tabLoc = contents.find('\t');
if (tabLoc == std::string::npos)
return;
std::string pageCode = contents.substr(0, tabLoc);
size_t secondTabLoc = contents.find('\t', tabLoc + 1);
if (secondTabLoc == std::string::npos)
return;
std::string unicodeCode = contents.substr(tabLoc + 1, secondTabLoc - tabLoc);
uint32_t decodedUnicodeCode = ParseHexCode(unicodeCode);
uint32_t decodedCharCode = ParseHexCode(pageCode);
size_t contentOffset = 1;
while (contentOffset < comment.length())
{
const char c = comment[contentOffset];
if (c <= ' ')
contentOffset++;
else
break;
}
g_toUnicode[decodedCharCode] = decodedUnicodeCode;
g_charDescs[decodedCharCode] = comment.substr(contentOffset);
}
int main(int argc, const char **argv)
{
for (int i = 0; i < 256; i++)
{
g_toUnicode[i] = 0xffff;
g_toUpper[i] = i;
g_toLower[i] = i;
g_stripDiacritic[i] = i;
}
FILE *f = nullptr;
if (errno_t err = fopen_s(&f, "MiscData/MacRoman.txt", "rb"))
return err;
std::string currentLine;
while (!feof(f))
{
char c = fgetc(f);
if (c == '\n')
{
ProcessLine(currentLine);
currentLine = "";
}
else
currentLine += c;
}
fclose(f);
// Fill unlisted codes
for (int i = 0; i < 0x20; i++)
g_toUnicode[i] = i;
g_toUnicode[0x11] = 0x2318;
g_toUnicode[0x12] = 0x21e7;
g_toUnicode[0x13] = 0x2325;
g_toUnicode[0x14] = 0x2303;
for (int i = 0; i < 256; i++)
{
bool isSmall = false;
bool isCapital = false;
std::string remainder;
if (ParseLatinDesc(g_charDescs[i], isSmall, isCapital, remainder))
{
for (int j = 0; j < 256; j++)
{
bool otherIsSmall = false;
bool otherIsCapital = false;
std::string otherRemainder = remainder;
if (ParseLatinDesc(g_charDescs[j], otherIsSmall, otherIsCapital, otherRemainder))
{
if (isCapital && otherIsSmall && remainder == otherRemainder)
{
g_toLower[i] = j;
g_toUpper[j] = i;
}
if (isSmall == otherIsSmall && isCapital == otherIsCapital && otherRemainder.length() < remainder.length() && remainder.substr(0, otherRemainder.length()) == otherRemainder)
g_stripDiacritic[i] = j;
}
}
}
}
FILE *outF;
if (errno_t err = fopen_s(&outF, "PortabilityLayer/MacRoman.cpp", "wb"))
return err;
fprintf(outF, "#include \"MacRoman.h\"\n");
fprintf(outF, "\n");
fprintf(outF, "// This file is automatically generated by the ImportCharSet tool. DO NOT MODIFY THIS BY HAND.\n");
fprintf(outF, "namespace PortabilityLayer\n");
fprintf(outF, "{\n");
fprintf(outF, "\tnamespace MacRoman\n");
fprintf(outF, "\t{\n");
DumpListing(outF, g_toUnicode, "0x%04x", "uint16_t g_toUnicode");
fprintf(outF, "\n");
DumpListing(outF, g_toUpper, "0x%02x", "uint8_t g_toUpper");
fprintf(outF, "\n");
DumpListing(outF, g_toLower, "0x%02x", "uint8_t g_toLower");
fprintf(outF, "\n");
DumpListing(outF, g_stripDiacritic, "0x%02x", "uint8_t g_stripDiacritic");
fprintf(outF, "\t}\n");
fprintf(outF, "}\n");
fclose(outF);
return 0;
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{B3D152CB-CD52-4CD6-9213-710ADE1B8EB0}</ProjectGuid>
<RootNamespace>ImportCharSet</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ImportCharSet.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ImportCharSet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>