Modules/Sketch3D/CMakeLists.txt
Шурупов Илья Викторович 300a25d4f8 Graphics: Cyrillic fallback fonts so Russian text renders
Cantarell, the regular and bold UI faces, has no Cyrillic. Board cards,
descriptions, Jira imports and every other Russian string arrived as empty
boxes, while the Markdown editor looked fine because its source pane uses
JetBrains Mono, which does have Cyrillic.

FontCyrillic.ttf and FontCyrillicBold.ttf are Cyrillic cuts of Cantarell
0.111 — the upstream release that has Cyrillic — at the two weights, subset
to the Cyrillic blocks plus №. Their x-height and cap height match the
Cantarell 1.004 faces already bundled, and nanovg scales each font by its own
upem, so the two generations sit on one line.

Each text face now has its own fallback chain in CanvasFonts.hpp: bold
Russian falls back to the bold cut instead of the regular one, and the symbol
fonts stay ahead of it in the chain so the arrows, maths and emoji characters
they already covered keep rendering. Mono draws Cyrillic itself and only
needs the cut for the few characters it lacks. LibraryViewer and Sketch3D ship
their own rsc and now copy the two files too.

FontCoverage gained a Russian-alphabet check — board text is data, so the
source-literal scan could not catch this — and a check that every face falls
back to the Cyrillic cut of its own weight. Graphics/rsc/FONTS.md now records
where each bundled font comes from and how the cuts are regenerated.
2026-10-27 12:21:14 +03:00

51 lines
2 KiB
CMake

project(Sketch3D)
find_package(Vulkan REQUIRED)
find_program(GLSLC glslc HINTS ${Vulkan_GLSLC_EXECUTABLE})
if(NOT GLSLC)
set(GLSLC ${Vulkan_GLSLC_EXECUTABLE})
endif()
set(SHADER_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/shaders_generated)
file(MAKE_DIRECTORY ${SHADER_GEN_DIR})
set(SHADER_INCS "")
foreach(SHADER stroke.vert stroke.geom stroke.frag)
add_custom_command(
OUTPUT ${SHADER_GEN_DIR}/${SHADER}.inc
COMMAND ${GLSLC} -O --target-env=vulkan1.0 -mfmt=c
${CMAKE_CURRENT_SOURCE_DIR}/shaders/${SHADER} -o ${SHADER_GEN_DIR}/${SHADER}.inc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/shaders/${SHADER}
COMMENT "Compiling ${SHADER} to SPIR-V"
VERBATIM
)
list(APPEND SHADER_INCS ${SHADER_GEN_DIR}/${SHADER}.inc)
endforeach()
add_custom_target(Sketch3DShaders DEPENDS ${SHADER_INCS})
### ---------------------- Externals --------------------- ###
set(BINDINGS_INCLUDE)
set(BINDINGS_LIBS Imgui)
### ---------------------- Static Library --------------------- ###
file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp")
file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp")
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
add_dependencies(${PROJECT_NAME} Sketch3DShaders)
target_include_directories(${PROJECT_NAME} PUBLIC ./public/ ${BINDINGS_INCLUDE} ./ext/)
target_include_directories(${PROJECT_NAME} PRIVATE ./private/ ${SHADER_GEN_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC Graphics Connection WidgetsApp Math RasterRender Vulkan::Vulkan)
target_link_libraries(${PROJECT_NAME} PUBLIC ${BINDINGS_LIBS})
### -------------------------- Applications -------------------------- ###
add_executable(Sketch3DApp ./applications/Entry.cpp)
target_link_libraries(Sketch3DApp ${PROJECT_NAME})
file(COPY "rsc" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/")
file(COPY "applications/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/rsc")
# Canvas falls back to these for Cyrillic text; see Graphics/rsc/FONTS.md.
file(COPY "../Graphics/rsc/FontCyrillic.ttf" "../Graphics/rsc/FontCyrillicBold.ttf"
DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/rsc")