tesseract 4.1.1
Loading...
Searching...
No Matches
output.h File Reference

Go to the source code of this file.

Functions

char determine_newline_type (WERD *word, BLOCK *block, WERD *next_word, BLOCK *next_block)
 

Function Documentation

◆ determine_newline_type()

char determine_newline_type ( WERD word,
BLOCK block,
WERD next_word,
BLOCK next_block 
)

test line ends

Parameters
wordword to do
blockcurrent block
next_wordnext word
next_blockblock of next word

Definition at line 213 of file output.cpp.

218 {
219 int16_t end_gap; //to right edge
220 int16_t width; //of next word
221 TBOX word_box; //bounding
222 TBOX next_box; //next word
223 TBOX block_box; //block bounding
224
225 if (!word->flag (W_EOL))
226 return false; //not end of line
227 if (next_word == nullptr || next_block == nullptr || block != next_block)
228 return CTRL_NEWLINE;
229 if (next_word->space () > 0)
230 return CTRL_HARDLINE; //it is tabbed
231 word_box = word->bounding_box ();
232 next_box = next_word->bounding_box ();
233 block_box = block->pdblk.bounding_box ();
234 //gap to eol
235 end_gap = block_box.right () - word_box.right ();
236 end_gap -= static_cast<int32_t>(block->space ());
237 width = next_box.right () - next_box.left ();
238 // tprintf("end_gap=%d-%d=%d, width=%d-%d=%d, nl=%d\n",
239 // block_box.right(),word_box.right(),end_gap,
240 // next_box.right(),next_box.left(),width,
241 // end_gap>width ? CTRL_HARDLINE : CTRL_NEWLINE);
242 return end_gap > width ? CTRL_HARDLINE : CTRL_NEWLINE;
243}
#define CTRL_NEWLINE
Definition: output.cpp:32
#define CTRL_HARDLINE
Definition: output.cpp:33
@ W_EOL
end of line
Definition: werd.h:33
int16_t space() const
return spacing
Definition: ocrblock.h:98
PDBLK pdblk
Page Description Block.
Definition: ocrblock.h:190
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:59
Definition: rect.h:34
int16_t left() const
Definition: rect.h:72
int16_t right() const
Definition: rect.h:79
uint8_t space()
Definition: werd.h:99
TBOX bounding_box() const
Definition: werd.cpp:148
bool flag(WERD_FLAGS mask) const
Definition: werd.h:117