| 65 | }); |
| 66 | } |
| 67 | static 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 | } |
| 104 | static void setupFontPreview(CLI::App& font) |
| 105 | { |
| 106 | auto* cmd = font.add_subcommand("preview", "Preview font with custom text"); |
no test coverage detected