680 const double kMinOKFraction = 0.99;
683 const double kMinWeightedFraction = 0.99995;
686 std::vector<std::vector<bool> > font_flags;
687 std::vector<int> font_scores;
688 std::vector<int> raw_scores;
689 int most_ok_chars = 0;
690 int best_raw_score = 0;
692 for (
unsigned i = 0; i < font_names.size(); ++i) {
693 std::vector<bool> ch_flags;
695 int ok_chars =
FontScore(ch_map, font_names[i], &raw_score, &ch_flags);
696 most_ok_chars = std::max(ok_chars, most_ok_chars);
697 best_raw_score = std::max(raw_score, best_raw_score);
699 font_flags.push_back(ch_flags);
700 font_scores.push_back(ok_chars);
701 raw_scores.push_back(raw_score);
712 int least_good_enough =
static_cast<int>(most_ok_chars * kMinOKFraction);
713 int least_raw_enough =
static_cast<int>(best_raw_score * kMinOKFraction);
714 int override_enough =
static_cast<int>(most_ok_chars * kMinWeightedFraction);
716 std::string font_list;
717 for (
unsigned i = 0; i < font_names.size(); ++i) {
718 int score = font_scores[i];
719 int raw_score = raw_scores[i];
720 if ((score >= least_good_enough && raw_score >= least_raw_enough) ||
721 score >= override_enough) {
722 fonts->push_back(std::make_pair(font_names[i].c_str(), font_flags[i]));
723 tlog(1,
"OK font %s = %.4f%%, raw = %d = %.2f%%\n",
724 font_names[i].c_str(),
725 100.0 * score / most_ok_chars,
726 raw_score, 100.0 * raw_score / best_raw_score);
727 font_list += font_names[i];
729 }
else if (score >= least_good_enough || raw_score >= least_raw_enough) {
730 tlog(1,
"Runner-up font %s = %.4f%%, raw = %d = %.2f%%\n",
731 font_names[i].c_str(),
732 100.0 * score / most_ok_chars,
733 raw_score, 100.0 * raw_score / best_raw_score);
static int FontScore(const std::unordered_map< char32, int64_t > &ch_map, const std::string &fontname, int *raw_score, std::vector< bool > *ch_flags)
static const std::vector< std::string > & ListAvailableFonts()