Skip to content

Commit

Permalink
update fonts.
Browse files Browse the repository at this point in the history
  • Loading branch information
wutipong committed Jan 26, 2024
1 parent b57c477 commit d5eea90
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 34 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

[submodule "imgui-filebrowser"]
path = imgui-filebrowser
path = ext/imgui-filebrowser
url = https://github.com/AirGuanZ/imgui-filebrowser
[submodule "ext/IconFontCppHeaders"]
path = ext/IconFontCppHeaders
url = https://github.com/juliettef/IconFontCppHeaders
18 changes: 12 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ add_executable(font-render-tester
"src/texture.cpp"
"src/texture.hpp"
)
target_include_directories(font-render-tester PRIVATE imgui-filebrowser)
target_include_directories(font-render-tester PRIVATE
"ext/imgui-filebrowser"
"ext/IconFontCppHeaders"
)

target_compile_features(font-render-tester PRIVATE cxx_std_23)
set_property(TARGET font-render-tester PROPERTY CXX_STANDARD 23)
Expand Down Expand Up @@ -72,9 +75,12 @@ copy_resources(
TARGET CopyFontFiles
DESTINATION "fonts"
INPUT
"fonts/NotoSans-Regular.ttf"
"fonts/NotoSansThai-Regular.ttf"
"fonts/NotoSansCJKjp-Regular.otf"
"fonts/NotoSansCJKkr-Regular.otf"
"fonts/NotoSansCJKsc-Regular.otf"
"fonts/forkawesome-webfont.ttf"
"fonts/NotoSans-Regular.ttf"
"fonts/NotoSansArabic-Regular.ttf"
"fonts/NotoSansJP-Regular.ttf"
"fonts/NotoSansKR-Regular.ttf"
"fonts/NotoSansSC-Regular.ttf"
"fonts/NotoSansTC-Regular.ttf"
"fonts/NotoSansThai-Regular.ttf"
)
1 change: 1 addition & 0 deletions ext/IconFontCppHeaders
Submodule IconFontCppHeaders added at b24591
4 changes: 2 additions & 2 deletions fonts/NotoSans-Regular.ttf
Git LFS file not shown
4 changes: 2 additions & 2 deletions fonts/NotoSansArabic-Regular.ttf
Git LFS file not shown
3 changes: 0 additions & 3 deletions fonts/NotoSansCJKjp-Regular.otf

This file was deleted.

3 changes: 0 additions & 3 deletions fonts/NotoSansCJKkr-Regular.otf

This file was deleted.

3 changes: 0 additions & 3 deletions fonts/NotoSansCJKsc-Regular.otf

This file was deleted.

3 changes: 3 additions & 0 deletions fonts/NotoSansJP-Regular.ttf
Git LFS file not shown
3 changes: 3 additions & 0 deletions fonts/NotoSansKR-Regular.ttf
Git LFS file not shown
3 changes: 3 additions & 0 deletions fonts/NotoSansSC-Regular.ttf
Git LFS file not shown
3 changes: 3 additions & 0 deletions fonts/NotoSansTC-Regular.ttf
Git LFS file not shown
4 changes: 2 additions & 2 deletions fonts/NotoSansThai-Regular.ttf
Git LFS file not shown
3 changes: 3 additions & 0 deletions fonts/forkawesome-webfont.ttf
Git LFS file not shown
26 changes: 16 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "context.hpp"
#include "io_util.hpp"
#include "main_scene.hpp"
#include "scene.hpp"
#include <IconsForkAwesome.h>
#include <SDL2/SDL.h>
#include <imgui.h>
#include <imgui_impl_sdl2.h>
#include <imgui_impl_sdlrenderer2.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/spdlog.h>

#include "context.hpp"
#include "io_util.hpp"
#include "main_scene.hpp"
#include "scene.hpp"

static constexpr char imguiIni[] = "imgui.ini";
static constexpr char logfile[] = "log.txt";

Expand Down Expand Up @@ -56,16 +56,22 @@ int main(int argc, char **argv) {
ImFontConfig config;
config.MergeMode = true;

io.Fonts->AddFontFromFileTTF("fonts/NotoSansCJKjp-Regular.otf", 20.0f,
&config, io.Fonts->GetGlyphRangesJapanese());
ImWchar iconRangesFK[] = {ICON_MIN_FK, ICON_MAX_FK, 0};
io.Fonts->AddFontFromFileTTF("fonts/forkawesome-webfont.ttf", 20.0f, &config,
iconRangesFK);
io.Fonts->AddFontFromFileTTF("fonts/NotoSansJP-Regular.ttf", 20.0f, &config,
io.Fonts->GetGlyphRangesJapanese());
io.Fonts->AddFontFromFileTTF("fonts/NotoSansThai-Regular.ttf", 20.0f, &config,
io.Fonts->GetGlyphRangesThai());
io.Fonts->AddFontFromFileTTF("fonts/NotoSansCJKkr-Regular.otf", 20.0f,
&config, io.Fonts->GetGlyphRangesKorean());
io.Fonts->AddFontFromFileTTF("fonts/NotoSansKR-Regular.ttf", 20.0f, &config,
io.Fonts->GetGlyphRangesKorean());
io.Fonts->AddFontFromFileTTF(
"fonts/NotoSansCJKsc-Regular.otf", 20.0f, &config,
"fonts/NotoSansSC-Regular.ttf", 20.0f, &config,
io.Fonts->GetGlyphRangesChineseSimplifiedCommon());

io.Fonts->AddFontFromFileTTF("fonts/NotoSansTC-Regular.ttf", 20.0f, &config,
io.Fonts->GetGlyphRangesChineseFull());

io.Fonts->Build();

ImGui_ImplSDL2_InitForSDLRenderer(window, renderer);
Expand Down
9 changes: 7 additions & 2 deletions src/main_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "settings.hpp"
#include "text_renderer.hpp"
#include "version.hpp"
#include <IconsForkAwesome.h>
#include <algorithm>
#include <array>
#include <filesystem>
Expand Down Expand Up @@ -121,7 +122,7 @@ void MainScene::DoUI(Context &context) {
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_MenuBar)) {
if (ImGui::BeginMenuBar()) {
ImGui::LabelText("Font Directory", fontDirPath.c_str());
ImGui::LabelText(ICON_FK_FOLDER " Font Directory", fontDirPath.c_str());
ImGui::EndMenuBar();
}
}
Expand Down Expand Up @@ -358,6 +359,10 @@ void MainScene::DoUI(Context &context) {

ImGui::Text("http://github.com/wutipong/font-render-tester");

ImGui::SeparatorText("Fonts");
ImGui::Text("Fork Awesome");
ImGui::Text("Noto Sans Family");

ImGui::SeparatorText("Dependencies");

ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
Expand All @@ -376,7 +381,7 @@ void MainScene::DoUI(Context &context) {
ImGui::Text("UTF8-CPP");

ImGui::Separator();

if (ImGui::Button("Close")) {
ImGui::CloseCurrentPopup();
}
Expand Down

0 comments on commit d5eea90

Please sign in to comment.