Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- x64-windows-static
- x86-windows-static
- arm64-windows-static
runs-on: windows-latest
runs-on: windows-2022
env:
VCPKG_DEFAULT_TRIPLET: ${{matrix.triplet}}
VCPKG_DEFAULT_HOST_TRIPLET: ${{startsWith(matrix.triplet, 'arm64-') && 'x64-windows-static-md' || matrix.triplet}}
Expand Down Expand Up @@ -221,7 +221,7 @@ jobs:
- x64-windows-static
- x86-windows-static
- arm64-windows-static
runs-on: windows-latest
runs-on: windows-2022
needs: deps-windows
env:
VCPKG_DEFAULT_TRIPLET: ${{matrix.triplet}}
Expand Down Expand Up @@ -326,7 +326,7 @@ jobs:
build/*.log

windows-ninja-clang-x86-64:
runs-on: windows-latest
runs-on: windows-2022
needs: deps-windows
env:
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
Expand Down Expand Up @@ -364,7 +364,7 @@ jobs:
build/*.log

windows-vs-x86:
runs-on: windows-latest
runs-on: windows-2022
needs: deps-windows
env:
VCPKG_DEFAULT_TRIPLET: x86-windows-static-md
Expand Down Expand Up @@ -429,7 +429,7 @@ jobs:
build/*.log

windows-vs-clangcl-x86_64:
runs-on: windows-latest
runs-on: windows-2022
needs: deps-windows
env:
VCPKG_DEFAULT_TRIPLET: x64-windows-static
Expand Down Expand Up @@ -499,7 +499,7 @@ jobs:
build/*.log

macos-ninja-clang-x86_64:
runs-on: macos-13
runs-on: macos-15-intel
needs: deps-macos
env:
VCPKG_DEFAULT_TRIPLET: x64-osx
Expand Down Expand Up @@ -647,7 +647,7 @@ jobs:
- x64-windows-static
- x86-windows-static
- arm64-windows-static
runs-on: windows-latest
runs-on: windows-2022
needs: build-windows
steps:
- name: Download artifacts
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ endif ()
install(
TARGETS
brisk-core
brisk-text-engine
brisk-graphics
brisk-network
brisk-window
Expand Down
29 changes: 29 additions & 0 deletions cmake/ports/dawn/abseil-apple-architecture.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake b/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake
index 9a88c9e9f..000000000 100644
--- a/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake
+++ b/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake
@@ -40,10 +40,16 @@ if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES [[Clang]])
set(ABSL_RANDOM_RANDEN_COPTS "")
- foreach(_arch IN ITEMS "x86_64" "arm64")
- string(TOUPPER "${_arch}" _arch_uppercase)
- string(REPLACE "X86_64" "X64" _arch_uppercase ${_arch_uppercase})
- foreach(_flag IN LISTS ABSL_RANDOM_HWAES_${_arch_uppercase}_FLAGS)
- list(APPEND ABSL_RANDOM_RANDEN_COPTS "-Xarch_${_arch}" "${_flag}")
- endforeach()
- endforeach()
+ if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
+ set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_X64_FLAGS}")
+ elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
+ set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM64_FLAGS}")
+ else()
+ foreach(_arch IN ITEMS "x86_64" "arm64")
+ string(TOUPPER "${_arch}" _arch_uppercase)
+ string(REPLACE "X86_64" "X64" _arch_uppercase ${_arch_uppercase})
+ foreach(_flag IN LISTS ABSL_RANDOM_HWAES_${_arch_uppercase}_FLAGS)
+ list(APPEND ABSL_RANDOM_RANDEN_COPTS "-Xarch_${_arch}" "${_flag}")
+ endforeach()
+ endforeach()
+ endif()
# If a compiler happens to deal with an argument for a currently unused
# architecture, it will warn about an unused command line argument.
option(ABSL_RANDOM_RANDEN_COPTS_WARNING OFF
5 changes: 5 additions & 0 deletions cmake/ports/dawn/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ vcpkg_add_to_path("${GIT_EXE_PATH}")
execute_process(COMMAND ${PYTHON3} tools/fetch_dawn_dependencies.py
WORKING_DIRECTORY ${SOURCE_PATH})

vcpkg_apply_patches(
SOURCE_PATH "${SOURCE_PATH}"
PATCHES abseil-apple-architecture.patch
)

set(DESKTOP_GL OFF)
set(USE_WAYLAND OFF)
if (VCPKG_TARGET_IS_LINUX)
Expand Down
28 changes: 28 additions & 0 deletions cmake/ports/sheenbidi/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Tehreer/SheenBidi
REF "v${VERSION}"
SHA512 67c8ef7bea9fc677fbb83601403b40bcc274842597df53a699fd5758f4f170ac5d1fc9a719d590da25f6a72769fe59a2a1cf57e54f0ef6859561bfb77c0c72c4
)

vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
"text-api" SB_CONFIG_EXPERIMENTAL_TEXT_API
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DSB_CONFIG_UNITY=ON
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SheenBidi)
vcpkg_fixup_pkgconfig()
vcpkg_copy_pdbs()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
22 changes: 22 additions & 0 deletions cmake/ports/sheenbidi/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "sheenbidi",
"version": "3.0.0",
"description": "SheenBidi is a lightweight, fast and stable implementation of the Unicode Bidirectional Algorithm.",
"homepage": "https://github.com/Tehreer/SheenBidi",
"license": "Apache-2.0",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"text-api": {
"description": "Enable the experimental text editing and analysis API"
}
}
}
25 changes: 19 additions & 6 deletions cmake/toolchains/linux.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
if (NOT _VCPKG_LINUX_TOOLCHAIN_OVERRIDE)
set(_VCPKG_LINUX_TOOLCHAIN_OVERRIDE 1)

if (Z_VCPKG_ROOT_DIR)
include(${Z_VCPKG_ROOT_DIR}/scripts/toolchains/linux.cmake)
else()
include(${_VCPKG_ROOT_DIR}/scripts/toolchains/linux.cmake)
endif()

# Prefer the root discovered by the vcpkg toolchain. Keep the environment
# and cache-variable fallbacks for older vcpkg versions and standalone use.
if (DEFINED Z_VCPKG_ROOT_DIR AND NOT "${Z_VCPKG_ROOT_DIR}" STREQUAL "")
set(_BRISK_VCPKG_ROOT_DIR "${Z_VCPKG_ROOT_DIR}")
elseif (DEFINED ENV{VCPKG_ROOT} AND NOT "$ENV{VCPKG_ROOT}" STREQUAL "")
file(TO_CMAKE_PATH "$ENV{VCPKG_ROOT}" _BRISK_VCPKG_ROOT_DIR)
elseif (DEFINED VCPKG_ROOT AND NOT "${VCPKG_ROOT}" STREQUAL "")
set(_BRISK_VCPKG_ROOT_DIR "${VCPKG_ROOT}")
elseif (DEFINED _VCPKG_ROOT_DIR AND NOT "${_VCPKG_ROOT_DIR}" STREQUAL "")
set(_BRISK_VCPKG_ROOT_DIR "${_VCPKG_ROOT_DIR}")
endif ()

if (NOT EXISTS "${_BRISK_VCPKG_ROOT_DIR}/scripts/toolchains/linux.cmake")
message(FATAL_ERROR "Could not locate the vcpkg Linux toolchain. Set VCPKG_ROOT or use a vcpkg toolchain that defines Z_VCPKG_ROOT_DIR.")
endif ()

include("${_BRISK_VCPKG_ROOT_DIR}/scripts/toolchains/linux.cmake")

string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -g0 -DNDEBUG -O3 ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -g0 -DNDEBUG -O3 ")
Expand All @@ -32,4 +44,5 @@ if (NOT _VCPKG_LINUX_TOOLCHAIN_OVERRIDE)
"${CMAKE_CXX_FLAGS_DEBUG_INIT}"
CACHE STRING "" FORCE)

unset(_BRISK_VCPKG_ROOT_DIR)
endif ()
25 changes: 19 additions & 6 deletions cmake/toolchains/osx.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
if (NOT _VCPKG_OSX_TOOLCHAIN_OVERRIDE)
set(_VCPKG_OSX_TOOLCHAIN_OVERRIDE 1)

if (Z_VCPKG_ROOT_DIR)
include(${Z_VCPKG_ROOT_DIR}/scripts/toolchains/osx.cmake)
else()
include(${_VCPKG_ROOT_DIR}/scripts/toolchains/osx.cmake)
endif()

# Prefer the root discovered by the vcpkg toolchain. Keep the environment
# and cache-variable fallbacks for older vcpkg versions and standalone use.
if (DEFINED Z_VCPKG_ROOT_DIR AND NOT "${Z_VCPKG_ROOT_DIR}" STREQUAL "")
set(_BRISK_VCPKG_ROOT_DIR "${Z_VCPKG_ROOT_DIR}")
elseif (DEFINED ENV{VCPKG_ROOT} AND NOT "$ENV{VCPKG_ROOT}" STREQUAL "")
file(TO_CMAKE_PATH "$ENV{VCPKG_ROOT}" _BRISK_VCPKG_ROOT_DIR)
elseif (DEFINED VCPKG_ROOT AND NOT "${VCPKG_ROOT}" STREQUAL "")
set(_BRISK_VCPKG_ROOT_DIR "${VCPKG_ROOT}")
elseif (DEFINED _VCPKG_ROOT_DIR AND NOT "${_VCPKG_ROOT_DIR}" STREQUAL "")
set(_BRISK_VCPKG_ROOT_DIR "${_VCPKG_ROOT_DIR}")
endif ()

if (NOT EXISTS "${_BRISK_VCPKG_ROOT_DIR}/scripts/toolchains/osx.cmake")
message(FATAL_ERROR "Could not locate the vcpkg macOS toolchain. Set VCPKG_ROOT or use a vcpkg toolchain that defines Z_VCPKG_ROOT_DIR.")
endif ()

include("${_BRISK_VCPKG_ROOT_DIR}/scripts/toolchains/osx.cmake")

string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -g0 -DNDEBUG -O3 ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -g0 -DNDEBUG -O3 ")
Expand All @@ -32,4 +44,5 @@ if (NOT _VCPKG_OSX_TOOLCHAIN_OVERRIDE)
"${CMAKE_CXX_FLAGS_DEBUG_INIT}"
CACHE STRING "" FORCE)

unset(_BRISK_VCPKG_ROOT_DIR)
endif ()
30 changes: 29 additions & 1 deletion cmake/toolchains/windows.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
if (NOT _VCPKG_WINDOWS_TOOLCHAIN_OVERRIDE)
set(_VCPKG_WINDOWS_TOOLCHAIN_OVERRIDE 1)

include($ENV{VCPKG_ROOT}/scripts/toolchains/windows.cmake)
# Recent vcpkg versions derive the root from .vcpkg-root and expose it as
# Z_VCPKG_ROOT_DIR. VCPKG_ROOT is not guaranteed to remain in the
# environment while a chainload toolchain is being evaluated.
if (DEFINED Z_VCPKG_ROOT_DIR AND NOT "${Z_VCPKG_ROOT_DIR}" STREQUAL "")
set(_BRISK_VCPKG_ROOT_DIR "${Z_VCPKG_ROOT_DIR}")
elseif (DEFINED ENV{VCPKG_ROOT} AND NOT "$ENV{VCPKG_ROOT}" STREQUAL "")
file(TO_CMAKE_PATH "$ENV{VCPKG_ROOT}" _BRISK_VCPKG_ROOT_DIR)
elseif (DEFINED VCPKG_ROOT AND NOT "${VCPKG_ROOT}" STREQUAL "")
set(_BRISK_VCPKG_ROOT_DIR "${VCPKG_ROOT}")
elseif (DEFINED _VCPKG_ROOT_DIR AND NOT "${_VCPKG_ROOT_DIR}" STREQUAL "")
set(_BRISK_VCPKG_ROOT_DIR "${_VCPKG_ROOT_DIR}")
endif ()

if (NOT EXISTS "${_BRISK_VCPKG_ROOT_DIR}/scripts/toolchains/windows.cmake")
message(FATAL_ERROR "Could not locate the vcpkg Windows toolchain. Set VCPKG_ROOT or use a vcpkg toolchain that defines Z_VCPKG_ROOT_DIR.")
endif ()

include("${_BRISK_VCPKG_ROOT_DIR}/scripts/toolchains/windows.cmake")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Zc:inline")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Zc:inline")
Expand Down Expand Up @@ -45,6 +62,16 @@ if (NOT _VCPKG_WINDOWS_TOOLCHAIN_OVERRIDE)
CACHE PATH "" FORCE)
endif ()

# vcpkg's Windows toolchain adds /c65001 to CMAKE_RC_FLAGS. That option
# is accepted by Microsoft's resource compiler, but CMake's resource
# dependency scanner invokes clang-cl with the same flags and clang-cl
# treats /c65001 as an input file. Keep the charset option for MSVC and
# omit it for clang-cl builds.
if (DEFINED ENV{LLVM_DIR} OR CMAKE_C_COMPILER MATCHES "clang-cl" OR CMAKE_CXX_COMPILER MATCHES "clang-cl")
set(CMAKE_RC_FLAGS "/DWIN32"
CACHE STRING "Flags used by the Windows resource compiler" FORCE)
endif ()

set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS}"
CACHE STRING "" FORCE)
Expand All @@ -65,4 +92,5 @@ if (NOT _VCPKG_WINDOWS_TOOLCHAIN_OVERRIDE)
"${CMAKE_CXX_FLAGS_DEBUG}"
CACHE STRING "" FORCE)

unset(_BRISK_VCPKG_ROOT_DIR)
endif ()
6 changes: 2 additions & 4 deletions examples/dashboard/src/dashboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
int briskMain() {
using namespace Brisk;

fonts->addFont("Titillium", FontStyle::Normal, FontWeight::Regular,
Resources::loadCached("TitilliumWeb-Regular.ttf"), false);
fonts->addFont("Titillium", FontStyle::Normal, FontWeight::Bold,
Resources::loadCached("TitilliumWeb-Bold.ttf"), false);
std::ignore = fonts->addFontFromResource("TitilliumWeb-Regular.ttf", "Titillium");
std::ignore = fonts->addFontFromResource("TitilliumWeb-Bold.ttf", "Titillium");

GuiApplication application;
return application.run(createComponent<App::MainComponent>());
Expand Down
5 changes: 5 additions & 0 deletions examples/showcase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ brisk_target_link_resource(
INPUT "${PROJECT_SOURCE_DIR}/resources/countries.json"
BROTLI)

brisk_target_link_resource(
showcase PRIVATE GoNotoKurrent-Regular.ttf
INPUT "${BRISK_RESOURCES_DIR}/fonts/GoNotoKurrent-Regular.ttf"
BROTLI)

brisk_setup_executable(showcase)
19 changes: 10 additions & 9 deletions examples/showcase/src/Buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@ Rc<Widget> ShowcaseButtons::build(Rc<Notifications> notifications, Value<bool> g
rcnew Viewport{
[](Canvas& canvas, Rectangle rect) {
canvas.setFillColor(Palette::Standard::amber);
PreparedText text = fonts->prepare(Font{ Font::DefaultPlusIconsEmoji, dp(18) },
"This text is rendered dynamically.");
float x = fract(currentTime() * 0.1) * text.bounds().width();
PointF offset = text.alignLines(0.f, 0.5f);
canvas.fillText(PointF{ -x, float(rect.center().y) } + offset, text);
canvas.fillText(PointF{ -x, float(rect.center().y) } + offset +
PointF{ text.bounds().width(), 0.f },
text);
const ShapedText text =
fonts->shapeText(Font{ Font::DefaultPlusIconsEmoji, dp(18) },
TextWithOptions{ "This text is rendered dynamically." });
const TextLayout layout = text.layout();
float x = fract(currentTime() * 0.1) * layout.bounds().width();
const PointF position{ -x, float(rect.center().y) };
canvas.fillText(position, { 0.f, 0.5f }, layout);
canvas.fillText(position + PointF{ layout.bounds().width(), 0.f }, { 0.f, 0.5f },
layout);
},
dimensions = { 70_apx, 25_apx },
},
Expand Down Expand Up @@ -156,7 +157,7 @@ Rc<Widget> ShowcaseButtons::build(Rc<Notifications> notifications, Value<bool> g
repeatDelay = 0.2,
repeatInterval = 0.2,
onClick = lifetime() |
[this] {
[this] {
m_clicked++;
bindings->notify(&m_clicked);
},
Expand Down
1 change: 1 addition & 0 deletions examples/showcase/src/Editors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ Rc<Widget> ShowcaseEditors::build(Rc<Notifications> notifications, Value<bool> g
textVerticalAlign = TextAlign::Start,
width = auto_,
enabled = globalEnabled,
fontFamily = "GoNoto",
},

rcnew Text{ "PasswordEditor (widgets/TextEditor.hpp)", classes = { "section-header" } },
Expand Down
13 changes: 8 additions & 5 deletions examples/showcase/src/Typography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Rc<Widget> emojiWidget(std::u32string str) {
textAlign = TextAlign::Center,
textVerticalAlign = TextAlign::Center,
onClick = staticLifetime |
[str] {
[str] {
std::string text;
for (char32_t ch : str) {
if (ch > U'\uFFFF')
Expand Down Expand Up @@ -180,7 +180,7 @@ static Builder iconsBuilder() {
fontSize = iconFontSize,
dimensions = { 36, 36 },
onClick = staticLifetime |
[ch] {
[ch] {
Clipboard::setText(fmt::format("\\u{:04X}", uint32_t(ch)));
},
});
Expand Down Expand Up @@ -237,9 +237,12 @@ Rc<Widget> ShowcaseTypography::build(Rc<Notifications> notifications, Value<bool
rcnew VLayout{
rcnew Text{
"gΥφ fi fl3.14 1/3 LT",
fontSize = 40,
fontFamily = "Lato",
fontFeatures = Value{ &m_fontFeatures },
fontSize = 40,
fontFamily = "Lato",
fontFeatures = Value{ &m_fontFeatures }.transform(
[](const std::array<OpenTypeFeatureFlag, 4>& features) -> OpenTypeFeatureFlags {
return { features[0], features[1], features[2], features[3] };
}),
letterSpacing = Value{ &m_letterSpacing },
wordSpacing = Value{ &m_wordSpacing },
textDecoration = Value{ &m_textDecoration },
Expand Down
4 changes: 2 additions & 2 deletions examples/showcase/src/Typography.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class ShowcaseTypography : public BindableObject<ShowcaseTypography, &uiSchedule
Rc<Widget> build(Rc<Notifications> notifications, Value<bool> globalEnabled);

private:
OpenTypeFeatureFlags m_fontFeatures{
std::array<OpenTypeFeatureFlag, 4> m_fontFeatures{ {
{ OpenTypeFeature::salt, false },
{ OpenTypeFeature::liga, true },
{ OpenTypeFeature::onum, false },
{ OpenTypeFeature::kern, true },
};
} };
float m_letterSpacing = 0.f;
float m_wordSpacing = 0.f;
TextDecoration m_textDecoration = TextDecoration::None;
Expand Down
Loading
Loading