Skip to content

Commit

Permalink
Remove harfbuzz as it's not capable of running on micro memory systems
Browse files Browse the repository at this point in the history
Harfbuzz's FreeType integration is written to load the entire font into
memory. I wanted Harfbuzz as a drop-in solution for substitution of
emoji sequences, which are stored in the 9MB NotoColorEmoji font
currently. This won't work without significant modification to Harfbuzz,
so I'll need a different solution to achieve ZWJ sequences.

Looks like we'll need to look up the GSUB table on our own to do this 🕶
  • Loading branch information
stecman committed Jul 31, 2022
1 parent 7939ccd commit ceee3ae
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 61 deletions.
18 changes: 1 addition & 17 deletions firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ set(FETCHCONTENT_QUIET FALSE)

# Source dependencies
FetchContent_Declare(freetype URL https://download.savannah.gnu.org/releases/freetype/freetype-2.12.1.tar.gz)
FetchContent_Declare(harfbuzz URL https://github.com/harfbuzz/harfbuzz/releases/download/3.4.0/harfbuzz-3.4.0.tar.xz)
FetchContent_Declare(libpng URL https://cytranet.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.xz)
FetchContent_Declare(unicode_blocks URL https://unicode.org/Public/UNIDATA/Blocks.txt DOWNLOAD_NO_EXTRACT TRUE)
FetchContent_Declare(unicode_codepoints URL https://unicode.org/Public/UNIDATA/UnicodeData.txt DOWNLOAD_NO_EXTRACT TRUE)
Expand Down Expand Up @@ -96,18 +95,6 @@ set(PNG_INCLUDE_DIRS ${libpng_SOURCE_DIR} ${libpng_BINARY_DIR} CACHE INTERNAL ""
add_subdirectory(${freetype_SOURCE_DIR} ${freetype_BINARY_DIR} EXCLUDE_FROM_ALL)


# harfbuzz
FetchContent_GetProperties(harfbuzz)
if(NOT harfbuzz_POPULATED)
FetchContent_Populate(harfbuzz)
endif()

set(CMAKE_DISABLE_FIND_PACKAGE_Threads TRUE CACHE INTERNAL "Prevent Harfbuzz from looking for a threading library")

add_subdirectory(${harfbuzz_SOURCE_DIR} ${harfbuzz_BINARY_DIR} EXCLUDE_FROM_ALL)
target_compile_options(harfbuzz PUBLIC -DHB_TINY -Wno-format)


#
# Support embedding resources in the binary (GCC-specific)
# Based on https://stackoverflow.com/a/56006001/1470907
Expand Down Expand Up @@ -181,7 +168,6 @@ set(DEVICE_SOURCES

set(FIRMWARE_LIBS
freetype
harfbuzz
pico_stdlib
png_static
zlibstatic
Expand Down Expand Up @@ -227,16 +213,14 @@ endif()
# Explicitly select targets to build from libpng and zlib (since we're EXCLUDE_FROM_ALL)
add_dependencies(png_static zlibstatic)
add_dependencies(freetype png_static zlibstatic)
add_dependencies(harfbuzz freetype)
add_dependencies(firmware png_static zlibstatic freetype harfbuzz)
add_dependencies(firmware png_static zlibstatic freetype)

target_include_directories(firmware PRIVATE
${libpng_SOURCE_DIR}
${libpng_BINARY_DIR}
${zlib_SOURCE_DIR}
${zlib_BINARY_DIR}
${FREETYPE_INCLUDE_DIRS}
${harfbuzz_SOURCE_DIR}/src # not ideal, but the harfbuzz public headers aren't exposed anywhere
)

target_link_libraries(firmware ${FIRMWARE_LIBS})
Expand Down
44 changes: 0 additions & 44 deletions firmware/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#include <freetype/ftoutln.h>
#include <freetype/internal/ftobjs.h>

// Harfbuzz
#include <hb.h>
#include <hb-ft.h>

// C++
#include <algorithm>
#include <cmath>
Expand Down Expand Up @@ -136,46 +132,6 @@ bool FontStore::drawGlyph(uint32_t codepoint, int adjust_y)
return false;
}

// {
// hb_buffer_t *buf;
// buf = hb_buffer_create();
// // hb_buffer_add_utf8(buf, "\U0001f3c3\u200d\U0001f3fe", -1, 0, -1);
// // hb_buffer_add_utf8(buf, "\u2764\uFE0F\u200D\U0001F525", -1, 0, -1);
// hb_buffer_add_utf8(buf, "\U0001F3F4\u200D\u2620\uFE0F", -1, 0, -1);

// hb_buffer_set_direction(buf, HB_DIRECTION_LTR);
// hb_buffer_set_script(buf, HB_SCRIPT_COMMON);
// hb_buffer_set_language(buf, hb_language_get_default());

// hb_font_t *font = hb_ft_font_create(m_face, noop_destroy_func);

// hb_shape(font, buf, NULL, 0);

// unsigned int glyph_count;
// hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count);
// hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &glyph_count);

// hb_position_t cursor_x = 0;
// hb_position_t cursor_y = 0;
// for (unsigned int i = 0; i < glyph_count; i++) {
// hb_codepoint_t glyphid = glyph_info[i].codepoint;
// hb_position_t x_offset = glyph_pos[i].x_offset;
// hb_position_t y_offset = glyph_pos[i].y_offset;
// hb_position_t x_advance = glyph_pos[i].x_advance;
// hb_position_t y_advance = glyph_pos[i].y_advance;

// /* draw_glyph(glyphid, cursor_x + x_offset, cursor_y + y_offset); */

// // printf(" glyph: %d\n", glyphid);

// cursor_x += x_advance;
// cursor_y += y_advance;
// }

// hb_buffer_destroy(buf);
// hb_font_destroy(font);
// }

FT_Error error;
int width = 0;
int height = 0;
Expand Down

0 comments on commit ceee3ae

Please sign in to comment.