Skip to content

Commit

Permalink
use TessHashMap instead of hash_map, unordered_map
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Nov 30, 2016
1 parent 0cbbbe6 commit 5750e72
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion training/ligature_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace tesseract {
class PangoFontInfo; // defined in pango_font_info.h

// Map to substitute strings for ligatures.
typedef hash_map<string, string, StringHash> LigHash;
typedef TessHashMap<string, string, StringHash> LigHash;

class LigatureTable {
public:
Expand Down
6 changes: 3 additions & 3 deletions training/pango_font_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ void FontUtils::GetAllRenderableCharacters(const vector<string>& fonts,
// Utilities written to be backward compatible with StringRender

/* static */
int FontUtils::FontScore(const unordered_map<char32, inT64>& ch_map,
int FontUtils::FontScore(const TessHashMap<char32, inT64>& ch_map,
const string& fontname,
int* raw_score,
vector<bool>* ch_flags) {
Expand All @@ -703,7 +703,7 @@ int FontUtils::FontScore(const unordered_map<char32, inT64>& ch_map,
}
*raw_score = 0;
int ok_chars = 0;
for (unordered_map<char32, inT64>::const_iterator it = ch_map.begin();
for (TessHashMap<char32, inT64>::const_iterator it = ch_map.begin();
it != ch_map.end(); ++it) {
bool covered = (IsWhitespace(it->first) ||
(pango_coverage_get(coverage, it->first)
Expand All @@ -721,7 +721,7 @@ int FontUtils::FontScore(const unordered_map<char32, inT64>& ch_map,


/* static */
string FontUtils::BestFonts(const unordered_map<char32, inT64>& ch_map,
string FontUtils::BestFonts(const TessHashMap<char32, inT64>& ch_map,
vector<pair<const char*, vector<bool> > >* fonts) {
const double kMinOKFraction = 0.99;
// Weighted fraction of characters that must be renderable in a font to make
Expand Down
5 changes: 3 additions & 2 deletions training/pango_font_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,16 @@ class FontUtils {
// In the flags vector, each flag is set according to whether the
// corresponding character (in order of iterating ch_map) can be rendered.
// The return string is a list of the acceptable fonts that were used.
static string BestFonts(const unordered_map<char32, inT64>& ch_map,
static string BestFonts(
const TessHashMap<char32, inT64>& ch_map,
vector<std::pair<const char*, vector<bool> > >* font_flag);

// FontScore returns the weighted renderability score of the given
// hash map character table in the given font. The unweighted score
// is also returned in raw_score.
// The values in the bool vector ch_flags correspond to whether the
// corresponding character (in order of iterating ch_map) can be rendered.
static int FontScore(const unordered_map<char32, inT64>& ch_map,
static int FontScore(const TessHashMap<char32, inT64>& ch_map,
const string& fontname, int* raw_score,
vector<bool>* ch_flags);

Expand Down
2 changes: 1 addition & 1 deletion training/stringrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class StringRenderer {
Boxa* page_boxes_;

// Objects cached for subsequent calls to RenderAllFontsToImage()
hash_map<char32, inT64> char_map_; // Time-saving char histogram.
TessHashMap<char32, inT64> char_map_; // Time-saving char histogram.
int total_chars_; // Number in the string to be rendered.
int font_index_; // Index of next font to use in font list.
int last_offset_; // Offset returned from last successful rendering
Expand Down

0 comments on commit 5750e72

Please sign in to comment.