48 if (debug_level > 0) {
49 tprintf(
"AssociateUtils::ComputeStats() for col=%d, row=%d%s\n",
50 col, row, fixed_pitch ?
" (fixed pitch)" :
"");
54 if (fixed_pitch && denorm !=
NULL && denorm->
row() !=
NULL) {
61 normalizing_height = denorm->
y_scale() *
64 if (debug_level > 0) {
65 tprintf(
"normalizing height = %g (scale %g xheight %g ascenders %g)\n",
72 if (debug_level)
tprintf(
"wh_ratio %g\n", wh_ratio);
73 if (wh_ratio > max_char_wh_ratio) stats->bad_shape =
true;
89 stats->bad_shape =
true;
92 float right_gap = 0.0f;
99 tprintf(
"right_gap %g right_seam %g\n",
102 if (right_gap < kMinGap || right_seam->priority > 0.0
f) {
103 stats->bad_shape =
true;
104 if (right_gap <
kMinGap) stats->bad_fixed_pitch_right_gap =
true;
113 stats->full_wh_ratio = wh_ratio + right_gap;
114 if (parent_stats !=
NULL) {
115 stats->full_wh_ratio_total =
116 (parent_stats->full_wh_ratio_total + stats->full_wh_ratio);
118 stats->full_wh_ratio_total /
static_cast<float>(parent_path_length+1);
119 stats->full_wh_ratio_var =
120 parent_stats->full_wh_ratio_var + pow(mean-stats->full_wh_ratio, 2);
122 stats->full_wh_ratio_total = stats->full_wh_ratio;
125 tprintf(
"full_wh_ratio %g full_wh_ratio_total %g full_wh_ratio_var %g\n",
126 stats->full_wh_ratio, stats->full_wh_ratio_total,
127 stats->full_wh_ratio_var);
136 if (col == 0 && end_row && wh_ratio > max_char_wh_ratio) {
137 stats->shape_cost += 10;
139 stats->shape_cost += stats->full_wh_ratio_var;
140 if (debug_level)
tprintf(
"shape_cost %g\n", stats->shape_cost);
static const float kMinGap
static int GetChunksWidth(WIDTH_RECORD *width_record, int start_blob, int last_blob)
static float FixedPitchWidthCost(float norm_width, float right_gap, bool end_pos, float max_char_wh_ratio)
static int GetChunksGap(WIDTH_RECORD *width_record, int last_chunk)
DLLSYM void tprintf(const char *format,...)
WIDTH_RECORD * chunk_widths
#define array_value(a, i)