tesseract  4.00.00dev
output.h File Reference
#include "params.h"
#include "pageres.h"

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 245 of file output.cpp.

250  {
251  inT16 end_gap; //to right edge
252  inT16 width; //of next word
253  TBOX word_box; //bounding
254  TBOX next_box; //next word
255  TBOX block_box; //block bounding
256 
257  if (!word->flag (W_EOL))
258  return FALSE; //not end of line
259  if (next_word == NULL || next_block == NULL || block != next_block)
260  return CTRL_NEWLINE;
261  if (next_word->space () > 0)
262  return CTRL_HARDLINE; //it is tabbed
263  word_box = word->bounding_box ();
264  next_box = next_word->bounding_box ();
265  block_box = block->bounding_box ();
266  //gap to eol
267  end_gap = block_box.right () - word_box.right ();
268  end_gap -= (inT32) block->space ();
269  width = next_box.right () - next_box.left ();
270  // tprintf("end_gap=%d-%d=%d, width=%d-%d=%d, nl=%d\n",
271  // block_box.right(),word_box.right(),end_gap,
272  // next_box.right(),next_box.left(),width,
273  // end_gap>width ? CTRL_HARDLINE : CTRL_NEWLINE);
274  return end_gap > width ? CTRL_HARDLINE : CTRL_NEWLINE;
275 }
#define CTRL_HARDLINE
Definition: output.cpp:48
int32_t inT32
Definition: host.h:38
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:59
Definition: werd.h:36
TBOX bounding_box() const
Definition: werd.cpp:160
int16_t inT16
Definition: host.h:36
BOOL8 flag(WERD_FLAGS mask) const
Definition: werd.h:128
inT16 left() const
Definition: rect.h:68
#define FALSE
Definition: capi.h:46
Definition: rect.h:30
#define CTRL_NEWLINE
Definition: output.cpp:47
inT16 right() const
Definition: rect.h:75
uinT8 space()
Definition: werd.h:104
inT16 space() const
return spacing
Definition: ocrblock.h:102