Merge pull request #1669 from amitdo/amitdo-fix-1665

WordFontAttributes: Check that word != nullptr earlier. Fix #1665
This commit is contained in:
Egor Pugin 2018-06-14 00:12:15 +03:00 committed by GitHub
commit 87635c1ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -166,13 +166,13 @@ const char* LTRResultIterator::WordFontAttributes(bool* is_bold,
bool* is_smallcaps,
int* pointsize,
int* font_id) const {
if (it_->word() == nullptr) return nullptr; // Already at the end!
float row_height = it_->row()->row->x_height() +
it_->row()->row->ascenders() - it_->row()->row->descenders();
// Convert from pixels to printers points.
*pointsize = scaled_yres_ > 0
? static_cast<int>(row_height * kPointsPerInch / scaled_yres_ + 0.5)
: 0;
if (it_->word() == nullptr) return nullptr; // Already at the end!
if (it_->word()->fontinfo == nullptr) {
*font_id = -1;
return nullptr; // No font information.