tsl0922 / mpv-debug-plugin

A debug tool for mpv script developers
GNU General Public License v2.0
19 stars 4 forks source link

Add configuration to set font #1

Closed Youxikong closed 7 months ago

Youxikong commented 9 months ago

The default fonts is lack of CJK fonts now, so my information in Chinease couldn't read. image

tsl0922 commented 9 months ago

It is supported in implay, but dropped in this plugin. I don't think it's a big problem as a developer tool.

imgui doesn't support dynamic font texture yet, loading a cjk font will eat a lot of memory.

tsl0922 commented 7 months ago

It's supported in the latest build.

~~/script-opts/debug.conf

font-path=C:/Windows/Fonts/msyh.ttc
font-size=13
zhongfly commented 5 months ago

It's supported in the latest build.

~~/script-opts/debug.conf

font-path=C:/Windows/Fonts/msyh.ttc
font-size=13

Can you support releative path like ~~/fonts/ ?

I tried this patch, work as expected:

diff --git a/src/main.cpp b/src/main.cpp
index 32fe4a2..138a7be 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -98,7 +98,8 @@ static int gui_thread() {
         io.Fonts->AddFontDefault(&font_cfg);
     } else {
         const ImWchar* unicodeRanges = buildGlyphRanges();
-        io.Fonts->AddFontFromFileTTF(config.fontPath.c_str(), 0, &font_cfg, unicodeRanges);
+        auto fontPath = mp_expand_path(config.fontPath.c_str());
+        io.Fonts->AddFontFromFileTTF(fontPath.c_str(), 0, &font_cfg, unicodeRanges);
     }

     ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
tsl0922 commented 5 months ago

I tried this patch, work as expected

You may want to send a PR for it.