Skip to content

Commit

Permalink
Prepare for 0.3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
RelativisticMechanic committed Aug 6, 2023
1 parent 40f00dc commit 832de0d
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 35 deletions.
16 changes: 13 additions & 3 deletions src/CRTermConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Windows.h>
#include <iostream>
#include <fstream>
#include "CRTerm.h"
#include "CRTermConfig.h"

std::string GetDefaultConfigJSON()
Expand Down Expand Up @@ -32,10 +33,19 @@ CRTermConfiguration::CRTermConfiguration(std::string json_path)
try
{
configuration_data = nlohmann::json::parse(json_file);
this->font_height = configuration_data.at("font_height");
this->font_width = configuration_data.at("font_width");
this->font_scale = configuration_data.at("font_scale");
this->bitmap_font_file = configuration_data.at("font");
/* If font is a PNG, expect font_height, font_width */
if (endsWith(this->bitmap_font_file, ".png"))
{
this->font_height = configuration_data.at("font_height");
this->font_width = configuration_data.at("font_width");
}
else
{
this->font_height = 0;
this->font_width = 0;
}
this->font_scale = configuration_data.at("font_scale");
this->console_width = configuration_data.at("console_width");
this->console_height = configuration_data.at("console_height");
this->crt_background_image = configuration_data.at("background");
Expand Down
2 changes: 1 addition & 1 deletion src/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Console::Console(CRTermConfiguration* cfg, ConsoleFont* fnt)
this->default_back_color = cfg->default_back_color;
/* Create the character and attribute buffers */
this->buffer = (ConsoleChar*)calloc(this->console_w * this->maxlines, sizeof(ConsoleChar));
this->attrib_buffer = (ConsoleChar*)calloc(this->console_w * this->maxlines, sizeof(ConsoleAttrib));
this->attrib_buffer = (ConsoleAttrib*)calloc(this->console_w * this->maxlines, sizeof(ConsoleAttrib));

/* Load the font and the background image */
this->console_font = fnt;
Expand Down
2 changes: 1 addition & 1 deletion src/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Console

Console(CRTermConfiguration*, ConsoleFont*);
void PlaceChar(int x, int y, ConsoleChar c, int fore_color, int back_color);
unsigned char ReadChar(int x, int y);
ConsoleChar ReadChar(int x, int y);
void PutCharExt(ConsoleChar c, int fore_color, int back_color);
void PutChar(ConsoleChar c);
void Puts(std::string s);
Expand Down
9 changes: 9 additions & 0 deletions src/PNGFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,13 @@ int PNGBitmapFont::GetYAdvance()
GPU_Image* PNGBitmapFont::GetGlyph(ConsoleChar c)
{
return this->characters[c];
}

PNGBitmapFont::~PNGBitmapFont()
{
for (int i = 0; i < 256; i++)
{
GPU_FreeImage(this->characters[i]);
}
GPU_FreeImage(this->font_bitmap);
}
2 changes: 2 additions & 0 deletions src/PNGFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class PNGBitmapFont : public ConsoleFont
{
public:
PNGBitmapFont(std::string filename, int char_width, int char_height);
~PNGBitmapFont();

GPU_Image* GetGlyph(ConsoleChar) override;
int GetXAdvance() override;
int GetYAdvance() override;
Expand Down
9 changes: 7 additions & 2 deletions src/TrueType.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#include "TrueType.h"
#include <iostream>

FreeTypeFont::FreeTypeFont(std::string filename, int size)
{
FT_Error err = FT_Init_FreeType(&ft_lib);

err = FT_New_Face(ft_lib, filename.c_str(), 0, &ft_face);
if (err)
{
std::cerr << "Unable to load TrueType font: " << filename << std::endl;
exit(-1);
}
this->mono_height = size;
this->mono_width = size;

Expand All @@ -27,7 +33,7 @@ FreeTypeFont::FreeTypeFont(std::string filename, int size)
int width = ft_face->glyph->bitmap.width;
/* Center the bitmap horizontally into our fixed size buffer */
int offsetx = (mono_width - width) / 2;
/* Match the botom with the bottom of the fixed size buffer */
/* TODO: Why does this formula work? */
int offsety = (mono_height - ft_face->glyph->bitmap_top - (mono_height / 4));

/* Copy data from source buffer into our fixed size buffer */
Expand All @@ -42,7 +48,6 @@ FreeTypeFont::FreeTypeFont(std::string filename, int size)
{
letter_buf[idx] = val;
}

}
}
/* Create SDL_Surface from bitmap */
Expand Down
2 changes: 0 additions & 2 deletions src/VT100.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ VT100::VT100(CRTermConfiguration* cfg, ConsoleFont* fnt, GPU_Target* render_targ
{
con->Puts("Failed to initialize provided shell application.\n");
}
/* Wait for it to spawn */
Sleep(500);
}

/*
Expand Down
Binary file modified src/crterm.ico
Binary file not shown.
Binary file added src/favicon.ico
Binary file not shown.
Binary file removed src/resources/ProggyClean.ttf
Binary file not shown.
Binary file added src/resources/ProggySquare.ttf
Binary file not shown.
Binary file modified src/resources/UbuntuMono.ttf
Binary file not shown.
4 changes: 1 addition & 3 deletions src/resources/config/default-cmd.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"font": "font.png",
"font_width": 8,
"font_height": 16,
"font": "VGA.ttf",
"font_scale": 1.5,
"console_width": 90,
"console_height": 30,
Expand Down
38 changes: 18 additions & 20 deletions src/resources/config/default-powershell.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"font": "font.png",
"font_width": 8,
"font_height": 16,
"font": "ProggySquare.ttf",
"font_scale": 1.5,
"console_width": 90,
"console_height": 30,
Expand All @@ -11,28 +9,28 @@
"crt_warp": 1.00,
"shell_command": "pwsh.exe -WorkingDirectory ~",
"blink_interval": 300,
"default_fg": 2,
"default_bg": 15,
"default_fg": 3,
"default_bg": 3,
"maxlines": 1000,

"color_scheme":
[
[10, 10, 10],
[0, 0, 85],
[0, 85, 0],
[0, 85, 85],
[85, 0, 0],
[85, 0, 85],
[85, 128, 0],
[80, 80, 80],
[0, 0, 170],
[0, 170, 0],
[0, 170, 170],
[170, 0, 0],
[170, 0, 170],
[170, 128, 0],
[170, 170, 170],
[85, 85, 85],
[42, 42, 42],
[42, 42, 255],
[42, 128, 42],
[42, 128, 128],
[128, 42, 42],
[128, 42, 128],
[128, 128, 0],
[128, 128, 128]
[85, 85, 255],
[85, 255, 85],
[85, 255, 255],
[255, 85, 85],
[255, 85, 255],
[255, 255, 0],
[255, 255, 255]
]
}

2 changes: 0 additions & 2 deletions src/resources/config/default-wsl.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"font": "UbuntuMono.ttf",
"font_width": 8,
"font_height": 16,
"font_scale": 1.5,
"console_width": 90,
"console_height": 30,
Expand Down
2 changes: 1 addition & 1 deletion src/resources/default
Original file line number Diff line number Diff line change
@@ -1 +1 @@
config\default-wsl.json
config\default-powershell.json
Binary file removed src/resources/font8x8.png
Binary file not shown.
Binary file modified src/resources/ui/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 832de0d

Please sign in to comment.