690 const double kMinOKFraction = 0.99;
693 const double kMinWeightedFraction = 0.99995;
696 std::vector<std::vector<bool> > font_flags;
697 std::vector<int> font_scores;
698 std::vector<int> raw_scores;
699 int most_ok_chars = 0;
700 int best_raw_score = 0;
702 for (
unsigned i = 0; i < font_names.size(); ++i) {
703 std::vector<bool> ch_flags;
705 int ok_chars =
FontScore(ch_map, font_names[i], &raw_score, &ch_flags);
706 most_ok_chars =
MAX(ok_chars, most_ok_chars);
707 best_raw_score =
MAX(raw_score, best_raw_score);
709 font_flags.push_back(ch_flags);
710 font_scores.push_back(ok_chars);
711 raw_scores.push_back(raw_score);
722 int least_good_enough =
static_cast<int>(most_ok_chars * kMinOKFraction);
723 int least_raw_enough =
static_cast<int>(best_raw_score * kMinOKFraction);
724 int override_enough =
static_cast<int>(most_ok_chars * kMinWeightedFraction);
727 for (
unsigned i = 0; i < font_names.size(); ++i) {
728 int score = font_scores[i];
729 int raw_score = raw_scores[i];
730 if ((score >= least_good_enough && raw_score >= least_raw_enough) ||
731 score >= override_enough) {
732 fonts->push_back(std::make_pair(font_names[i].c_str(), font_flags[i]));
733 tlog(1,
"OK font %s = %.4f%%, raw = %d = %.2f%%\n",
734 font_names[i].c_str(),
735 100.0 * score / most_ok_chars,
736 raw_score, 100.0 * raw_score / best_raw_score);
737 font_list += font_names[i];
739 }
else if (score >= least_good_enough || raw_score >= least_raw_enough) {
740 tlog(1,
"Runner-up font %s = %.4f%%, raw = %d = %.2f%%\n",
741 font_names[i].c_str(),
742 100.0 * score / most_ok_chars,
743 raw_score, 100.0 * raw_score / best_raw_score);
static const std::vector< string > & ListAvailableFonts()
static int FontScore(const std::unordered_map< char32, inT64 > &ch_map, const string &fontname, int *raw_score, std::vector< bool > *ch_flags)