tesseract  4.0.0-1-g2a2b
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 220 of file output.cpp.

225  {
226  int16_t end_gap; //to right edge
227  int16_t width; //of next word
228  TBOX word_box; //bounding
229  TBOX next_box; //next word
230  TBOX block_box; //block bounding
231 
232  if (!word->flag (W_EOL))
233  return FALSE; //not end of line
234  if (next_word == nullptr || next_block == nullptr || block != next_block)
235  return CTRL_NEWLINE;
236  if (next_word->space () > 0)
237  return CTRL_HARDLINE; //it is tabbed
238  word_box = word->bounding_box ();
239  next_box = next_word->bounding_box ();
240  block_box = block->pdblk.bounding_box ();
241  //gap to eol
242  end_gap = block_box.right () - word_box.right ();
243  end_gap -= (int32_t) block->space ();
244  width = next_box.right () - next_box.left ();
245  // tprintf("end_gap=%d-%d=%d, width=%d-%d=%d, nl=%d\n",
246  // block_box.right(),word_box.right(),end_gap,
247  // next_box.right(),next_box.left(),width,
248  // end_gap>width ? CTRL_HARDLINE : CTRL_NEWLINE);
249  return end_gap > width ? CTRL_HARDLINE : CTRL_NEWLINE;
250 }
int16_t space() const
return spacing
Definition: ocrblock.h:100
#define CTRL_NEWLINE
Definition: output.cpp:39
TBOX bounding_box() const
Definition: werd.cpp:159
Definition: rect.h:34
Definition: werd.h:35
uint8_t space()
Definition: werd.h:102
int16_t left() const
Definition: rect.h:72
bool flag(WERD_FLAGS mask) const
Definition: werd.h:126
#define FALSE
Definition: capi.h:52
#define CTRL_HARDLINE
Definition: output.cpp:40
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:60
int16_t right() const
Definition: rect.h:79
PDBLK pdblk
Definition: ocrblock.h:192