Debian Codegraph @

fontforgeexe/gtk/show_histogram_shim.hpp

raw symbols SCIP
1 /* Copyright (C) 2026 by Maxim Iorsh <iorsh@[email protected]>
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
8
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 #pragma once
28
29 enum hist_type { hist_hstem, hist_vstem, hist_blues };
30 typedef struct gwindow* GWindow;
31 typedef struct splinefont SplineFont;
32 struct psdict;
33 typedef struct encmap EncMap;
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 #include <stdint.h>
38 void SFHistogram(GWindow parent, SplineFont* sf, int layer,
39 struct psdict* private_dict, uint8_t* selected, EncMap* map,
40 enum hist_type which);
41 #ifdef __cplusplus
42 }
43 #endif
44
45 #ifdef __cplusplus
46 #include <map>
47 #include <optional>
48 #include <string>
49 #include <vector>
50
51 #include "l10n_text.hpp"
52 #include "intl.h"
53
54 namespace ff::dlg {
55
56 struct HistogramBarRecord {
57 // Total count of hints or blues with this value.
58 unsigned int count;
59
60 // List of characters with this hint or blue value. The number of characters
61 // may be smaller than cnt, because the same character may have multiple
62 // hints or blues with the same value.
63 std::vector<std::string> glyph_names;
64 };
65
66 struct PrivateDictValues {
67 std::string primary;
68 std::string secondary;
69 };
70
71 struct HistogramData {
72 enum hist_type type;
73 int lower_bound;
74 bool small_selection_warning;
75 std::vector<HistogramBarRecord> bars;
76 PrivateDictValues initial_values;
77 };
78
79 struct UiStrings {
80 L10nText title;
81 std::string primary_label;
82 std::string secondary_label;
83 };
84
85 const std::map<hist_type, UiStrings> kHistogramUiStrings = {
86 {hist_hstem, {_("Horizontal Stem Hints"), "StdHW", "StemSnapH"}},
87 {hist_vstem, {_("Vertical Stem Hints"), "StdVW", "StemSnapV"}},
88 {hist_blues, {_("Blues"), "BlueValues", "OtherBlues"}},
89 };
90
91 std::optional<PrivateDictValues> show_histogram_dialog(
92 GWindow parent, const HistogramData& data);
93
94 } // namespace ff::dlg
95
96 #endif // __cplusplus