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

Function setupFontPreview

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

Source from the content-addressed store, hash-verified

102 });
103}
104static void setupFontPreview(CLI::App& font)
105{
106 auto* cmd = font.add_subcommand("preview", "Preview font with custom text");
107 static std::string inputPath;
108 static std::string screenshotPath;
109 static std::string sampleText;
110 cmd->add_option("input", inputPath, "Input FXY font file")->required()->check(CLI::ExistingFile);
111 cmd->add_option("--screenshot", screenshotPath, "Save screenshot to file and exit");
112 cmd->add_option("--text", sampleText, "Custom sample text to render");
113
114 cmd->callback(
115 []()
116 {
117 Poseidon::FontPreviewOptions opts;
118 if (!sampleText.empty())
119 opts.sampleText = sampleText;
120
121 auto preview = Poseidon::PreviewFont(inputPath, opts);
122 if (!preview.valid())
123 {
124 std::cerr << "Error: Failed to render font preview" << std::endl;
125 throw CLI::RuntimeError(1);
126 }
127
128 if (!screenshotPath.empty())
129 {
130 if (!preview.saveToFile(screenshotPath))
131 {
132 std::cerr << "Error: Failed to write screenshot" << std::endl;
133 throw CLI::RuntimeError(1);
134 }
135 std::cout << "Screenshot: " << screenshotPath << " (" << preview.width << "x" << preview.height << ")"
136 << std::endl;
137 return;
138 }
139
140 DisplayWindowRGBA("PoseidonTools - " + inputPath, preview.width, preview.height, preview.data.data());
141 });
142}
143static void setupFontRender(CLI::App& font)
144{
145 auto* cmd = font.add_subcommand("render", "Render font to PNG file");

Callers 1

SetupMethod · 0.85

Calls 5

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

Tested by

no test coverage detected