Skip to content

Commit a8fc5fd

Browse files
committed
build atlas from needed characters only
1 parent 5454b80 commit a8fc5fd

22 files changed

+163
-196
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ product_info
2727
libMali*
2828
ss/*
2929
*.tbl
30+
*.dat

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@
4141
[submodule "libs/llusbdac"]
4242
path = libs/llusbdac
4343
url = https://github.com/zhangboyang/llusbdac.git
44+
[submodule "libs/sqlite"]
45+
path = libs/sqlite
46+
url = https://github.com/sqlite/sqlite.git
47+
ignore = dirty

CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ include_directories(
3838
libs/glm
3939
libs/alsa-lib/src/include
4040
libs/mINI/src
41+
libs/sqlite/build-${arch}/install/include
4142
libs
4243
server/armv5-unknown-linux-gnueabihf
4344
${PROTOBUF_INCLUDE}
@@ -152,6 +153,10 @@ target_link_libraries(${PROJECT_NAME} ${ImageMagick_LIBRARIES})
152153
find_library(PROTOBUF protobuf REQUIRED PATHS libs/protobuf/build-${arch}/lib/ REQUIRED)
153154
target_link_libraries(${PROJECT_NAME} "${PROTOBUF}")
154155

156+
set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/libs/sqlite/build-${arch}/install")
157+
find_package(SQLite3 REQUIRED)
158+
target_link_libraries(${PROJECT_NAME} "${SQLite3_LIBRARIES}")
159+
155160
add_custom_target(version
156161
${CMAKE_COMMAND} -D SRC=${CMAKE_SOURCE_DIR}/src/Version.h.in
157162
-D DST=${CMAKE_SOURCE_DIR}/src/Version.h
@@ -163,7 +168,7 @@ add_dependencies(${PROJECT_NAME} version)
163168

164169
if (DESKTOP EQUAL 1)
165170
find_library(GLES GLESv2 PATHS /usr/lib)
166-
target_link_libraries(${PROJECT_NAME} "${GLES}")
171+
target_link_libraries(${PROJECT_NAME} ${GLES})
167172
target_compile_definitions(${PROJECT_NAME} PRIVATE DESKTOP=1)
168173
else ()
169174
set_target_properties(${PROJECT_NAME} PROPERTIES
@@ -173,7 +178,7 @@ else ()
173178

174179
find_library(MALI Mali_linux PATHS libs)
175180
# find_library(ASOUND asound PATHS libs)
176-
target_link_libraries(${PROJECT_NAME} "${MALI}")
181+
target_link_libraries(${PROJECT_NAME} ${MALI})
177182
# target_link_libraries(${PROJECT_NAME} "${ASOUND}")
178183
endif ()
179184

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ RUN apt-get build-dep qtbase5-dev -y && \
1414
RUN ln -s /x-tools/armv5-unknown-linux-gnueabihf/bin/armv5-unknown-linux-gnueabihf-ld /usr/bin/arm-linux-gnueabihf-ld && \
1515
ln -s /x-tools/armv5-unknown-linux-gnueabihf/bin/armv5-unknown-linux-gnueabihf-ld.bfd /usr/bin/arm-linux-gnueabihf-ld.bfd && \
1616
ln -s /x-tools/armv5-unknown-linux-gnueabihf/bin/armv5-unknown-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc && \
17-
ln -s /x-tools/armv5-unknown-linux-gnueabihf/bin/armv5-unknown-linux-gnueabihf-strip /usr/bin/arm-linux-gnueabihf-strip
17+
ln -s /x-tools/armv5-unknown-linux-gnueabihf/bin/armv5-unknown-linux-gnueabihf-strip /usr/bin/arm-linux-gnueabihf-strip
18+
19+
RUN apt-get install tclsh patchelf -y && apt-get clean

MAKING_OF.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ supported at all, it's a guaranteed OOM.
761761
It could've been avoided by providing exact list of characters that will be used. Obtaining such list is relatively
762762
easy: query local song database for all artists and all titles, get unique characters. Most likely it will be your
763763
alphabet, some punctuation and 10-20 characters from foreign languages. The problem is the query - no idea how to do it
764-
quickly.
764+
quickly. After some time I successfully used this approach.
765765
766766
Another workaround is to use another framework like Qt - how do they render all these characters without font atlas with
767767
such ease? But at that point it was too late to switch.

USAGE.md

+1-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* [Wampy is not showing when "Hold" is toggled](#wampy-is-not-showing-when-hold-is-toggled)
88
* [There is no song info](#there-is-no-song-info)
99
* [Notes on ugly settings](#notes-on-ugly-settings)
10-
* [Fonts](#fonts)
1110
* [There is a "detailed info" popup after turning screen off and on instead of Wampy](#there-is-a-detailed-info-popup-after-turning-screen-off-and-on-instead-of-wampy)
1211
* [Everything lags after changing skins/tapes too much](#everything-lags-after-changing-skinstapes-too-much)
1312
* [Using Wampy](#using-wampy)
@@ -49,7 +48,7 @@ points in default player terms).
4948
### ⚠️What to do if device crashes / Wampy doesn't start?⚠️
5049

5150
If Wampy failed to start 3 times (read: device rebooted trice), it stops starting until you edit `wampy/config.ini`.
52-
Remove config file or set `[wampy][badboots]` to 0 (along with device-breaking settings you changed such as fonts) and
51+
Remove config file or set `[wampy][badboots]` to 0 (along with possible device-breaking settings) and
5352
reboot the device. If you cannot access config file (device stuck in boot loop and won't connect to pc, very unlikely
5453
situation), restore it from backup that you made beforehand (see [BACKUP.md](./BACKUP.md)).
5554

@@ -74,23 +73,6 @@ default music player, not SensMe or Language Study.
7473
Due to unfortunate combination of font and framework quirks, all text in settings is placed slightly lower than
7574
expected.
7675

77-
### Fonts
78-
79-
By default, basic latin characters plus various punctuation are used. If your songs have non-latin glyphs in their
80-
artist/title fields, you'll have to toggle on needed character set.
81-
82-
⚠️**WARNING**⚠️
83-
84-
Due to gui framework limitations all characters are loaded into huge texture (font atlas) which is then uploaded to GPU
85-
memory. GPU memory is shared with main memory and usually there is not much left. If you turn on all character sets,
86-
this **will** cause crashes. Generally it is fine to turn on one or two of these. Chinese characters are guaranteed to
87-
crash your device, so they are explicitly disabled.
88-
89-
If crashes occur,
90-
see [What to do if device crashes / Wampy doesn't start?](#what-to-do-if-device-crashes--Wampy-doesnt-start) section.
91-
92-
<img src="images/fonts.png" alt="fonts settings">
93-
9476
### There is a "detailed info" popup after turning screen off and on instead of Wampy
9577

9678
This is the place where current track info is coming from. Toggle Wampy on and off to close it automatically or just

images/fonts.png

-54.2 KB
Binary file not shown.

libs/Makefile

+21-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ libjpeg-turbo/build-arm:
8080
make && make install \
8181
"
8282

83+
sqlite/build-arm:
84+
mkdir -p $@
85+
$(DOCKER) bash -c "\
86+
cd $@ && \
87+
../configure $(ARM_CC) $(ARM_CXX) --host arm-unknown-linux --prefix=`pwd`/$@/install && \
88+
make && make install && patchelf --set-soname libsqlite3.so `pwd`/$@/install/lib/libsqlite3.so \
89+
"
90+
91+
sqlite/build-x86:
92+
mkdir -p $@
93+
$(DOCKER) bash -c "\
94+
cd $@ && \
95+
../configure --prefix=`pwd`/$@/install && \
96+
make && make install && patchelf --set-soname libsqlite3.so `pwd`/$@/install/lib/libsqlite3.so \
97+
"
98+
8399
libEGL.so: libMali_linux.so
84100
ln -s libMali_linux.so libEGL.so
85101

@@ -93,6 +109,8 @@ libjpeg: libjpeg-turbo/build-arm libjpeg-turbo/build-x86
93109

94110
magick: ImageMagick/build-x86 ImageMagick/build-arm
95111

112+
sqlite: sqlite/build-arm sqlite/build-x86
113+
96114
protobuf:
97115
$(DOCKER) bash -c "\
98116
make -f Makefile.protobuf \
@@ -101,16 +119,17 @@ protobuf:
101119
llusbdac:
102120
$(MAKE) -f Makefile.llusbdac
103121

104-
all: patch libEGL.so libGLESv2.so libjpeg magick protobuf llusbdac
122+
all: patch libEGL.so libGLESv2.so libjpeg magick protobuf llusbdac sqlite
105123

106124
clean:
107125
rm -rf libjpeg-turbo/build-*
108126
rm -rf ImageMagick/build-*
109127
rm -rf protobuf/build-*
110128
-make -C protobuf clean
111129
-make -C ImageMagick clean
130+
rm -rf sqlite/build-*
112131

113132

114133
.DEFAULT_GOAL := all
115134

116-
.PHONY: libjpeg-turbo/build-arm libjpeg-turbo/build-x86 protobuf patch llusbdac
135+
.PHONY: libjpeg-turbo/build-arm libjpeg-turbo/build-x86 protobuf patch llusbdac sqlite

libs/sqlite

Submodule sqlite added at 2c76360

src/cassette/cassette.cpp

+8-26
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
#include <sstream>
55
#include <thread>
66

7-
const ImWchar rangesPunctuation[] = {
8-
0x2000,
9-
0x206F, // General Punctuation
10-
0,
11-
};
12-
137
namespace Cassette {
148

159
#ifdef DESKTOP
@@ -72,26 +66,14 @@ namespace Cassette {
7266
gr.clear();
7367

7468
range.AddRanges(io.Fonts->GetGlyphRangesDefault());
75-
range.AddRanges(rangesPunctuation);
76-
range.AddChar(ImWchar(0x266a));
77-
range.AddChar(ImWchar(0x266b));
78-
range.AddChar(ImWchar(0x24c8));
79-
80-
if (fontRanges) {
81-
if (fontRanges->Japanese)
82-
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesJapanese());
83-
if (fontRanges->ChineseFull)
84-
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesChineseFull());
85-
if (fontRanges->Cyrillic)
86-
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
87-
if (fontRanges->Greek)
88-
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesGreek());
89-
if (fontRanges->Korean)
90-
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesKorean());
91-
if (fontRanges->Thai)
92-
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesThai());
93-
if (fontRanges->Vietnamese)
94-
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesVietnamese());
69+
range.AddChar(ImWchar(0x266a)); //
70+
range.AddChar(ImWchar(0x266b)); //
71+
range.AddChar(ImWchar(0x24c8)); //
72+
73+
std::vector<uint32_t> allchars;
74+
getCharRange(&allchars);
75+
for (const auto c : allchars) {
76+
range.AddChar(c);
9577
}
9678

9779
range.BuildRanges(&gr);

src/config.cpp

-26
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,6 @@ namespace AppConfig {
7070
ini["features"]["touchscreenStaysOFF"] = std::to_string(features.touchscreenStaysOFF);
7171
ini["mpd"]["socketPath"] = MPDSocketPath;
7272

73-
#ifdef DESKTOP
74-
ini["fonts"]["chineseFull"] = std::to_string(fontRanges.ChineseFull);
75-
#else
76-
ini["fonts"]["chineseFull"] = std::to_string(false);
77-
#endif
78-
ini["fonts"]["cyrillic"] = std::to_string(fontRanges.Cyrillic);
79-
ini["fonts"]["greek"] = std::to_string(fontRanges.Greek);
80-
ini["fonts"]["japanese"] = std::to_string(fontRanges.Japanese);
81-
ini["fonts"]["korean"] = std::to_string(fontRanges.Korean);
82-
ini["fonts"]["thai"] = std::to_string(fontRanges.Thai);
83-
ini["fonts"]["vietnamese"] = std::to_string(fontRanges.Vietnamese);
84-
8573
ini["w1"]["deviceColor"] = std::to_string(w1Options.deviceColor);
8674

8775
ini["digitalClock"]["color"] = digitalClock.color;
@@ -90,7 +78,6 @@ namespace AppConfig {
9078
void AppConfig::Default() {
9179
cassette.Default();
9280
winamp.Default();
93-
fontRanges = FontRanges{};
9481
digitalClock.Default();
9582

9683
activeSkin = WINAMP;
@@ -170,19 +157,6 @@ namespace AppConfig {
170157
features.limitVolume = (bool)std::atoi(ini["features"]["limitVolume"].c_str());
171158
features.touchscreenStaysOFF = (bool)std::atoi(ini["features"]["touchscreenStaysOFF"].c_str());
172159

173-
#ifdef DESKTOP
174-
fontRanges.ChineseFull = (bool)std::atoi(ini["fonts"]["chineseFull"].c_str());
175-
#else
176-
// device cannot handle full chinese range
177-
fontRanges.ChineseFull = false;
178-
#endif
179-
fontRanges.Cyrillic = (bool)std::atoi(ini["fonts"]["cyrillic"].c_str());
180-
fontRanges.Greek = (bool)std::atoi(ini["fonts"]["greek"].c_str());
181-
fontRanges.Japanese = (bool)std::atoi(ini["fonts"]["japanese"].c_str());
182-
fontRanges.Korean = (bool)std::atoi(ini["fonts"]["korean"].c_str());
183-
fontRanges.Thai = (bool)std::atoi(ini["fonts"]["thai"].c_str());
184-
fontRanges.Vietnamese = (bool)std::atoi(ini["fonts"]["vietnamese"].c_str());
185-
186160
w1Options.deviceColor = std::atoi(ini["w1"]["deviceColor"].c_str());
187161
if (W1::colorByValue.count(w1Options.deviceColor) == 0) {
188162
w1Options.deviceColor = W1::defaultColor;

src/config.h

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "cassette/cassette.h"
55
#include "digital_clock/digital_clock.h"
6-
#include "fontranges.h"
76
#include "mini/ini.h"
87
#include "w1/w1.h"
98
#include "winamp/winamp.h"
@@ -43,7 +42,6 @@ namespace AppConfig {
4342
Features features{};
4443
W1::W1Options w1Options{};
4544
bool debug{};
46-
FontRanges fontRanges;
4745
int badBoots{};
4846
bool limitFPS = false;
4947
std::string forceConnector{};

src/digital_clock/digital_clock.cpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
#include "../skin.h"
33
#include "imgui_impl_opengl3.h"
44

5-
const ImWchar rangesPunctuation[] = {
6-
0x2000,
7-
0x206F, // General Punctuation
8-
0,
9-
};
10-
115
namespace DigitalClock {
126
#ifdef DESKTOP
137
const std::string FontPath = "../NotoSansKR-Regular.otf";
@@ -346,11 +340,13 @@ namespace DigitalClock {
346340
ImVector<ImWchar> gr;
347341
gr.clear();
348342

343+
// no need to pull chars from db, skin has no text
344+
// ascii is enough for settings
345+
349346
range.AddRanges(io.Fonts->GetGlyphRangesDefault());
350-
range.AddRanges(rangesPunctuation);
351-
range.AddChar(ImWchar(0x266a));
352-
range.AddChar(ImWchar(0x266b));
353-
range.AddChar(ImWchar(0x24c8));
347+
range.AddChar(ImWchar(0x266a)); //
348+
range.AddChar(ImWchar(0x266b)); //
349+
range.AddChar(ImWchar(0x24c8)); //
354350

355351
range.BuildRanges(&gr);
356352
*fontRegular = io.Fonts->AddFontFromFileTTF(FontPath.c_str(), fontSizeTTF, nullptr, gr.Data);

src/fontranges.h

-14
This file was deleted.

src/main.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,8 @@ int main(int, char **) {
398398
skin.winamp.connector = connector;
399399
skin.cassette.connector = connector;
400400

401-
skin.winamp.fontRanges = &config.fontRanges;
402-
skin.cassette.fontRanges = &config.fontRanges;
403401
skin.winamp.WithConfig(&config.winamp);
404402
skin.cassette.WithConfig(&config.cassette);
405-
skin.digitalClock.fontRanges = &config.fontRanges;
406403
skin.digitalClock.WithConfig(&config.digitalClock);
407404

408405
connector->clients.push_back(&skin.winamp);

0 commit comments

Comments
 (0)