WordFontAttributes: Check that word != nullptr earlier. Fix #1665

This commit is contained in:
Amit D 2018-06-13 23:38:27 +03:00 committed by GitHub
parent 8b64602a86
commit 6f85de22bc
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.