Skip to content

Commit

Permalink
Remove unused functions FontUtils::GetAllRenderableCharacters
Browse files Browse the repository at this point in the history
They used the function pango_coverage_max which does nothing and
which has been deprecated since pango version 1.44.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Oct 3, 2020
1 parent 45413e6 commit 7c4ef88
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 52 deletions.
43 changes: 0 additions & 43 deletions src/training/pango_font_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
9 changes: 0 additions & 9 deletions src/training/pango_font_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 5 additions & 0 deletions unittest/pango_font_info_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -315,4 +318,6 @@ TEST_F(FontUtilsTest, GetAllRenderableCharacters) {
unicode_mask.clear();
}
}
#endif

} // namespace

0 comments on commit 7c4ef88

Please sign in to comment.