729 const double kMinOKFraction = 0.99;
732 const double kMinWeightedFraction = 0.99995;
735 std::vector<std::vector<bool> > font_flags;
736 std::vector<int> font_scores;
737 std::vector<int> raw_scores;
738 int most_ok_chars = 0;
739 int best_raw_score = 0;
741 for (
unsigned i = 0; i < font_names.size(); ++i) {
742 std::vector<bool> ch_flags;
744 int ok_chars =
FontScore(ch_map, font_names[i], &raw_score, &ch_flags);
745 most_ok_chars =
MAX(ok_chars, most_ok_chars);
746 best_raw_score =
MAX(raw_score, best_raw_score);
748 font_flags.push_back(ch_flags);
749 font_scores.push_back(ok_chars);
750 raw_scores.push_back(raw_score);
761 int least_good_enough =
static_cast<int>(most_ok_chars * kMinOKFraction);
762 int least_raw_enough =
static_cast<int>(best_raw_score * kMinOKFraction);
763 int override_enough =
static_cast<int>(most_ok_chars * kMinWeightedFraction);
766 for (
unsigned i = 0; i < font_names.size(); ++i) {
767 int score = font_scores[i];
768 int raw_score = raw_scores[i];
769 if ((score >= least_good_enough && raw_score >= least_raw_enough) ||
770 score >= override_enough) {
771 fonts->push_back(std::make_pair(font_names[i].c_str(), font_flags[i]));
772 tlog(1,
"OK font %s = %.4f%%, raw = %d = %.2f%%\n",
773 font_names[i].c_str(),
774 100.0 * score / most_ok_chars,
775 raw_score, 100.0 * raw_score / best_raw_score);
776 font_list += font_names[i];
778 }
else if (score >= least_good_enough || raw_score >= least_raw_enough) {
779 tlog(1,
"Runner-up font %s = %.4f%%, raw = %d = %.2f%%\n",
780 font_names[i].c_str(),
781 100.0 * score / most_ok_chars,
782 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)