16#include <nlohmann/json.hpp>
103 fRenderData = std::make_unique<REveRenderData>(
"makeZText");
138 static bool s_have_fallback =
false;
139 if (!s_have_fallback) {
140 s_have_fallback =
true;
141 s_dirs.AddFallbackDir(REveAssetDir::GetAssetsDir() +
"sdf-fonts/");
161 static const char* tpfx =
"REveText::SetSdfFontDir";
164 ::Error(tpfx,
"Empty directory given.");
168 std::string sanitized_dir = REveAssetDir::NormalizeDir(dir);
171 ::Error(tpfx,
"Directory does not exist and mkdir failed for '%s", dir.data());
178 auto &
fonts = SdfFontDirs();
196 static const char *tpfx =
"REveText::AddSdfFontDir";
198 std::string sanitized_dir = REveAssetDir::NormalizeDir(dir);
200 ::Error(tpfx,
"SDF font directory '%s' does not exist or is not readable.", dir.data());
205 SdfFontDirs().AddUserDir(sanitized_dir);
219 static const char *tpfx =
"REveText::SetDefaultSdfFontDir";
221 std::string dir = REveAssetDir::GetUi5Dir() +
"/eve7/sdf-fonts/";
225 ::Info(tpfx,
"Using SDF font dir %s", dir.c_str());
227 dir =
"./sdf-fonts/";
228 ::Info(tpfx,
"Using SDF font dir sdf-fonts/ in current directory");
232 auto &
fonts = SdfFontDirs();
233 fonts.SetWriteDir(dir);
234 fonts.SetUserDir(dir);
253 static const char* tpfx =
"REveText::AssertSdfFont";
258 auto &
fonts = SdfFontDirs();
259 std::string png = font_name +
".png";
260 std::string js = font_name +
".js.gz";
262 if (
fonts.FindPair(png, js).empty()) {
264 std::string at_png =
fonts.Find(png), at_js =
fonts.Find(js), split;
265 auto where = [](
const std::string &
f,
const std::string &
p) {
266 return f + (
p.empty() ?
" not found" :
" found at '" +
p +
"'");
268 if (!at_png.empty() || !at_js.empty())
269 split =
" Its two files must be in one directory: " + where(png, at_png) +
", " + where(js, at_js) +
".";
271 ::Warning(tpfx,
"Source TTF font '%s' not found.%s", ttf_font.data(), split.data());
275 if (
gROOT->IsBatch()) {
276 static std::set<std::string> s_warned_fonts;
277 if (s_warned_fonts.insert(font_name).second) {
280 "SDF font '%s' is not in '%s' and is not generated in batch mode. "
281 "Generating it needs a GL context, which needs a display. "
282 "Run once with a display, or copy %s.png and %s.js.gz into the SDF font directory.",
283 font_name.data(),
sSdfFontDir.data(), font_name.data(), font_name.data());
285 ::Warning(tpfx,
"SDF font '%s' is not used and is not generated in batch mode.%s", font_name.data(),
290 std::string base =
fonts.WritePath(font_name);
292 ::Warning(tpfx,
"Cannot create SDF font directory '%s', font '%s' not generated.",
fonts.GetWriteDir().data(),
298 int cl = snprintf(command, 8192,
"TGLSdfFontMaker::MakeFont(\"%s\", \"%s\");",
299 ttf_font.data(), base.data());
301 ::Warning(tpfx,
"Error generating interpreter command for TGLSdfFontMaker::MakeFont(), ret=%d.", cl);
305 while (--cl >= 0)
if (command[cl] ==
'\\') command[cl] =
'/';
307 gROOT->ProcessLine(command);
309 if (
fonts.FindPair(png, js).empty()) {
310 ::Warning(tpfx,
"Creation of font '%s' failed.", font_name.data());
char Text_t
General string (char)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
R__EXTERN TSystem * gSystem
Directories of one kind of file the REve server serves under one http location prefix.
virtual void RemoveNiece(REveElement *el)
virtual void RemoveAunt(REveAunt *au)
Remove el from the list of aunts.
std::unique_ptr< REveRenderData > fRenderData
! Vertex / normal / triangle index information for rendering.
virtual void BuildRenderData()
Build fRenderData, what the client draws.
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
static std::string sSdfFontDir
REveText(const REveText &)=delete
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
void ComputeBBox() override
Text has no box: its extent is known only to the client, which lays it out.
std::string fFont
Default must be a face ROOT ships: only Liberation Mono and Serif are in $ROOTSYS/fonts,...
static bool SetDefaultSdfFontDir()
Set the default SDF font directory: sdf-fonts/ in the ui5 directory if it is writable or can be creat...
void SetClickAction(const std::string &mir, REveElement *target=nullptr)
Fill core part of JSON representation.
ElementId_t fClickTargetId
void RemoveAunt(REveAunt *au) override
Clear the click action when the click target is destroyed, so the button does not keep an id that may...
static bool AssertSdfFont(const std::string &font_name, const std::string &ttf_font)
Check if font exists, otherwise try to create it.
Color_t fTextColor
target held as an aunt, so its death is noticed
static bool AddSdfFontDir(const std::string &dir)
Add a directory fonts are read from, searched after the one of SetSdfFontDir() and before the fonts s...
static bool SetSdfFontDir(const std::string &dir, bool require_write_access=true)
Set location where SDF fonts and their metrics data are stored or are to be created via the AssertSdf...
void BuildRenderData() override
Crates 3D point array for rendering.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Namespace for ROOT features in testing.