Skip to content

Commit c8514b2

Browse files
authored
Split out font code into sindarin-inc/tiny-font (#1151)
1 parent ab55eee commit c8514b2

File tree

413 files changed

+103
-34674
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+103
-34674
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
[submodule "components/astubs"]
1717
path = components/astubs
1818
url = git@github.com:sindarin-inc/astubs.git
19-
[submodule "components/freetype/freetype"]
20-
path = components/freetype/freetype
21-
url = git@github.com:sindarin-inc/freetype.git
2219
[submodule "lib/mbedtls"]
2320
path = lib/mbedtls
2421
url = https://github.com/Mbed-TLS/mbedtls.git
22+
[submodule "components/tiny-font"]
23+
path = components/tiny-font
24+
url = git@github.com:sindarin-inc/tiny-font.git

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ endif
4242
IDF_PROFILE = -B build-$(TARGET) -DSDKCONFIG_DEFAULTS="$(SDKCONFIG_DEFAULTS)"
4343

4444
# Optional variables for the Simulator builds
45-
CMAKE_SIM_DISPLAY_OPTIONS := $(if $(DISPLAY_WIDTH),-DDISPLAY_WIDTH=$(DISPLAY_WIDTH)) $(if $(DISPLAY_HEIGHT),-DDISPLAY_HEIGHT=$(DISPLAY_HEIGHT)) $(if $(DISPLAY_SCALE),-DDISPLAY_SCALE=$(DISPLAY_SCALE)) $(if $(SIM_LAYOUT_DEBUG),-DSIM_LAYOUT_DEBUG=$(SIM_LAYOUT_DEBUG)) $(if $(DISPLAY_TYPE),-DDISPLAY_TYPE=$(DISPLAY_TYPE)) $(if $(TTF_SCREEN_RES_PER_INCH),-DTTF_SCREEN_RES_PER_INCH=$(TTF_SCREEN_RES_PER_INCH))
45+
CMAKE_SIM_DISPLAY_OPTIONS := $(if $(DISPLAY_WIDTH),-DDISPLAY_WIDTH=$(DISPLAY_WIDTH)) $(if $(DISPLAY_HEIGHT),-DDISPLAY_HEIGHT=$(DISPLAY_HEIGHT)) $(if $(DISPLAY_SCALE),-DDISPLAY_SCALE=$(DISPLAY_SCALE)) $(if $(SIM_LAYOUT_DEBUG),-DSIM_LAYOUT_DEBUG=$(SIM_LAYOUT_DEBUG)) $(if $(DISPLAY_TYPE),-DDISPLAY_TYPE=$(DISPLAY_TYPE)) $(if $(TTF_SCREEN_RES_PER_INCH),-DCONFIG_TINYFONT_DISPLAY_DPI=$(TTF_SCREEN_RES_PER_INCH))
4646

4747
.PHONY: sim-build
4848
sim-build:

components/freetype/CMakeLists.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

components/freetype/freetype

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/tiny-font

Submodule tiny-font added at 72fee05

lib/Simulator/Common/CMakeLists.txt

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ add_subdirectory(${REPO_ROOT_DIR}/components/miniz ${CMAKE_CURRENT_BINARY_DIR}/m
4343

4444
add_subdirectory(${REPO_ROOT_DIR}/components/Adafruit-GFX-Library ${CMAKE_CURRENT_BINARY_DIR}/Adafruit-GFX-Library)
4545

46+
add_subdirectory(${REPO_ROOT_DIR}/components/tiny-font ${CMAKE_CURRENT_BINARY_DIR}/tiny-font)
47+
48+
# Conditionally link freetype if we're using 8-bit or 16-bit display
49+
if(DISPLAY_TYPE STREQUAL "DISPLAY_SIM_24BIT" OR DISPLAY_TYPE STREQUAL "DISPLAY_SIM_16BIT" OR DISPLAY_TYPE STREQUAL "DISPLAY_SIM_8BIT")
50+
# Set FreeType options before adding the subdirectory
51+
set(FT_DISABLE_PNG ON CACHE BOOL "Disable PNG support in FreeType" FORCE)
52+
set(FT_DISABLE_HARFBUZZ ON CACHE BOOL "Disable HarfBuzz support in FreeType" FORCE)
53+
set(FT_DISABLE_BROTLI ON CACHE BOOL "Disable Brotli support in FreeType" FORCE)
54+
add_subdirectory(${REPO_ROOT_DIR}/components/tiny-font/freetype/freetype ${CMAKE_CURRENT_BINARY_DIR}/freetype)
55+
target_link_libraries(tiny-font PUBLIC freetype)
56+
target_compile_definitions(tiny-font PUBLIC
57+
CONFIG_TINYFONT_TTF=1
58+
CONFIG_TINYFONT_IBMF=0
59+
CONFIG_TINYFONT_DISPLAY_DPI=${TTF_SCREEN_RES_PER_INCH}
60+
)
61+
else()
62+
target_compile_definitions(tiny-font PUBLIC
63+
CONFIG_TINYFONT_TTF=0
64+
CONFIG_TINYFONT_IBMF=1
65+
)
66+
endif()
67+
4668
add_subdirectory(${REPO_ROOT_DIR}/lib/esp_ringbuf ${CMAKE_CURRENT_BINARY_DIR}/esp_ringbuf)
4769

4870
# Before adding mbedtls, set options to disable tests and programs
@@ -59,7 +81,7 @@ endif()
5981

6082
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HTTP_CLIENT_SOURCE})
6183

