710 const double kMinOKFraction = 0.99;
713 const double kMinWeightedFraction = 0.99995;
716 std::vector<std::vector<bool> > font_flags;
717 std::vector<int> font_scores;
718 std::vector<int> raw_scores;
719 int most_ok_chars = 0;
720 int best_raw_score = 0;
722 for (
unsigned i = 0; i < font_names.size(); ++i) {
723 std::vector<bool> ch_flags;
725 int ok_chars =
FontScore(ch_map, font_names[i], &raw_score, &ch_flags);
726 most_ok_chars = std::max(ok_chars, most_ok_chars);
727 best_raw_score = std::max(raw_score, best_raw_score);
729 font_flags.push_back(ch_flags);
730 font_scores.push_back(ok_chars);
731 raw_scores.push_back(raw_score);
742 int least_good_enough = static_cast<int>(most_ok_chars * kMinOKFraction);
743 int least_raw_enough = static_cast<int>(best_raw_score * kMinOKFraction);
744 int override_enough = static_cast<int>(most_ok_chars * kMinWeightedFraction);
747 for (
unsigned i = 0; i < font_names.size(); ++i) {
748 int score = font_scores[i];
749 int raw_score = raw_scores[i];
750 if ((score >= least_good_enough && raw_score >= least_raw_enough) ||
751 score >= override_enough) {
752 fonts->push_back(std::make_pair(font_names[i].c_str(), font_flags[i]));
753 tlog(1,
"OK font %s = %.4f%%, raw = %d = %.2f%%\n",
754 font_names[i].c_str(),
755 100.0 * score / most_ok_chars,
756 raw_score, 100.0 * raw_score / best_raw_score);
757 font_list += font_names[i];
759 }
else if (score >= least_good_enough || raw_score >= least_raw_enough) {
760 tlog(1,
"Runner-up font %s = %.4f%%, raw = %d = %.2f%%\n",
761 font_names[i].c_str(),
762 100.0 * score / most_ok_chars,
763 raw_score, 100.0 * raw_score / best_raw_score);