| 102 | }); |
| 103 | } |
| 104 | static 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 | } |
| 143 | static void setupFontRender(CLI::App& font) |
| 144 | { |
| 145 | auto* cmd = font.add_subcommand("render", "Render font to PNG file"); |
no test coverage detected