tesseract  4.0.0-1-g2a2b
output.cpp File Reference
#include <cctype>
#include <cerrno>
#include <cstring>
#include "helpers.h"
#include "tessvars.h"
#include "control.h"
#include "reject.h"
#include "docqual.h"
#include "output.h"
#include "globals.h"
#include "tesseractclass.h"

Go to the source code of this file.

Namespaces

 tesseract
 

Macros

#define EPAPER_EXT   ".ep"
 
#define PAGE_YSIZE   3508
 
#define CTRL_INSET   '\024'
 
#define CTRL_FONT   '\016'
 
#define CTRL_DEFAULT   '\017'
 
#define CTRL_SHIFT   '\022'
 
#define CTRL_TAB   '\011'
 
#define CTRL_NEWLINE   '\012'
 
#define CTRL_HARDLINE   '\015'
 

Functions

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

Macro Definition Documentation

◆ CTRL_DEFAULT

#define CTRL_DEFAULT   '\017'

Definition at line 36 of file output.cpp.

◆ CTRL_FONT

#define CTRL_FONT   '\016'

Definition at line 35 of file output.cpp.

◆ CTRL_HARDLINE

#define CTRL_HARDLINE   '\015'

Definition at line 40 of file output.cpp.

◆ CTRL_INSET

#define CTRL_INSET   '\024'

Definition at line 34 of file output.cpp.

◆ CTRL_NEWLINE

#define CTRL_NEWLINE   '\012'

Definition at line 39 of file output.cpp.

◆ CTRL_SHIFT

#define CTRL_SHIFT   '\022'

Definition at line 37 of file output.cpp.

◆ CTRL_TAB

#define CTRL_TAB   '\011'

Definition at line 38 of file output.cpp.

◆ EPAPER_EXT

#define EPAPER_EXT   ".ep"

Definition at line 32 of file output.cpp.

◆ PAGE_YSIZE

#define PAGE_YSIZE   3508

Definition at line 33 of file output.cpp.

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