[gpu] Wire up default font/text in demo

Fall back to an embedded font when no font file is given,
matching the glyphy-demo behaviour.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Behdad EsfahbodandClaude Opus 4.6 committed 2026-03-26 18:32:21 -06:00
1 parent 03c2688436
commit 294b625f7c
2 files changed
+24 -2

No files matched your search

+16 -2
View File
@@ -245,7 +245,7 @@ main (int argc, char** argv)
else
text = default_text;
}
if (!text || !font_path)
if (!text)
{
show_usage(argv[0]);
return 1;
@@ -297,7 +297,21 @@ main (int argc, char** argv)
demo_view_print_help (vu);
warn_about_vsync_override ();
hb_blob_t *blob = hb_blob_create_from_file_or_fail (font_path);
hb_blob_t *blob = NULL;
if (font_path)
{
blob = hb_blob_create_from_file_or_fail (font_path);
}
else
{
#ifdef _WIN32
blob = hb_blob_create_from_file_or_fail ("C:\\Windows\\Fonts\\calibri.ttf");
#else
#include "default-font.h"
blob = hb_blob_create ((const char *) default_font, sizeof (default_font),
HB_MEMORY_MODE_READONLY, NULL, NULL);
#endif
}
if (!blob)
die ("Failed to open font file");
+8
View File
@@ -44,6 +44,14 @@ glew_dep = dependency('glew', required: true)
glfw_dep = dependency('glfw3', required: true)
gl_dep = dependency('gl', required: true)
hexify = find_program('hexify')
gpu_demo_shader_sources += custom_target('default font',
input: 'default-font.ttf',
output: 'default-font.h',
capture: true,
command: [ hexify, 'static const char default_font[]', '@INPUT@' ])
hb_gpu_demo = executable('hb-gpu', gpu_demo_sources + gpu_demo_shader_sources,
cpp_args: cpp_args,
include_directories: [incconfig, incsrc],