From 9390ab02d5e1d921cfaa4e4948082a818d0e8246 Mon Sep 17 00:00:00 2001 From: ruevs Date: Mon, 23 Nov 2020 13:52:17 +0200 Subject: [PATCH] Set the default font for text objects correctly. The default font is BitstreamVeraSans-Roman-builtin.ttf since 94b26ddfac0c, but on Win32 it needs to be `res://fonts/...` URI to work. Fixes: https://github.com/solvespace/solvespace/issues/821 --- src/mouse.cpp | 2 +- src/platform/platform.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mouse.cpp b/src/mouse.cpp index 699f3e26..6c22a0cb 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -1117,7 +1117,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my, bool shiftDown, bool ct AddToPending(hr); Request *r = SK.GetRequest(hr); r->str = "Abc"; - r->font = "BitstreamVeraSans-Roman-builtin.ttf"; + r->font = Platform::embeddedFont; for(int i = 1; i <= 4; i++) { SK.GetEntity(hr.entity(i))->PointForceTo(v); diff --git a/src/platform/platform.h b/src/platform/platform.h index 5664fa21..21c2b2bf 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -17,6 +17,12 @@ std::string Narrow(const std::wstring &s); std::wstring Widen(const std::string &s); #endif +#if defined(_WIN32) + const std::string embeddedFont = "res://fonts/BitstreamVeraSans-Roman-builtin.ttf"; +#else // Linux and macOS + const std::string embeddedFont = "BitstreamVeraSans-Roman-builtin.ttf"; +#endif + // A filesystem path, respecting the conventions of the current platform. // Transformation functions return an empty path on error. class Path {