MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / setupFontShow

Function setupFontShow

apps/tools/Tools/commands/FontCommand.cpp:67–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65 });
66}
67static void setupFontShow(CLI::App& font)
68{
69 auto* cmd = font.add_subcommand("show", "Display font character map grid in a window");
70 static std::string inputPath;
71 static std::string screenshotPath;
72 cmd->add_option("input", inputPath, "Input FXY font file")->required()->check(CLI::ExistingFile);
73 cmd->add_option("--screenshot", screenshotPath, "Save screenshot to file and exit");
74
75 cmd->callback(
76 []()
77 {
78 Poseidon::FontPreviewOptions opts;
79 opts.charmap = true;
80
81 auto preview = Poseidon::PreviewFont(inputPath, opts);
82 if (!preview.valid())
83 {
84 std::cerr << "Error: Failed to render font charmap" << std::endl;
85 throw CLI::RuntimeError(1);
86 }
87
88 if (!screenshotPath.empty())
89 {
90 if (!preview.saveToFile(screenshotPath))
91 {
92 std::cerr << "Error: Failed to write screenshot" << std::endl;
93 throw CLI::RuntimeError(1);
94 }
95 std::cout << "Screenshot: " << screenshotPath << " (" << preview.width << "x" << preview.height << ")"
96 << std::endl;
97 return;
98 }
99
100 DisplayWindowRGBA("PoseidonTools - " + inputPath + " (charmap)", preview.width, preview.height,
101 preview.data.data());
102 });
103}
104static void setupFontPreview(CLI::App& font)
105{
106 auto* cmd = font.add_subcommand("preview", "Preview font with custom text");

Callers 1

SetupMethod · 0.85

Calls 5

PreviewFontFunction · 0.85
DisplayWindowRGBAFunction · 0.85
saveToFileMethod · 0.80
validMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected