mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-19 15:03:45 +08:00
Merge pull request #3113 from stweil/pango
Remove unused functions FontUtils::GetAllRenderableCharacters
This commit is contained in:
commit
0ded9f3573
@ -622,49 +622,6 @@ static void CharCoverageMapToBitmap(PangoCoverage* coverage,
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void FontUtils::GetAllRenderableCharacters(std::vector<bool>* unichar_bitmap) {
|
||||
const std::vector<std::string>& all_fonts = ListAvailableFonts();
|
||||
return GetAllRenderableCharacters(all_fonts, unichar_bitmap);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void FontUtils::GetAllRenderableCharacters(const std::string& font_name,
|
||||
std::vector<bool>* unichar_bitmap) {
|
||||
PangoFontInfo font_info(font_name);
|
||||
PangoFont* font = font_info.ToPangoFont();
|
||||
if (font != nullptr) {
|
||||
// Font found.
|
||||
PangoCoverage* coverage = pango_font_get_coverage(font, nullptr);
|
||||
CharCoverageMapToBitmap(coverage, unichar_bitmap);
|
||||
pango_coverage_unref(coverage);
|
||||
g_object_unref(font);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void FontUtils::GetAllRenderableCharacters(const std::vector<std::string>& fonts,
|
||||
std::vector<bool>* unichar_bitmap) {
|
||||
// Form the union of coverage maps from the fonts
|
||||
PangoCoverage* all_coverage = pango_coverage_new();
|
||||
tlog(1, "Processing %u fonts\n", static_cast<unsigned>(fonts.size()));
|
||||
for (unsigned i = 0; i < fonts.size(); ++i) {
|
||||
PangoFontInfo font_info(fonts[i]);
|
||||
PangoFont* font = font_info.ToPangoFont();
|
||||
if (font != nullptr) {
|
||||
// Font found.
|
||||
PangoCoverage* coverage = pango_font_get_coverage(font, nullptr);
|
||||
// Mark off characters that any font can render.
|
||||
pango_coverage_max(all_coverage, coverage);
|
||||
pango_coverage_unref(coverage);
|
||||
g_object_unref(font);
|
||||
}
|
||||
}
|
||||
CharCoverageMapToBitmap(all_coverage, unichar_bitmap);
|
||||
pango_coverage_unref(all_coverage);
|
||||
}
|
||||
|
||||
|
||||
// Utilities written to be backward compatible with StringRender
|
||||
|
||||
/* static */
|
||||
|
@ -170,15 +170,6 @@ class FontUtils {
|
||||
const std::vector<std::string>& all_fonts,
|
||||
std::string* font_name, std::vector<std::string>* graphemes);
|
||||
|
||||
// Returns a bitmask where the value of true at index 'n' implies that unicode
|
||||
// value 'n' is renderable by at least one available font.
|
||||
static void GetAllRenderableCharacters(std::vector<bool>* unichar_bitmap);
|
||||
// Variant of the above function that inspects only the provided font names.
|
||||
static void GetAllRenderableCharacters(const std::vector<std::string>& font_names,
|
||||
std::vector<bool>* unichar_bitmap);
|
||||
static void GetAllRenderableCharacters(const std::string& font_name,
|
||||
std::vector<bool>* unichar_bitmap);
|
||||
|
||||
// NOTE: The following utilities were written to be backward compatible with
|
||||
// StringRender.
|
||||
|
||||
|
@ -275,6 +275,9 @@ TEST_F(FontUtilsTest, DoesFailToSelectFont) {
|
||||
&selected_font, &graphemes));
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Needs fix. FontUtils::GetAllRenderableCharacters was removed
|
||||
// because of deprecated pango_coverage_max.
|
||||
TEST_F(FontUtilsTest, GetAllRenderableCharacters) {
|
||||
const int32_t kHindiChar = 0x0905;
|
||||
const int32_t kArabicChar = 0x0623;
|
||||
@ -315,4 +318,6 @@ TEST_F(FontUtilsTest, GetAllRenderableCharacters) {
|
||||
unicode_mask.clear();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user