Updated the editor UI font

Gui_Panel_Refactor
Joeyrp 4 years ago
parent 97db356d66
commit 18ce0d4375

@ -23,6 +23,7 @@ Core:
✔ Refactor the drawing code to allow for rotation with cleaner code @high @done (10/29/2021, 8:36:24 PM)
✔ Test rotation of images @done (11/1/2021, 2:11:13 PM)
☐ Fix line rotation @low
✔ Add Roboto-Regular.ttf as an internal font @high @done (11/3/2021, 8:35:51 PM)
GUI:

@ -0,0 +1,18 @@
font_file = open("Roboto-Regular.ttf", "rb")
raw_bytes = font_file.read()
font_file.close()
cfile = open("robotoFontData.h", "w")
cfile.write("\nnamespace lunarium\n{\n\tconst int RobotoDataSize = ")
cfile.write(str(len(raw_bytes)))
cfile.write(";\n\tconst unsigned char RobotoFontData[] =\n{\n\t")
cfile.write("(unsigned char)" + str(raw_bytes[0]))
for i,b in enumerate(raw_bytes[1:]):
cfile.write(",")
if i % 20 == 0:
cfile.write("\n\t")
cfile.write("(unsigned char)" + str(b))
cfile.write("\n};}")
cfile.close()

Binary file not shown.

@ -8,13 +8,14 @@
******************************************************************************/
#include "internalFont.h"
#include "internalFontData.h"
#include "openFontData.h"
#include "robotoFontData.h"
#include <utils/logger.h>
#include <fstream>
namespace lunarium
{
bool GenerateFontFileAt(const char * filename)
bool GenerateFontFileAt(Font font, const char * filename)
{
std::ofstream ofs(filename, std::ios_base::binary);
@ -25,7 +26,17 @@ namespace lunarium
}
ofs.write((const char*)FontData, DataSize);
switch (font)
{
case Font::F_OPEN:
ofs.write((const char*)OpenFontData, OpenDataSize);
break;
case Font::F_ROBOTO:
ofs.write((const char*)RobotoFontData, RobotoDataSize);
break;
}
ofs.close();
ofs.clear();

@ -12,7 +12,12 @@
namespace lunarium
{
bool GenerateFontFileAt(const char* filename);
enum Font
{
F_OPEN,
F_ROBOTO,
};
bool GenerateFontFileAt(Font font, const char* filename);
}
#endif // INTERNAL_FONT_H_

@ -6,8 +6,8 @@
namespace lunarium
{
const int DataSize = 217360;
const unsigned char FontData[] =
const int OpenDataSize = 217360;
const unsigned char OpenFontData[] =
{
(unsigned char)0,
(unsigned char)1,(unsigned char)0,(unsigned char)0,(unsigned char)0,(unsigned char)19,(unsigned char)1,(unsigned char)0,(unsigned char)0,(unsigned char)4,(unsigned char)0,(unsigned char)48,(unsigned char)68,(unsigned char)83,(unsigned char)73,(unsigned char)71,(unsigned char)158,(unsigned char)18,(unsigned char)68,(unsigned char)29,(unsigned char)0,

@ -10,7 +10,7 @@
#include "defaultShaders.h"
#include <window/window.h>
#include <assets/types/image.h>
#include "../internalFontData.h"
#include "../openFontData.h"
#include <utils/logger.h>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
@ -85,7 +85,7 @@ namespace lunarium
// Load the default internal font
const char* font = "OpenSans-Regular.ttf";
// GenerateFontFileAt(font);
mDefaultFont = mText.LoadFont(FontData, DataSize, font);
mDefaultFont = mText.LoadFont(OpenFontData, OpenDataSize, font);
if (mDefaultFont < 0)
{
Logger::Log(LogCategory::GRAPHICS, LogLevel::WARNING, "Unable to load the default font: %s", font);

File diff suppressed because it is too large Load Diff

@ -57,8 +57,10 @@ namespace lunarium
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
// NOTE: Generating a font file for now. Late might look into loading directly from memory
GenerateFontFileAt("open.ttf");
io.Fonts->AddFontFromFileTTF("open.ttf", 16.0f);
GenerateFontFileAt(Font::F_ROBOTO, "robo.ttf");
//io.Fonts->AddFontFromFileTTF("open.ttf", 16.0f);
io.Fonts->AddFontFromFileTTF("robo.ttf", 18.0f);
//io.Fonts->AddFontFromFileTTF("Karla-Regular.ttf", 16.0f);
// Setup Dear ImGui style
ImGui::StyleColorsDark();

Loading…
Cancel
Save