49 lines
1.9 KiB
C++
49 lines
1.9 KiB
C++
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
// SPDX-FileCopyrightText: 2025 ai-ad4 and the FreePDFEditor contributors
|
|
//
|
|
// Spike C main: grow an embedded subset font with a new glyph (§14 step 6)
|
|
// and report whether the growth produces a valid, renderable glyph.
|
|
//
|
|
// Usage:
|
|
// spike_c_subset_growth [font_path]
|
|
//
|
|
// Defaults to DejaVu Sans if no font is given. Exit 0 if the grown subset
|
|
// contains and can render the new glyph (U+03A9) and the original subset did
|
|
// not (i.e. growth actually added something).
|
|
|
|
#include "SubsetGrowth.h"
|
|
#include "../common/SpikeRunner.h"
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <string>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
const std::string font_path = (argc >= 2) ? argv[1]
|
|
: "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf";
|
|
|
|
auto r = freepdfeditor::spike::c::grow_subset(font_path);
|
|
|
|
freepdfeditor::spike::SpikeResult sr{};
|
|
sr.spike = "C";
|
|
sr.name = "hb-subset growth of an embedded subset font";
|
|
sr.total = 1;
|
|
sr.passed = r.ok ? 1 : 0;
|
|
sr.failed = r.ok ? 0 : 1;
|
|
sr.errored = (!r.ok && !r.error.empty() && r.error.find("failed") != std::string::npos) ? 1 : 0;
|
|
sr.metric_name = "new_glyph_renders";
|
|
sr.metric_value = r.ok ? 1.0 : 0.0;
|
|
sr.target = 1.0;
|
|
sr.gate_met = r.ok;
|
|
sr.notes = "font=" + font_path +
|
|
" original_glyphs=" + std::to_string(r.original_glyph_count) +
|
|
" grown_glyphs=" + std::to_string(r.grown_glyph_count) +
|
|
" original_bytes=" + std::to_string(r.original_font_bytes) +
|
|
" grown_bytes=" + std::to_string(r.grown_font_bytes) +
|
|
" new_glyph_present=" + (r.new_glyph_present ? "yes" : "no") +
|
|
" new_glyph_renders=" + (r.new_glyph_renders ? "yes" : "no") +
|
|
(!r.error.empty() ? " error=" + r.error : "") +
|
|
"; §4.2 requires growing produces a NEW font (original untouched)";
|
|
return freepdfeditor::spike::emit_json_report(sr);
|
|
} |