199 double best_dist =
static_cast<double>(
WORST_COST);
201 for (
int fnt = 0; fnt < font_pair_size_models_.size(); fnt++) {
202 const FontPairSizeInfo *fnt_info = &font_pair_size_models_[fnt];
203 double mean_dist = 0;
206 for (
int smp_0 = 0; smp_0 < samp_cnt; smp_0++) {
207 int cls_0 = char_set_->
ClassID(samp_array[smp_0]->StrLabel());
215 samp_array[smp_0]->FirstChar() == 0 ? 0 : 1,
216 samp_array[smp_0]->LastChar() == 0 ? 0 : 1);
221 int char0_height = samp_array[smp_0]->Height();
222 int char0_width = samp_array[smp_0]->Width();
223 int char0_top = samp_array[smp_0]->Top();
225 for (
int smp_1 = smp_0 + 1; smp_1 < samp_cnt; smp_1++) {
226 int cls_1 = char_set_->
ClassID(samp_array[smp_1]->StrLabel());
234 samp_array[smp_1]->FirstChar() == 0 ? 0 : 1,
235 samp_array[smp_1]->LastChar() == 0 ? 0 : 1);
240 char0_width, char0_height, char0_top, samp_array[smp_1]->Width(),
241 samp_array[smp_1]->Height(), samp_array[smp_1]->Top(),
242 fnt_info->pair_size_info[size_code_0][size_code_1]);
252 mean_dist /= pair_cnt;
253 if (best_fnt == -1 || mean_dist < best_dist) {
254 best_dist = mean_dist;
258 if (best_fnt == -1) {
261 return static_cast<int>(best_dist);
static int SizeCode(int cls_id, int start, int end)
static double PairCost(int width_0, int height_0, int top_0, int width_1, int height_1, int top_1, const PairSizeInfo &pair_info)
int ClassID(const char_32 *str) const