tesseract  5.0.0-alpha-619-ge9db
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 211 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);
WERD::flag
bool flag(WERD_FLAGS mask) const
Definition: werd.h:116
PDBLK::bounding_box
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:58
WERD::bounding_box
TBOX bounding_box() const
Definition: werd.cpp:147
BLOCK::space
int16_t space() const
return spacing
Definition: ocrblock.h:97
BLOCK::pdblk
PDBLK pdblk
Page Description Block.
Definition: ocrblock.h:189
WERD::space
uint8_t space()
Definition: werd.h:98
W_EOL
end of line
Definition: werd.h:47
CTRL_HARDLINE
#define CTRL_HARDLINE
Definition: output.cpp:32
TBOX::left
int16_t left() const
Definition: rect.h:71
CTRL_NEWLINE
#define CTRL_NEWLINE
Definition: output.cpp:31
TBOX::right
int16_t right() const
Definition: rect.h:78
TBOX
Definition: rect.h:33