lang: Use offical system font
10
Makefile
@ -222,16 +222,6 @@ $(OFILES_SRC) : $(HFILES_BIN)
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o %_bin.h : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
#---------------------------------------------------------------------------------
|
||||
%.otf.o %_otf.h : %.otf
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o %_ttf.h : %.ttf
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
Before Width: | Height: | Size: 652 B After Width: | Height: | Size: 4.1 KiB |
BIN
romfs/audio.png
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.9 KiB |
BIN
romfs/check.png
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 3.9 KiB |
BIN
romfs/file.png
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 3.7 KiB |
BIN
romfs/folder.png
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 3.1 KiB |
BIN
romfs/image.png
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 4.5 KiB |
BIN
romfs/text.png
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 4.5 KiB |
@ -1,12 +1,6 @@
|
||||
#include <cstring>
|
||||
#include <switch.h>
|
||||
|
||||
// Font data
|
||||
#include "NotoSans_ttf.h"
|
||||
#include "NotoSansCJKjp_otf.h"
|
||||
#include "NotoSansCJKkr_otf.h"
|
||||
#include "NotoSansCJKsc_otf.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "fs.h"
|
||||
#include "gui.h"
|
||||
@ -133,15 +127,48 @@ namespace Services {
|
||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
|
||||
Result ret = 0;
|
||||
PlFontData standard, s_chinese, t_chinese, korean;
|
||||
if (R_FAILED(ret = plGetSharedFontByType(&standard, PlSharedFontType_Standard))) {
|
||||
Log::Error("plGetSharedFontByType(PlSharedFontType_Standard) failed: 0x%x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = plGetSharedFontByType(&s_chinese, PlSharedFontType_ChineseSimplified))) {
|
||||
Log::Error("plGetSharedFontByType(PlSharedFontType_ChineseSimplified) failed: 0x%x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = plGetSharedFontByType(&t_chinese, PlSharedFontType_ChineseTraditional))) {
|
||||
Log::Error("plGetSharedFontByType(PlSharedFontType_ChineseTraditional) failed: 0x%x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = plGetSharedFontByType(&korean, PlSharedFontType_KO))) {
|
||||
Log::Error("plGetSharedFontByType(PlSharedFontType_KO) failed: 0x%x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned char *pixels = nullptr;
|
||||
int width = 0, height = 0, bpp = 0;
|
||||
ImFontConfig font_cfg;
|
||||
|
||||
font_cfg.FontDataOwnedByAtlas = false;
|
||||
io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t *>(NotoSans_ttf), NotoSans_ttf_size, 35.0f, &font_cfg, io.Fonts->GetGlyphRangesDefault());
|
||||
io.Fonts->AddFontFromMemoryTTF(standard.address, standard.size, 24.0f, &font_cfg, io.Fonts->GetGlyphRangesDefault());
|
||||
font_cfg.MergeMode = true;
|
||||
io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t *>(NotoSansCJKjp_otf), NotoSansCJKjp_otf_size, 35.0f, &font_cfg, io.Fonts->GetGlyphRangesJapanese());
|
||||
io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t *>(NotoSansCJKkr_otf), NotoSansCJKkr_otf_size, 35.0f, &font_cfg, io.Fonts->GetGlyphRangesKorean());
|
||||
io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t *>(NotoSansCJKsc_otf), NotoSansCJKsc_otf_size, 35.0f, &font_cfg, io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||
|
||||
io.Fonts->AddFontFromMemoryTTF(s_chinese.address, s_chinese.size, 24.0f, &font_cfg, io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||
io.Fonts->AddFontFromMemoryTTF(korean.address, korean.size, 24.0f, &font_cfg, io.Fonts->GetGlyphRangesKorean());
|
||||
io.Fonts->AddFontFromMemoryTTF(t_chinese.address, t_chinese.size, 24.0f, &font_cfg, io.Fonts->GetGlyphRangesChineseFull());
|
||||
|
||||
// build font atlas
|
||||
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height, &bpp);
|
||||
io.Fonts->Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;
|
||||
io.Fonts->Build();
|
||||
|
||||
Services::SetDefaultTheme();
|
||||
Textures::Init();
|
||||
plExit();
|
||||
romfsExit();
|
||||
return 0;
|
||||
}
|
||||
@ -184,6 +211,11 @@ namespace Services {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = plInitialize(PlServiceType_User))) {
|
||||
Log::Error("plInitialize(PlServiceType_User) failed: 0x%x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -210,8 +242,9 @@ int main(int, char *argv[]) {
|
||||
|
||||
if (R_FAILED(ret = GUI::RenderLoop()))
|
||||
return ret;
|
||||
|
||||
|
||||
Services::ExitImGui();
|
||||
Services::Exit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -41,9 +41,10 @@ namespace Windows {
|
||||
if (item.entries[i].type == FsDirEntryType_Dir)
|
||||
ImGui::Image(reinterpret_cast<ImTextureID>(folder_icon.id), ImVec2(folder_icon.width, folder_icon.height));
|
||||
else
|
||||
ImGui::Image(reinterpret_cast<ImTextureID>(file_icons[file_type].id), ImVec2(40.0f, 40.0f));
|
||||
ImGui::Image(reinterpret_cast<ImTextureID>(file_icons[file_type].id), ImVec2(file_icons[0].width, file_icons[0].height));
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 4);
|
||||
if (ImGui::Selectable(filename.c_str())) {
|
||||
char path[FS_MAX_PATH + 1];
|
||||
|
||||
|