tesseract  4.0.0-1-g2a2b
tesseract::FontInfo Struct Reference

#include <fontinfo.h>

Public Member Functions

 FontInfo ()
 
 ~FontInfo ()=default
 
bool Serialize (FILE *fp) const
 
bool DeSerialize (TFile *fp)
 
void init_spacing (int unicharset_size)
 
void add_spacing (UNICHAR_ID uch_id, FontSpacingInfo *spacing_info)
 
const FontSpacingInfoget_spacing (UNICHAR_ID uch_id) const
 
bool get_spacing (UNICHAR_ID prev_uch_id, UNICHAR_ID uch_id, int *spacing) const
 
bool is_italic () const
 
bool is_bold () const
 
bool is_fixed_pitch () const
 
bool is_serif () const
 
bool is_fraktur () const
 

Public Attributes

char * name
 
uint32_t properties
 
int32_t universal_id
 
GenericVector< FontSpacingInfo * > * spacing_vec
 

Detailed Description

Definition at line 62 of file fontinfo.h.

Constructor & Destructor Documentation

◆ FontInfo()

tesseract::FontInfo::FontInfo ( )
inline

Definition at line 63 of file fontinfo.h.

63 : name(nullptr), properties(0), universal_id(0), spacing_vec(nullptr) {}
uint32_t properties
Definition: fontinfo.h:118
GenericVector< FontSpacingInfo * > * spacing_vec
Definition: fontinfo.h:125
int32_t universal_id
Definition: fontinfo.h:123

◆ ~FontInfo()

tesseract::FontInfo::~FontInfo ( )
default

Member Function Documentation

◆ add_spacing()

void tesseract::FontInfo::add_spacing ( UNICHAR_ID  uch_id,
FontSpacingInfo spacing_info 
)
inline

Definition at line 80 of file fontinfo.h.

80  {
81  ASSERT_HOST(spacing_vec != nullptr && spacing_vec->size() > uch_id);
82  (*spacing_vec)[uch_id] = spacing_info;
83  }
GenericVector< FontSpacingInfo * > * spacing_vec
Definition: fontinfo.h:125
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ DeSerialize()

bool tesseract::FontInfo::DeSerialize ( TFile fp)

Definition at line 34 of file fontinfo.cpp.

34  {
35  if (!read_info(fp, this)) return false;
36  if (!read_spacing_info(fp, this)) return false;
37  return true;
38 }
bool read_spacing_info(TFile *f, FontInfo *fi)
Definition: fontinfo.cpp:169
bool read_info(TFile *f, FontInfo *fi)
Definition: fontinfo.cpp:152

◆ get_spacing() [1/2]

const FontSpacingInfo* tesseract::FontInfo::get_spacing ( UNICHAR_ID  uch_id) const
inline

Definition at line 86 of file fontinfo.h.

86  {
87  return (spacing_vec == nullptr || spacing_vec->size() <= uch_id) ?
88  nullptr : (*spacing_vec)[uch_id];
89  }
GenericVector< FontSpacingInfo * > * spacing_vec
Definition: fontinfo.h:125

◆ get_spacing() [2/2]

bool tesseract::FontInfo::get_spacing ( UNICHAR_ID  prev_uch_id,
UNICHAR_ID  uch_id,
int *  spacing 
) const
inline

Definition at line 93 of file fontinfo.h.

95  {
96  const FontSpacingInfo *prev_fsi = this->get_spacing(prev_uch_id);
97  const FontSpacingInfo *fsi = this->get_spacing(uch_id);
98  if (prev_fsi == nullptr || fsi == nullptr) return false;
99  int i = 0;
100  for (; i < prev_fsi->kerned_unichar_ids.size(); ++i) {
101  if (prev_fsi->kerned_unichar_ids[i] == uch_id) break;
102  }
103  if (i < prev_fsi->kerned_unichar_ids.size()) {
104  *spacing = prev_fsi->kerned_x_gaps[i];
105  } else {
106  *spacing = prev_fsi->x_gap_after + fsi->x_gap_before;
107  }
108  return true;
109  }
const FontSpacingInfo * get_spacing(UNICHAR_ID uch_id) const
Definition: fontinfo.h:86

◆ init_spacing()

void tesseract::FontInfo::init_spacing ( int  unicharset_size)
inline

Definition at line 73 of file fontinfo.h.

73  {
75  spacing_vec->init_to_size(unicharset_size, nullptr);
76  }
GenericVector< FontSpacingInfo * > * spacing_vec
Definition: fontinfo.h:125

◆ is_bold()

bool tesseract::FontInfo::is_bold ( ) const
inline

Definition at line 112 of file fontinfo.h.

112 { return (properties & 2) != 0; }
uint32_t properties
Definition: fontinfo.h:118

◆ is_fixed_pitch()

bool tesseract::FontInfo::is_fixed_pitch ( ) const
inline

Definition at line 113 of file fontinfo.h.

113 { return (properties & 4) != 0; }
uint32_t properties
Definition: fontinfo.h:118

◆ is_fraktur()

bool tesseract::FontInfo::is_fraktur ( ) const
inline

Definition at line 115 of file fontinfo.h.

115 { return (properties & 16) != 0; }
uint32_t properties
Definition: fontinfo.h:118

◆ is_italic()

bool tesseract::FontInfo::is_italic ( ) const
inline

Definition at line 111 of file fontinfo.h.

111 { return properties & 1; }
uint32_t properties
Definition: fontinfo.h:118

◆ is_serif()

bool tesseract::FontInfo::is_serif ( ) const
inline

Definition at line 114 of file fontinfo.h.

114 { return (properties & 8) != 0; }
uint32_t properties
Definition: fontinfo.h:118

◆ Serialize()

bool tesseract::FontInfo::Serialize ( FILE *  fp) const

Definition at line 27 of file fontinfo.cpp.

27  {
28  if (!write_info(fp, *this)) return false;
29  if (!write_spacing_info(fp, *this)) return false;
30  return true;
31 }
bool write_spacing_info(FILE *f, const FontInfo &fi)
Definition: fontinfo.cpp:197
bool write_info(FILE *f, const FontInfo &fi)
Definition: fontinfo.cpp:162

Member Data Documentation

◆ name

char* tesseract::FontInfo::name

Definition at line 117 of file fontinfo.h.

◆ properties

uint32_t tesseract::FontInfo::properties

Definition at line 118 of file fontinfo.h.

◆ spacing_vec

GenericVector<FontSpacingInfo *>* tesseract::FontInfo::spacing_vec

Definition at line 125 of file fontinfo.h.

◆ universal_id

int32_t tesseract::FontInfo::universal_id

Definition at line 123 of file fontinfo.h.


The documentation for this struct was generated from the following files: