Skip to content

Commit

Permalink
improve error messages for font-subset (flutter#20410)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield authored Aug 11, 2020
1 parent be78eba commit 93cdb90
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tools/font-subset/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ int main(int argc, char** argv) {
hb_blob_create_from_file(input_file_path.c_str()));
if (!hb_blob_get_length(font_blob.get())) {
std::cerr << "Failed to load input font " << input_file_path
<< "; aborting." << std::endl;
<< "; aborting. This error indicates that the font is invalid or "
"the current version of Harfbuzz is unable to process it."
<< std::endl;
return -1;
}

HarfbuzzWrappers::HbFacePtr font_face(hb_face_create(font_blob.get(), 0));
if (font_face.get() == hb_face_get_empty()) {
std::cerr << "Failed to load input font face " << input_file_path
<< "; aborting." << std::endl;
<< "; aborting. This error indicates that the font is invalid or "
"the current version of Harfbuzz is unable to process it."
<< std::endl;
return -1;
}

Expand Down Expand Up @@ -103,13 +107,18 @@ int main(int argc, char** argv) {
HarfbuzzWrappers::HbFacePtr new_face(hb_subset(font_face.get(), input.get()));

if (new_face.get() == hb_face_get_empty()) {
std::cerr << "Failed to subset font; aborting." << std::endl;
std::cerr
<< "Failed to subset font; aborting. This error normally indicates "
"the current version of Harfbuzz is unable to process it."
<< std::endl;
return -1;
}

HarfbuzzWrappers::HbBlobPtr result(hb_face_reference_blob(new_face.get()));
if (!hb_blob_get_length(result.get())) {
std::cerr << "Failed get new font bytes; aborting" << std::endl;
std::cerr << "Failed get new font bytes; aborting. This error may indicate "
"low availability of memory or a bug in Harfbuzz."
<< std::endl;
return -1;
}

Expand Down

0 comments on commit 93cdb90

Please sign in to comment.