214 double best_dist =
static_cast<double>(
WORST_COST);
216 for (
int fnt = 0; fnt < font_pair_size_models_.size(); fnt++) {
217 const FontPairSizeInfo *fnt_info = &font_pair_size_models_[fnt];
218 double mean_dist = 0;
221 for (
int smp_0 = 0; smp_0 < samp_cnt; smp_0++) {
222 int cls_0 = char_set_->
ClassID(samp_array[smp_0]->StrLabel());
230 samp_array[smp_0]->FirstChar() == 0 ? 0 : 1,
231 samp_array[smp_0]->LastChar() == 0 ? 0 : 1);
236 int char0_height = samp_array[smp_0]->Height();
237 int char0_width = samp_array[smp_0]->Width();
238 int char0_top = samp_array[smp_0]->Top();
240 for (
int smp_1 = smp_0 + 1; smp_1 < samp_cnt; smp_1++) {
241 int cls_1 = char_set_->
ClassID(samp_array[smp_1]->StrLabel());
249 samp_array[smp_1]->FirstChar() == 0 ? 0 : 1,
250 samp_array[smp_1]->LastChar() == 0 ? 0 : 1);
255 char0_width, char0_height, char0_top, samp_array[smp_1]->Width(),
256 samp_array[smp_1]->Height(), samp_array[smp_1]->Top(),
257 fnt_info->pair_size_info[size_code_0][size_code_1]);
267 mean_dist /= pair_cnt;
268 if (best_fnt == -1 || mean_dist < best_dist) {
269 best_dist = mean_dist;
273 if (best_fnt == -1) {
276 return static_cast<int>(best_dist);
static int SizeCode(int cls_id, int start, int end)
int ClassID(const char_32 *str) const
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)