From b6a0db7a17a7a2466d3a766b4fb09c45198da1db Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Thu, 25 Jun 2026 00:15:35 -0700 Subject: [PATCH] Add Atkinson Hyperlegible Mono font support PiperOrigin-RevId: 937799904 Change-Id: I89e4652cc45afdd9a55b3042395c4a56c70289fb --- .../atkinson_hyperlegible_mono.cmake | 28 +++++++++++++++++++ .../atkinson_hyperlegible_mono/CMakeLists.txt | 15 ++++++++++ src/experimental/platform/hal/window.cc | 7 +++++ src/experimental/studio/CMakeLists.txt | 11 ++++++++ src/experimental/studio/live.js | 1 + 5 files changed, 62 insertions(+) create mode 100644 cmake/third_party_deps/atkinson_hyperlegible_mono.cmake create mode 100644 cmake/third_party_deps/atkinson_hyperlegible_mono/CMakeLists.txt diff --git a/cmake/third_party_deps/atkinson_hyperlegible_mono.cmake b/cmake/third_party_deps/atkinson_hyperlegible_mono.cmake new file mode 100644 index 00000000..bc0fd532 --- /dev/null +++ b/cmake/third_party_deps/atkinson_hyperlegible_mono.cmake @@ -0,0 +1,28 @@ +# Copyright 2026 DeepMind Technologies Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MUJOCO_DEP_VERSION_atkinson_hyperlegible_mono + 154d50362016cc3e873eb21d242cd0772384c8f9 + CACHE STRING "Tag/version of `atkinson_hyperlegible_mono` to be fetched." +) +mark_as_advanced(MUJOCO_DEP_VERSION_atkinson_hyperlegible_mono) + +include(FindOrFetch) + +fetchpackage( + PACKAGE_NAME atkinson_hyperlegible_mono + GIT_REPO https://github.com/googlefonts/atkinson-hyperlegible-next-mono.git + GIT_TAG ${MUJOCO_DEP_VERSION_atkinson_hyperlegible_mono} + CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/atkinson_hyperlegible_mono/CMakeLists.txt" +) diff --git a/cmake/third_party_deps/atkinson_hyperlegible_mono/CMakeLists.txt b/cmake/third_party_deps/atkinson_hyperlegible_mono/CMakeLists.txt new file mode 100644 index 00000000..6a1e13eb --- /dev/null +++ b/cmake/third_party_deps/atkinson_hyperlegible_mono/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright 2026 DeepMind Technologies Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Data-only package. diff --git a/src/experimental/platform/hal/window.cc b/src/experimental/platform/hal/window.cc index f1fb63ee..c3e0facd 100644 --- a/src/experimental/platform/hal/window.cc +++ b/src/experimental/platform/hal/window.cc @@ -84,6 +84,13 @@ static void InitImGui(SDL_Window* window, float content_scale, constexpr ImWchar icon_ranges[] = {0xf000, 0xf3ff, 0x000}; io.Fonts->AddFontFromMemoryTTF(data, size, 13.f, &icon_cfg, icon_ranges); + ImFontConfig mono_cfg; + mono_cfg.FontDataOwnedByAtlas = false; + font = mju_openResource("", "font:AtkinsonHyperlegibleMono-Regular.ttf", nullptr, + nullptr, 0); + size = mju_readResource(font, const_cast(&data)); + io.Fonts->AddFontFromMemoryTTF(data, size, 14.f, &mono_cfg); + // Note: we purposefully do not "close" the font resources as ImGui may // need them again to resize fonts. } diff --git a/src/experimental/studio/CMakeLists.txt b/src/experimental/studio/CMakeLists.txt index 8eaf944f..8128ce26 100644 --- a/src/experimental/studio/CMakeLists.txt +++ b/src/experimental/studio/CMakeLists.txt @@ -17,6 +17,7 @@ cmake_minimum_required(VERSION 3.16) include(third_party_deps/dear_imgui) include(third_party_deps/implot) include(third_party_deps/atkinson_hyperlegible_next) +include(third_party_deps/atkinson_hyperlegible_mono) include(third_party_deps/font_awesome) # Common configuration shared between mujoco_studio and mujoco_live. @@ -81,6 +82,16 @@ function(configure_studio_target TARGET_NAME) ${STUDIO_ASSETS_DIR} COMMENT "Copying fontawesome-webfont.ttf to build directory" ) + add_custom_command( + TARGET ${TARGET_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${STUDIO_ASSETS_DIR} + COMMAND ${CMAKE_COMMAND} + -E copy + "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../_deps/atkinson_hyperlegible_mono-src/fonts/ttf/AtkinsonHyperlegibleMono-Regular.ttf" + ${STUDIO_ASSETS_DIR}/AtkinsonHyperlegibleMono-Regular.ttf + COMMENT "Copying AtkinsonHyperlegibleMono-Regular font to build directory" + ) # Filament backend requires additional files to be copied into an "assets" folder. if(MUJOCO_USE_FILAMENT) diff --git a/src/experimental/studio/live.js b/src/experimental/studio/live.js index af830e75..4d8bfec1 100644 --- a/src/experimental/studio/live.js +++ b/src/experimental/studio/live.js @@ -143,6 +143,7 @@ var Module = { "assets/fontawesome-webfont.ttf", "assets/ibl.ktx", "assets/AtkinsonHyperlegibleNext[wght].ttf", + "assets/AtkinsonHyperlegibleMono-Regular.ttf", "assets/pbr.filamat", "assets/pbr_transparent.filamat", "assets/pbr_packed.filamat",