62-
target_link_libraries(${PROJECT_NAME} PUBLIC pugixml ArduinoJson miniz astubs esp-idf-stubs nvs_flash Adafruit-GFX-Library mbedtls mbedx509 mbedcrypto esp_ringbuf)
84+
target_link_libraries(${PROJECT_NAME} PUBLIC pugixml ArduinoJson miniz astubs esp-idf-stubs nvs_flash Adafruit-GFX-Library tiny-font mbedtls mbedx509 mbedcrypto esp_ringbuf)
6385

6486
target_include_directories(${PROJECT_NAME} PUBLIC
6587
"${REPO_ROOT_DIR}/src"
@@ -71,46 +93,42 @@ target_include_directories(${PROJECT_NAME} PUBLIC
7193
"${REPO_ROOT_DIR}/lib/argparse"
7294
)
7395

74-
# Conditionally link freetype if we're using 8-bit or 16-bit display
75-
if(DISPLAY_TYPE STREQUAL "DISPLAY_SIM_24BIT" OR DISPLAY_TYPE STREQUAL "DISPLAY_SIM_16BIT" OR DISPLAY_TYPE STREQUAL "DISPLAY_SIM_8BIT")
76-
# Set FreeType options before adding the subdirectory
77-
set(FT_DISABLE_PNG ON CACHE BOOL "Disable PNG support in FreeType" FORCE)
78-
set(FT_DISABLE_HARFBUZZ ON CACHE BOOL "Disable HarfBuzz support in FreeType" FORCE)
79-
set(FT_DISABLE_BROTLI ON CACHE BOOL "Disable Brotli support in FreeType" FORCE)
80-
add_subdirectory(${REPO_ROOT_DIR}/components/freetype/freetype ${CMAKE_CURRENT_BINARY_DIR}/freetype)
81-
target_link_libraries(${PROJECT_NAME} PUBLIC freetype)
82-
target_compile_definitions(${PROJECT_NAME} PUBLIC
83-
CONFIG_FONT_TTF=1
84-
CONFIG_FONT_IBMF=0
85-
)
86-
else()
87-
target_compile_definitions(${PROJECT_NAME} PUBLIC
88-
CONFIG_FONT_TTF=0
89-
CONFIG_FONT_IBMF=1
90-
)
91-
endif()
92-
9396
# Set compile definitions based on the selected DISPLAY_TYPE
9497
if(DISPLAY_TYPE STREQUAL "DISPLAY_SIM_24BIT")
9598
target_compile_definitions(${PROJECT_NAME} PUBLIC
9699
CONFIG_DISPLAY_SIM_24BIT=1
97100
)
101+
target_compile_definitions(tiny-font PUBLIC
102+
CONFIG_TINYFONT_PIXEL_RESOLUTION_TWENTY_FOUR_BIT=1
103+
)
98104
elseif(DISPLAY_TYPE STREQUAL "DISPLAY_SIM_16BIT")
99105
target_compile_definitions(${PROJECT_NAME} PUBLIC
100106
CONFIG_DISPLAY_SIM_16BIT=1
101107
)
108+
target_compile_definitions(tiny-font PUBLIC
109+
CONFIG_TINYFONT_PIXEL_RESOLUTION_SIXTEEN_BIT=1
110+
)
102111
elseif(DISPLAY_TYPE STREQUAL "DISPLAY_SIM_8BIT")
103112
target_compile_definitions(${PROJECT_NAME} PUBLIC
104113
CONFIG_DISPLAY_SIM_8BIT=1
105114
)
115+
target_compile_definitions(tiny-font PUBLIC
116+
CONFIG_TINYFONT_PIXEL_RESOLUTION_EIGHT_BIT=1
117+
)
106118
elseif(DISPLAY_TYPE STREQUAL "DISPLAY_SIM_1BIT")
107119
target_compile_definitions(${PROJECT_NAME} PUBLIC
108120
CONFIG_DISPLAY_SIM_1BIT=1
109121
)
122+
target_compile_definitions(tiny-font PUBLIC
123+
CONFIG_TINYFONT_PIXEL_RESOLUTION_ONE_BIT=1
124+
)
110125
elseif(DISPLAY_TYPE STREQUAL "DISPLAY_EINKET013TT1")
111126
target_compile_definitions(${PROJECT_NAME} PUBLIC
112127
CONFIG_DISPLAY_EINKET013TT1=1
113128
)
129+
target_compile_definitions(tiny-font PUBLIC
130+
CONFIG_TINYFONT_PIXEL_RESOLUTION_ONE_BIT=1
131+
)
114132
else()
115133
message(FATAL_ERROR "Invalid DISPLAY_TYPE: ${DISPLAY_TYPE}")
116134
endif()
@@ -145,7 +163,6 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC
145163
CONFIG_DISABLE_POWER_MANAGEMENT=1
146164
RTC_SLOW_ATTR=
147165
RTC_NOINIT_ATTR=
148-
CONFIG_TTF_SCREEN_RES_PER_INCH=${TTF_SCREEN_RES_PER_INCH}
149166
CONFIG_DEFAULT_INACTIVITY_MINUTES=10
150167
CONFIG_DISPLAY_POWER=-1
151168
CONFIG_DISPLAY_WIDTH=${DISPLAY_WIDTH}

scripts/epub-render/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "DisplayUtil.hpp"
1414
#include "EPub/EPubFile.hpp"
1515
#include "Renderers/Renderer.hpp"
16-
#include "UI/Fonts/Fonts.hpp"
16+
#include "UI/Fonts.hpp"
1717

1818
int main(int argc, char **argv) {
1919
argparse::ArgumentParser program("epub-render");

sdkconfig.defaults.p4-function-ev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
# Espressif IoT Development Framework (ESP-IDF) 5.5.0 Project Minimal Configuration
33
#
44
CONFIG_DISPLAY_ESP32_P4_FUNCTION_EV=y
5+
CONFIG_TINYFONT_TTF=y
6+
CONFIG_TINYFONT_PIXEL_RESOLUTION_SIXTEEN_BIT=y

sdkconfig.defaults.p4-function-ev-r0

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Espressif IoT Development Framework (ESP-IDF) 5.5.0 Project Minimal Configuration
33
#
44
CONFIG_DISPLAY_ESP32_P4_FUNCTION_EV_R0=y
5+
CONFIG_TINYFONT_TTF=y
6+
CONFIG_TINYFONT_PIXEL_RESOLUTION_SIXTEEN_BIT=y
57
CONFIG_ESP32P4_REV_MIN_0=y
68
CONFIG_ESP_HOSTED_SDIO_PIN_D0=49
79
# NOTE: This doesn't take from the defaults for some reason and needs to be set manually from menuconfig

sdkconfig.defaults.p4-seeya049

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
# Espressif IoT Development Framework (ESP-IDF) 5.5.0 Project Minimal Configuration
33
#
44
CONFIG_DISPLAY_ESP32_P4_SEEYA_049=y
5+
CONFIG_TINYFONT_TTF=y
6+
CONFIG_TINYFONT_PIXEL_RESOLUTION_TWENTY_FOUR_BIT=y

0 commit comments

Comments
 (0)