float casts within fabs() - partial patch from issue 304

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@374 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
joregan 2010-05-27 01:45:47 +00:00
parent 428b1bb543
commit 8cd185d49f

View File

@ -710,25 +710,25 @@ char* TessBaseAPI::GetUTF8Text() {
static bool IsParagraphBreak(TBOX bbox_cur, TBOX bbox_prev, static bool IsParagraphBreak(TBOX bbox_cur, TBOX bbox_prev,
int right, int line_height) { int right, int line_height) {
// Check if the distance between lines is larger than the normal leading, // Check if the distance between lines is larger than the normal leading,
if (fabs(bbox_cur.bottom() - bbox_prev.bottom()) > line_height * 2) if (fabs((float)(bbox_cur.bottom() - bbox_prev.bottom())) > line_height * 2)
return true; return true;
// Check if the distance between left bounds of the two lines is nearly the // Check if the distance between left bounds of the two lines is nearly the
// same as between their right bounds (if so, then both lines probably belong // same as between their right bounds (if so, then both lines probably belong
// to the same paragraph, maybe a centered one). // to the same paragraph, maybe a centered one).
if (fabs((bbox_cur.left() - bbox_prev.left()) - if (fabs((float)((bbox_cur.left() - bbox_prev.left()) -
(bbox_prev.right() - bbox_cur.right())) < line_height) (bbox_prev.right() - bbox_cur.right()))) < line_height)
return false; return false;
// Check if there is a paragraph indent at this line (either -ve or +ve). // Check if there is a paragraph indent at this line (either -ve or +ve).
if (fabs(bbox_cur.left() - bbox_prev.left()) > line_height) if (fabs((float)(bbox_cur.left() - bbox_prev.left())) > line_height)
return true; return true;
// Check if both current and previous line don't reach the right bound of the // Check if both current and previous line don't reach the right bound of the
// block, but the distance is different. This will cause all lines in a verse // block, but the distance is different. This will cause all lines in a verse
// to be treated as separate paragraphs, but most probably will not split // to be treated as separate paragraphs, but most probably will not split
// block-quotes to separate lines (at least if the text is justified). // block-quotes to separate lines (at least if the text is justified).
if (fabs(bbox_cur.right() - bbox_prev.right()) > line_height && if (fabs((float)(bbox_cur.right() - bbox_prev.right())) > line_height &&
right - bbox_cur.right() > line_height && right - bbox_cur.right() > line_height &&
right - bbox_prev.right() > line_height) right - bbox_prev.right() > line_height)
return true; return true;