First phase moving from STBTT to FreeType

This commit is contained in:
2023-05-22 11:25:59 -07:00
parent 4a0c817a1c
commit 8328dba55c
22 changed files with 332 additions and 21 deletions

View File

@@ -36,14 +36,33 @@ target_link_libraries(truetypetool
)
# Tool Function
function(tool_truetype target in)
function(tool_truetype target)
# Defaults
set(FILE "" )
# Parse Args
foreach(_PAIR IN LISTS ARGN)
if (_PAIR MATCHES "^([^:]+)=(.*)$")
set(${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
else()
message(FATAL_ERROR "Invalid pair: ${_PAIR}")
endif()
endforeach()
# Check for missing args
if(NOT DEFINED FILE)
message(FATAL_ERROR "Missing FILE input")
endif()
set(DEPS "")
if(DAWN_BUILD_TOOLS)
set(DEPS truetypetool)
endif()
add_custom_target(${target}
COMMAND truetypetool --input="${DAWN_ASSETS_SOURCE_DIR}/${in}" --output="${DAWN_ASSETS_BUILD_DIR}/${target}"
COMMAND truetypetool
--input="${DAWN_ASSETS_SOURCE_DIR}/${FILE}"
--output="${DAWN_ASSETS_BUILD_DIR}/${target}"
COMMENT "Generating truetype font ${target} from ${in}"
DEPENDS ${DEPS}
)

View File

@@ -56,13 +56,10 @@ int32_t TrueTypeTool::start() {
// Write data
fileOut.writeString(std::to_string(width) + "|" + std::to_string(height) + "|" + std::to_string(fontSize) + "|");
uint8_t pixels[4];
uint8_t pixels[1];
for(size_t i = 0; i < textureSize; i++) {
pixels[0] = 255;
pixels[1] = 255;
pixels[2] = 255;
pixels[3] = bitmapData[i];
fileOut.writeRaw((char*)pixels, 4);
pixels[0] = bitmapData[i];
fileOut.writeRaw((char*)pixels, 1);
}
// Write quads