tesseract  3.05.00
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UNICHARSET Class Reference

#include <unicharset.h>

Public Types

enum  Direction {
  U_LEFT_TO_RIGHT = 0, U_RIGHT_TO_LEFT = 1, U_EUROPEAN_NUMBER = 2, U_EUROPEAN_NUMBER_SEPARATOR = 3,
  U_EUROPEAN_NUMBER_TERMINATOR = 4, U_ARABIC_NUMBER = 5, U_COMMON_NUMBER_SEPARATOR = 6, U_BLOCK_SEPARATOR = 7,
  U_SEGMENT_SEPARATOR = 8, U_WHITE_SPACE_NEUTRAL = 9, U_OTHER_NEUTRAL = 10, U_LEFT_TO_RIGHT_EMBEDDING = 11,
  U_LEFT_TO_RIGHT_OVERRIDE = 12, U_RIGHT_TO_LEFT_ARABIC = 13, U_RIGHT_TO_LEFT_EMBEDDING = 14, U_RIGHT_TO_LEFT_OVERRIDE = 15,
  U_POP_DIRECTIONAL_FORMAT = 16, U_DIR_NON_SPACING_MARK = 17, U_BOUNDARY_NEUTRAL = 18, U_CHAR_DIRECTION_COUNT
}
 

Public Member Functions

 UNICHARSET ()
 
 ~UNICHARSET ()
 
UNICHAR_ID unichar_to_id (const char *const unichar_repr) const
 
UNICHAR_ID unichar_to_id (const char *const unichar_repr, int length) const
 
int step (const char *str) const
 
bool encodable_string (const char *str, int *first_bad_position) const
 
bool encode_string (const char *str, bool give_up_on_failure, GenericVector< UNICHAR_ID > *encoding, GenericVector< char > *lengths, int *encoded_length) const
 
const char * id_to_unichar (UNICHAR_ID id) const
 
const char * id_to_unichar_ext (UNICHAR_ID id) const
 
STRING debug_str (UNICHAR_ID id) const
 
STRING debug_str (const char *unichar_repr) const
 
void unichar_insert (const char *const unichar_repr)
 
bool contains_unichar_id (UNICHAR_ID unichar_id) const
 
bool contains_unichar (const char *const unichar_repr) const
 
bool contains_unichar (const char *const unichar_repr, int length) const
 
bool eq (UNICHAR_ID unichar_id, const char *const unichar_repr) const
 
void delete_pointers_in_unichars ()
 
void clear ()
 
int size () const
 
void reserve (int unichars_number)
 
bool save_to_file (const char *const filename) const
 
bool save_to_file (FILE *file) const
 
bool save_to_file (tesseract::TFile *file) const
 
bool save_to_string (STRING *str) const
 
bool load_from_inmemory_file (const char *const memory, int mem_size, bool skip_fragments)
 
bool load_from_inmemory_file (const char *const memory, int mem_size)
 
bool load_from_file (const char *const filename, bool skip_fragments)
 
bool load_from_file (const char *const filename)
 
bool load_from_file (FILE *file, bool skip_fragments)
 
bool load_from_file (FILE *file)
 
bool load_from_file (tesseract::TFile *file, bool skip_fragments)
 
void post_load_setup ()
 
bool major_right_to_left () const
 
void set_black_and_whitelist (const char *blacklist, const char *whitelist, const char *unblacklist)
 
void set_isalpha (UNICHAR_ID unichar_id, bool value)
 
void set_islower (UNICHAR_ID unichar_id, bool value)
 
void set_isupper (UNICHAR_ID unichar_id, bool value)
 
void set_isdigit (UNICHAR_ID unichar_id, bool value)
 
void set_ispunctuation (UNICHAR_ID unichar_id, bool value)
 
void set_isngram (UNICHAR_ID unichar_id, bool value)
 
void set_script (UNICHAR_ID unichar_id, const char *value)
 
void set_other_case (UNICHAR_ID unichar_id, UNICHAR_ID other_case)
 
void set_direction (UNICHAR_ID unichar_id, UNICHARSET::Direction value)
 
void set_mirror (UNICHAR_ID unichar_id, UNICHAR_ID mirror)
 
void set_normed (UNICHAR_ID unichar_id, const char *normed)
 
void set_normed_ids (UNICHAR_ID unichar_id)
 
bool get_isalpha (UNICHAR_ID unichar_id) const
 
bool get_islower (UNICHAR_ID unichar_id) const
 
bool get_isupper (UNICHAR_ID unichar_id) const
 
bool get_isdigit (UNICHAR_ID unichar_id) const
 
bool get_ispunctuation (UNICHAR_ID unichar_id) const
 
bool get_isngram (UNICHAR_ID unichar_id) const
 
bool get_isprivate (UNICHAR_ID unichar_id) const
 
bool top_bottom_useful () const
 
void set_ranges_empty ()
 
void SetPropertiesFromOther (const UNICHARSET &src)
 
void PartialSetPropertiesFromOther (int start_index, const UNICHARSET &src)
 
void ExpandRangesFromOther (const UNICHARSET &src)
 
void CopyFrom (const UNICHARSET &src)
 
void AppendOtherUnicharset (const UNICHARSET &src)
 
bool SizesDistinct (UNICHAR_ID id1, UNICHAR_ID id2) const
 
void get_top_bottom (UNICHAR_ID unichar_id, int *min_bottom, int *max_bottom, int *min_top, int *max_top) const
 
void set_top_bottom (UNICHAR_ID unichar_id, int min_bottom, int max_bottom, int min_top, int max_top)
 
void get_width_stats (UNICHAR_ID unichar_id, float *width, float *width_sd) const
 
void set_width_stats (UNICHAR_ID unichar_id, float width, float width_sd)
 
void get_bearing_stats (UNICHAR_ID unichar_id, float *bearing, float *bearing_sd) const
 
void set_bearing_stats (UNICHAR_ID unichar_id, float bearing, float bearing_sd)
 
void get_advance_stats (UNICHAR_ID unichar_id, float *advance, float *advance_sd) const
 
void set_advance_stats (UNICHAR_ID unichar_id, float advance, float advance_sd)
 
bool PropertiesIncomplete (UNICHAR_ID unichar_id) const
 
int get_script (UNICHAR_ID unichar_id) const
 
unsigned int get_properties (UNICHAR_ID unichar_id) const
 
char get_chartype (UNICHAR_ID unichar_id) const
 
UNICHAR_ID get_other_case (UNICHAR_ID unichar_id) const
 
Direction get_direction (UNICHAR_ID unichar_id) const
 
UNICHAR_ID get_mirror (UNICHAR_ID unichar_id) const
 
UNICHAR_ID to_lower (UNICHAR_ID unichar_id) const
 
UNICHAR_ID to_upper (UNICHAR_ID unichar_id) const
 
bool has_special_codes () const
 
bool AnyRepeatedUnicodes () const
 
const CHAR_FRAGMENTget_fragment (UNICHAR_ID unichar_id) const
 
bool get_isalpha (const char *const unichar_repr) const
 
bool get_islower (const char *const unichar_repr) const
 
bool get_isupper (const char *const unichar_repr) const
 
bool get_isdigit (const char *const unichar_repr) const
 
bool get_ispunctuation (const char *const unichar_repr) const
 
unsigned int get_properties (const char *const unichar_repr) const
 
char get_chartype (const char *const unichar_repr) const
 
int get_script (const char *const unichar_repr) const
 
const CHAR_FRAGMENTget_fragment (const char *const unichar_repr) const
 
bool get_isalpha (const char *const unichar_repr, int length) const
 
bool get_islower (const char *const unichar_repr, int length) const
 
bool get_isupper (const char *const unichar_repr, int length) const
 
bool get_isdigit (const char *const unichar_repr, int length) const
 
bool get_ispunctuation (const char *const unichar_repr, int length) const
 
const char * get_normed_unichar (UNICHAR_ID unichar_id) const
 
const GenericVector< UNICHAR_ID > & normed_ids (UNICHAR_ID unichar_id) const
 
int get_script (const char *const unichar_repr, int length) const
 
int get_script_table_size () const
 
const char * get_script_from_script_id (int id) const
 
int get_script_id_from_name (const char *script_name) const
 
bool is_null_script (const char *script) const
 
int add_script (const char *script)
 
bool get_enabled (UNICHAR_ID unichar_id) const
 
int null_sid () const
 
int common_sid () const
 
int latin_sid () const
 
int cyrillic_sid () const
 
int greek_sid () const
 
int han_sid () const
 
int hiragana_sid () const
 
int katakana_sid () const
 
int default_sid () const
 
bool script_has_upper_lower () const
 
bool script_has_xheight () const
 

Static Public Member Functions

static STRING debug_utf8_str (const char *str)
 

Static Public Attributes

static TESS_API const char * kCustomLigatures [][2]
 
static const char * kSpecialUnicharCodes [SPECIAL_UNICHAR_CODES_COUNT]
 

Detailed Description

Definition at line 139 of file unicharset.h.

Member Enumeration Documentation

Enumerator
U_LEFT_TO_RIGHT 
U_RIGHT_TO_LEFT 
U_EUROPEAN_NUMBER 
U_EUROPEAN_NUMBER_SEPARATOR 
U_EUROPEAN_NUMBER_TERMINATOR 
U_ARABIC_NUMBER 
U_COMMON_NUMBER_SEPARATOR 
U_BLOCK_SEPARATOR 
U_SEGMENT_SEPARATOR 
U_WHITE_SPACE_NEUTRAL 
U_OTHER_NEUTRAL 
U_LEFT_TO_RIGHT_EMBEDDING 
U_LEFT_TO_RIGHT_OVERRIDE 
U_RIGHT_TO_LEFT_ARABIC 
U_RIGHT_TO_LEFT_EMBEDDING 
U_RIGHT_TO_LEFT_OVERRIDE 
U_POP_DIRECTIONAL_FORMAT 
U_DIR_NON_SPACING_MARK 
U_BOUNDARY_NEUTRAL 
U_CHAR_DIRECTION_COUNT 

Definition at line 150 of file unicharset.h.

150  {
151  U_LEFT_TO_RIGHT = 0,
152  U_RIGHT_TO_LEFT = 1,
153  U_EUROPEAN_NUMBER = 2,
156  U_ARABIC_NUMBER = 5,
158  U_BLOCK_SEPARATOR = 7,
161  U_OTHER_NEUTRAL = 10,
169  U_BOUNDARY_NEUTRAL = 18,
171  };

Constructor & Destructor Documentation

UNICHARSET::UNICHARSET ( )

Definition at line 159 of file unicharset.cpp.

159  :
160  unichars(NULL),
161  ids(),
162  size_used(0),
163  size_reserved(0),
164  script_table(NULL),
165  script_table_size_used(0),
166  null_script("NULL") {
167  clear();
168  for (int i = 0; i < SPECIAL_UNICHAR_CODES_COUNT; ++i) {
170  if (i == UNICHAR_JOINED)
171  set_isngram(i, true);
172  }
173 }
void clear()
Definition: unicharset.h:265
void set_isngram(UNICHAR_ID unichar_id, bool value)
Definition: unicharset.h:413
static const char * kSpecialUnicharCodes[SPECIAL_UNICHAR_CODES_COUNT]
Definition: unicharset.h:147
void unichar_insert(const char *const unichar_repr)
Definition: unicharset.cpp:612
UNICHARSET::~UNICHARSET ( )

Definition at line 175 of file unicharset.cpp.

175  {
176  clear();
177 }
void clear()
Definition: unicharset.h:265

Member Function Documentation

int UNICHARSET::add_script ( const char *  script)

Definition at line 1002 of file unicharset.cpp.

1002  {
1003  for (int i = 0; i < script_table_size_used; ++i) {
1004  if (strcmp(script, script_table[i]) == 0)
1005  return i;
1006  }
1007  if (script_table_size_reserved == 0) {
1008  script_table_size_reserved = 8;
1009  script_table = new char*[script_table_size_reserved];
1010  }
1011  if (script_table_size_used + 1 >= script_table_size_reserved) {
1012  char** new_script_table = new char*[script_table_size_reserved * 2];
1013  memcpy(new_script_table, script_table, script_table_size_reserved * sizeof(char*));
1014  delete[] script_table;
1015  script_table = new_script_table;
1016  script_table_size_reserved = 2 * script_table_size_reserved;
1017  }
1018  script_table[script_table_size_used] = new char[strlen(script) + 1];
1019  strcpy(script_table[script_table_size_used], script);
1020  return script_table_size_used++;
1021 }
bool UNICHARSET::AnyRepeatedUnicodes ( ) const

Definition at line 986 of file unicharset.cpp.

986  {
987  int start_id = 0;
989  for (int id = start_id; id < size_used; ++id) {
990  // Convert to unicodes.
991  GenericVector<int> unicodes;
992  if (UNICHAR::UTF8ToUnicode(get_normed_unichar(id), &unicodes) &&
993  unicodes.size() > 1) {
994  for (int u = 1; u < unicodes.size(); ++u) {
995  if (unicodes[u - 1] == unicodes[u]) return true;
996  }
997  }
998  }
999  return false;
1000 }
int size() const
Definition: genericvector.h:72
bool has_special_codes() const
Definition: unicharset.h:669
const char * get_normed_unichar(UNICHAR_ID unichar_id) const
Definition: unicharset.h:775
static bool UTF8ToUnicode(const char *utf8_str, GenericVector< int > *unicodes)
Definition: unichar.cpp:211
void UNICHARSET::AppendOtherUnicharset ( const UNICHARSET src)

Definition at line 439 of file unicharset.cpp.

439  {
440  int initial_used = size_used;
441  for (int ch = 0; ch < src.size_used; ++ch) {
442  const UNICHAR_PROPERTIES& src_props = src.unichars[ch].properties;
443  const char* utf8 = src.id_to_unichar(ch);
444  if (ch >= SPECIAL_UNICHAR_CODES_COUNT && src_props.AnyRangeEmpty()) {
445  // Only use fully valid entries.
446  tprintf("Bad properties for index %d, char %s: "
447  "%d,%d %d,%d %g,%g %g,%g %g,%g\n",
448  ch, utf8, src_props.min_bottom, src_props.max_bottom,
449  src_props.min_top, src_props.max_top,
450  src_props.width, src_props.width_sd,
451  src_props.bearing, src_props.bearing_sd,
452  src_props.advance, src_props.advance_sd);
453  continue;
454  }
455  int id = size_used;
456  if (contains_unichar(utf8)) {
457  id = unichar_to_id(utf8);
458  // Just expand current ranges.
459  unichars[id].properties.ExpandRangesFrom(src_props);
460  } else {
461  unichar_insert(utf8);
462  unichars[id].properties.SetRangesEmpty();
463  }
464  }
465  // Set properties, including mirror and other_case, WITHOUT reordering
466  // the unicharset.
467  PartialSetPropertiesFromOther(initial_used, src);
468 }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
#define tprintf(...)
Definition: tprintf.h:31
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
bool contains_unichar(const char *const unichar_repr) const
Definition: unicharset.cpp:644
void PartialSetPropertiesFromOther(int start_index, const UNICHARSET &src)
Definition: unicharset.cpp:380
void unichar_insert(const char *const unichar_repr)
Definition: unicharset.cpp:612
void UNICHARSET::clear ( )
inline

Definition at line 265 of file unicharset.h.

265  {
266  if (script_table != NULL) {
267  for (int i = 0; i < script_table_size_used; ++i)
268  delete[] script_table[i];
269  delete[] script_table;
270  script_table = NULL;
271  script_table_size_used = 0;
272  }
273  if (unichars != NULL) {
275  delete[] unichars;
276  unichars = NULL;
277  }
278  script_table_size_reserved = 0;
279  size_reserved = 0;
280  size_used = 0;
281  ids.clear();
282  top_bottom_set_ = false;
283  script_has_upper_lower_ = false;
284  script_has_xheight_ = false;
285  null_sid_ = 0;
286  common_sid_ = 0;
287  latin_sid_ = 0;
288  cyrillic_sid_ = 0;
289  greek_sid_ = 0;
290  han_sid_ = 0;
291  hiragana_sid_ = 0;
292  katakana_sid_ = 0;
293  }
void clear()
Definition: unicharmap.cpp:154
void delete_pointers_in_unichars()
Definition: unicharset.h:255
int UNICHARSET::common_sid ( ) const
inline

Definition at line 831 of file unicharset.h.

831 { return common_sid_; }
bool UNICHARSET::contains_unichar ( const char *const  unichar_repr) const

Definition at line 644 of file unicharset.cpp.

644  {
645  return ids.contains(unichar_repr);
646 }
bool contains(const char *const unichar_repr) const
Definition: unicharmap.cpp:101
bool UNICHARSET::contains_unichar ( const char *const  unichar_repr,
int  length 
) const

Definition at line 648 of file unicharset.cpp.

649  {
650  if (length == 0) {
651  return false;
652  }
653  return ids.contains(unichar_repr, length);
654 }
bool contains(const char *const unichar_repr) const
Definition: unicharmap.cpp:101
bool UNICHARSET::contains_unichar_id ( UNICHAR_ID  unichar_id) const
inline

Definition at line 241 of file unicharset.h.

241  {
242  return unichar_id != INVALID_UNICHAR_ID && unichar_id < size_used &&
243  unichar_id >= 0;
244  }
void UNICHARSET::CopyFrom ( const UNICHARSET src)

Definition at line 423 of file unicharset.cpp.

423  {
424  clear();
425  for (int ch = 0; ch < src.size_used; ++ch) {
426  const UNICHAR_PROPERTIES& src_props = src.unichars[ch].properties;
427  const char* utf8 = src.id_to_unichar(ch);
428  unichar_insert(utf8);
429  unichars[ch].properties.ExpandRangesFrom(src_props);
430  }
431  // Set properties, including mirror and other_case, WITHOUT reordering
432  // the unicharset.
434 }
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
void clear()
Definition: unicharset.h:265
void PartialSetPropertiesFromOther(int start_index, const UNICHARSET &src)
Definition: unicharset.cpp:380
void unichar_insert(const char *const unichar_repr)
Definition: unicharset.cpp:612
int UNICHARSET::cyrillic_sid ( ) const
inline

Definition at line 833 of file unicharset.h.

833 { return cyrillic_sid_; }
STRING UNICHARSET::debug_str ( UNICHAR_ID  id) const

Definition at line 318 of file unicharset.cpp.

318  {
319  if (id == INVALID_UNICHAR_ID) return STRING(id_to_unichar(id));
320  const CHAR_FRAGMENT *fragment = this->get_fragment(id);
321  if (fragment) {
322  return fragment->to_string();
323  }
324  const char* str = id_to_unichar(id);
325  STRING result = debug_utf8_str(str);
326  // Append a for lower alpha, A for upper alpha, and x if alpha but neither.
327  if (get_isalpha(id)) {
328  if (get_islower(id))
329  result += "a";
330  else if (get_isupper(id))
331  result += "A";
332  else
333  result += "x";
334  }
335  // Append 0 if a digit.
336  if (get_isdigit(id)) {
337  result += "0";
338  }
339  // Append p is a punctuation symbol.
340  if (get_ispunctuation(id)) {
341  result += "p";
342  }
343  return result;
344 }
bool get_isupper(UNICHAR_ID unichar_id) const
Definition: unicharset.h:462
Definition: strngs.h:44
static STRING debug_utf8_str(const char *str)
Definition: unicharset.cpp:294
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
Definition: unicharset.h:681
bool get_isdigit(UNICHAR_ID unichar_id) const
Definition: unicharset.h:469
bool get_isalpha(UNICHAR_ID unichar_id) const
Definition: unicharset.h:448
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
bool get_islower(UNICHAR_ID unichar_id) const
Definition: unicharset.h:455
bool get_ispunctuation(UNICHAR_ID unichar_id) const
Definition: unicharset.h:476
static STRING to_string(const char *unichar, int pos, int total, bool natural)
STRING UNICHARSET::debug_str ( const char *  unichar_repr) const
inline

Definition at line 232 of file unicharset.h.

232  {
233  return debug_str(unichar_to_id(unichar_repr));
234  }
STRING debug_str(UNICHAR_ID id) const
Definition: unicharset.cpp:318
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
STRING UNICHARSET::debug_utf8_str ( const char *  str)
static

Definition at line 294 of file unicharset.cpp.

294  {
295  STRING result = str;
296  result += " [";
297  int step = 1;
298  // Chop into unicodes and code each as hex.
299  for (int i = 0; str[i] != '\0'; i += step) {
300  char hex[sizeof(int) * 2 + 1];
301  step = UNICHAR::utf8_step(str + i);
302  if (step == 0) {
303  step = 1;
304  sprintf(hex, "%x", str[i]);
305  } else {
306  UNICHAR ch(str + i, step);
307  sprintf(hex, "%x", ch.first_uni());
308  }
309  result += hex;
310  result += " ";
311  }
312  result += "]";
313  return result;
314 }
int step(const char *str) const
Definition: unicharset.cpp:211
Definition: strngs.h:44
static int utf8_step(const char *utf8_str)
Definition: unichar.cpp:134
int UNICHARSET::default_sid ( ) const
inline

Definition at line 838 of file unicharset.h.

838 { return default_sid_; }
void UNICHARSET::delete_pointers_in_unichars ( )
inline

Definition at line 255 of file unicharset.h.

255  {
256  for (int i = 0; i < size_used; ++i) {
257  if (unichars[i].properties.fragment != NULL) {
258  delete unichars[i].properties.fragment;
259  unichars[i].properties.fragment = NULL;
260  }
261  }
262  }
bool UNICHARSET::encodable_string ( const char *  str,
int *  first_bad_position 
) const

Definition at line 222 of file unicharset.cpp.

223  {
224  GenericVector<UNICHAR_ID> encoding;
225  return encode_string(str, true, &encoding, NULL, first_bad_position);
226 }
bool encode_string(const char *str, bool give_up_on_failure, GenericVector< UNICHAR_ID > *encoding, GenericVector< char > *lengths, int *encoded_length) const
Definition: unicharset.cpp:234
bool UNICHARSET::encode_string ( const char *  str,
bool  give_up_on_failure,
GenericVector< UNICHAR_ID > *  encoding,
GenericVector< char > *  lengths,
int *  encoded_length 
) const

Definition at line 234 of file unicharset.cpp.

237  {
238  GenericVector<UNICHAR_ID> working_encoding;
239  GenericVector<char> working_lengths;
240  GenericVector<char> best_lengths;
241  encoding->truncate(0); // Just in case str is empty.
242  int str_length = strlen(str);
243  int str_pos = 0;
244  bool perfect = true;
245  while (str_pos < str_length) {
246  encode_string(str, str_pos, str_length, &working_encoding, &working_lengths,
247  &str_pos, encoding, &best_lengths);
248  if (str_pos < str_length) {
249  // This is a non-match. Skip one utf-8 character.
250  perfect = false;
251  if (give_up_on_failure) break;
252  int step = UNICHAR::utf8_step(str + str_pos);
253  if (step == 0) step = 1;
254  encoding->push_back(INVALID_UNICHAR_ID);
255  best_lengths.push_back(step);
256  str_pos += step;
257  working_encoding = *encoding;
258  working_lengths = best_lengths;
259  }
260  }
261  if (lengths != NULL) *lengths = best_lengths;
262  if (encoded_length != NULL) *encoded_length = str_pos;
263  return perfect;
264 }
int step(const char *str) const
Definition: unicharset.cpp:211
void truncate(int size)
static int utf8_step(const char *utf8_str)
Definition: unichar.cpp:134
int push_back(T object)
bool encode_string(const char *str, bool give_up_on_failure, GenericVector< UNICHAR_ID > *encoding, GenericVector< char > *lengths, int *encoded_length) const
Definition: unicharset.cpp:234
bool UNICHARSET::eq ( UNICHAR_ID  unichar_id,
const char *const  unichar_repr 
) const

Definition at line 656 of file unicharset.cpp.

657  {
658  return strcmp(this->id_to_unichar(unichar_id), unichar_repr) == 0;
659 }
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
void UNICHARSET::ExpandRangesFromOther ( const UNICHARSET src)

Definition at line 410 of file unicharset.cpp.

410  {
411  for (int ch = 0; ch < size_used; ++ch) {
412  const char* utf8 = id_to_unichar(ch);
413  UNICHAR_PROPERTIES properties;
414  if (src.GetStrProperties(utf8, &properties)) {
415  // Expand just the ranges from properties.
416  unichars[ch].properties.ExpandRangesFrom(properties);
417  }
418  }
419 }
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
void UNICHARSET::get_advance_stats ( UNICHAR_ID  unichar_id,
float *  advance,
float *  advance_sd 
) const
inline

Definition at line 587 of file unicharset.h.

588  {
589  if (INVALID_UNICHAR_ID == unichar_id) {
590  *advance = *advance_sd = 0;
591  return;
592  }
593  ASSERT_HOST(contains_unichar_id(unichar_id));
594  *advance = unichars[unichar_id].properties.advance;
595  *advance_sd = unichars[unichar_id].properties.advance_sd;
596  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
void UNICHARSET::get_bearing_stats ( UNICHAR_ID  unichar_id,
float *  bearing,
float *  bearing_sd 
) const
inline

Definition at line 570 of file unicharset.h.

571  {
572  if (INVALID_UNICHAR_ID == unichar_id) {
573  *bearing = *bearing_sd = 0.0f;
574  return;
575  }
576  ASSERT_HOST(contains_unichar_id(unichar_id));
577  *bearing = unichars[unichar_id].properties.bearing;
578  *bearing_sd = unichars[unichar_id].properties.bearing_sd;
579  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
char UNICHARSET::get_chartype ( UNICHAR_ID  unichar_id) const

Definition at line 603 of file unicharset.cpp.

603  {
604  if (this->get_isupper(id)) return 'A';
605  if (this->get_islower(id)) return 'a';
606  if (this->get_isalpha(id)) return 'x';
607  if (this->get_isdigit(id)) return '0';
608  if (this->get_ispunctuation(id)) return 'p';
609  return 0;
610 }
bool get_isupper(UNICHAR_ID unichar_id) const
Definition: unicharset.h:462
bool get_isdigit(UNICHAR_ID unichar_id) const
Definition: unicharset.h:469
bool get_isalpha(UNICHAR_ID unichar_id) const
Definition: unicharset.h:448
bool get_islower(UNICHAR_ID unichar_id) const
Definition: unicharset.h:455
bool get_ispunctuation(UNICHAR_ID unichar_id) const
Definition: unicharset.h:476
char UNICHARSET::get_chartype ( const char *const  unichar_repr) const
inline

Definition at line 718 of file unicharset.h.

718  {
719  return get_chartype(unichar_to_id(unichar_repr));
720  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
char get_chartype(UNICHAR_ID unichar_id) const
Definition: unicharset.cpp:603
Direction UNICHARSET::get_direction ( UNICHAR_ID  unichar_id) const
inline

Definition at line 637 of file unicharset.h.

637  {
638  if (INVALID_UNICHAR_ID == unichar_id) return UNICHARSET::U_OTHER_NEUTRAL;
639  ASSERT_HOST(contains_unichar_id(unichar_id));
640  return unichars[unichar_id].properties.direction;
641  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
bool UNICHARSET::get_enabled ( UNICHAR_ID  unichar_id) const
inline

Definition at line 825 of file unicharset.h.

825  {
826  return unichars[unichar_id].properties.enabled;
827  }
const CHAR_FRAGMENT* UNICHARSET::get_fragment ( UNICHAR_ID  unichar_id) const
inline

Definition at line 681 of file unicharset.h.

681  {
682  if (INVALID_UNICHAR_ID == unichar_id) return NULL;
683  ASSERT_HOST(contains_unichar_id(unichar_id));
684  return unichars[unichar_id].properties.fragment;
685  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
const CHAR_FRAGMENT* UNICHARSET::get_fragment ( const char *const  unichar_repr) const
inline

Definition at line 731 of file unicharset.h.

731  {
732  if (unichar_repr == NULL || unichar_repr[0] == '\0' ||
733  !ids.contains(unichar_repr)) {
734  return NULL;
735  }
736  return get_fragment(unichar_to_id(unichar_repr));
737  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
Definition: unicharset.h:681
bool contains(const char *const unichar_repr) const
Definition: unicharmap.cpp:101
bool UNICHARSET::get_isalpha ( UNICHAR_ID  unichar_id) const
inline

Definition at line 448 of file unicharset.h.

448  {
449  if (INVALID_UNICHAR_ID == unichar_id) return false;
450  ASSERT_HOST(contains_unichar_id(unichar_id));
451  return unichars[unichar_id].properties.isalpha;
452  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
bool UNICHARSET::get_isalpha ( const char *const  unichar_repr) const
inline

Definition at line 688 of file unicharset.h.

688  {
689  return get_isalpha(unichar_to_id(unichar_repr));
690  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
bool get_isalpha(UNICHAR_ID unichar_id) const
Definition: unicharset.h:448
bool UNICHARSET::get_isalpha ( const char *const  unichar_repr,
int  length 
) const
inline

Definition at line 741 of file unicharset.h.

742  {
743  return get_isalpha(unichar_to_id(unichar_repr, length));
744  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
bool get_isalpha(UNICHAR_ID unichar_id) const
Definition: unicharset.h:448
bool UNICHARSET::get_isdigit ( UNICHAR_ID  unichar_id) const
inline

Definition at line 469 of file unicharset.h.

469  {
470  if (INVALID_UNICHAR_ID == unichar_id) return false;
471  ASSERT_HOST(contains_unichar_id(unichar_id));
472  return unichars[unichar_id].properties.isdigit;
473  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
bool UNICHARSET::get_isdigit ( const char *const  unichar_repr) const
inline

Definition at line 703 of file unicharset.h.

703  {
704  return get_isdigit(unichar_to_id(unichar_repr));
705  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
bool get_isdigit(UNICHAR_ID unichar_id) const
Definition: unicharset.h:469
bool UNICHARSET::get_isdigit ( const char *const  unichar_repr,
int  length 
) const
inline

Definition at line 762 of file unicharset.h.

763  {
764  return get_isdigit(unichar_to_id(unichar_repr, length));
765  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
bool get_isdigit(UNICHAR_ID unichar_id) const
Definition: unicharset.h:469
bool UNICHARSET::get_islower ( UNICHAR_ID  unichar_id) const
inline

Definition at line 455 of file unicharset.h.

455  {
456  if (INVALID_UNICHAR_ID == unichar_id) return false;
457  ASSERT_HOST(contains_unichar_id(unichar_id));
458  return unichars[unichar_id].properties.islower;
459  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
bool UNICHARSET::get_islower ( const char *const  unichar_repr) const
inline

Definition at line 693 of file unicharset.h.

693  {
694  return get_islower(unichar_to_id(unichar_repr));
695  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
bool get_islower(UNICHAR_ID unichar_id) const
Definition: unicharset.h:455
bool UNICHARSET::get_islower ( const char *const  unichar_repr,
int  length 
) const
inline

Definition at line 748 of file unicharset.h.

749  {
750  return get_islower(unichar_to_id(unichar_repr, length));
751  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
bool get_islower(UNICHAR_ID unichar_id) const
Definition: unicharset.h:455
bool UNICHARSET::get_isngram ( UNICHAR_ID  unichar_id) const
inline

Definition at line 483 of file unicharset.h.

483  {
484  if (INVALID_UNICHAR_ID == unichar_id) return false;
485  ASSERT_HOST(contains_unichar_id(unichar_id));
486  return unichars[unichar_id].properties.isngram;
487  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
bool UNICHARSET::get_isprivate ( UNICHAR_ID  unichar_id) const

Definition at line 363 of file unicharset.cpp.

363  {
364  UNICHAR uc(id_to_unichar(unichar_id), -1);
365  int uni = uc.first_uni();
366  return (uni >= 0xE000 && uni <= 0xF8FF);
367 }
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
bool UNICHARSET::get_ispunctuation ( UNICHAR_ID  unichar_id) const
inline

Definition at line 476 of file unicharset.h.

476  {
477  if (INVALID_UNICHAR_ID == unichar_id) return false;
478  ASSERT_HOST(contains_unichar_id(unichar_id));
479  return unichars[unichar_id].properties.ispunctuation;
480  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
bool UNICHARSET::get_ispunctuation ( const char *const  unichar_repr) const
inline

Definition at line 708 of file unicharset.h.

708  {
709  return get_ispunctuation(unichar_to_id(unichar_repr));
710  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
bool get_ispunctuation(UNICHAR_ID unichar_id) const
Definition: unicharset.h:476
bool UNICHARSET::get_ispunctuation ( const char *const  unichar_repr,
int  length 
) const
inline

Definition at line 769 of file unicharset.h.

770  {
771  return get_ispunctuation(unichar_to_id(unichar_repr, length));
772  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
bool get_ispunctuation(UNICHAR_ID unichar_id) const
Definition: unicharset.h:476
bool UNICHARSET::get_isupper ( UNICHAR_ID  unichar_id) const
inline

Definition at line 462 of file unicharset.h.

462  {
463  if (INVALID_UNICHAR_ID == unichar_id) return false;
464  ASSERT_HOST(contains_unichar_id(unichar_id));
465  return unichars[unichar_id].properties.isupper;
466  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
bool UNICHARSET::get_isupper ( const char *const  unichar_repr) const
inline

Definition at line 698 of file unicharset.h.

698  {
699  return get_isupper(unichar_to_id(unichar_repr));
700  }
bool get_isupper(UNICHAR_ID unichar_id) const
Definition: unicharset.h:462
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
bool UNICHARSET::get_isupper ( const char *const  unichar_repr,
int  length 
) const
inline

Definition at line 755 of file unicharset.h.

756  {
757  return get_isupper(unichar_to_id(unichar_repr, length));
758  }
bool get_isupper(UNICHAR_ID unichar_id) const
Definition: unicharset.h:462
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
UNICHAR_ID UNICHARSET::get_mirror ( UNICHAR_ID  unichar_id) const
inline

Definition at line 644 of file unicharset.h.

644  {
645  if (INVALID_UNICHAR_ID == unichar_id) return INVALID_UNICHAR_ID;
646  ASSERT_HOST(contains_unichar_id(unichar_id));
647  return unichars[unichar_id].properties.mirror;
648  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
const char* UNICHARSET::get_normed_unichar ( UNICHAR_ID  unichar_id) const
inline

Definition at line 775 of file unicharset.h.

775  {
776  if (unichar_id == UNICHAR_SPACE && has_special_codes()) return " ";
777  return unichars[unichar_id].properties.normed.string();
778  }
bool has_special_codes() const
Definition: unicharset.h:669
UNICHAR_ID UNICHARSET::get_other_case ( UNICHAR_ID  unichar_id) const
inline

Definition at line 630 of file unicharset.h.

630  {
631  if (INVALID_UNICHAR_ID == unichar_id) return INVALID_UNICHAR_ID;
632  ASSERT_HOST(contains_unichar_id(unichar_id));
633  return unichars[unichar_id].properties.other_case;
634  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
unsigned int UNICHARSET::get_properties ( UNICHAR_ID  unichar_id) const

Definition at line 588 of file unicharset.cpp.

588  {
589  unsigned int properties = 0;
590  if (this->get_isalpha(id))
591  properties |= ISALPHA_MASK;
592  if (this->get_islower(id))
593  properties |= ISLOWER_MASK;
594  if (this->get_isupper(id))
595  properties |= ISUPPER_MASK;
596  if (this->get_isdigit(id))
597  properties |= ISDIGIT_MASK;
598  if (this->get_ispunctuation(id))
599  properties |= ISPUNCTUATION_MASK;
600  return properties;
601 }
bool get_isupper(UNICHAR_ID unichar_id) const
Definition: unicharset.h:462
bool get_isdigit(UNICHAR_ID unichar_id) const
Definition: unicharset.h:469
bool get_isalpha(UNICHAR_ID unichar_id) const
Definition: unicharset.h:448
bool get_islower(UNICHAR_ID unichar_id) const
Definition: unicharset.h:455
bool get_ispunctuation(UNICHAR_ID unichar_id) const
Definition: unicharset.h:476
unsigned int UNICHARSET::get_properties ( const char *const  unichar_repr) const
inline

Definition at line 714 of file unicharset.h.

714  {
715  return get_properties(unichar_to_id(unichar_repr));
716  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
unsigned int get_properties(UNICHAR_ID unichar_id) const
Definition: unicharset.cpp:588
int UNICHARSET::get_script ( UNICHAR_ID  unichar_id) const
inline

Definition at line 610 of file unicharset.h.

610  {
611  if (INVALID_UNICHAR_ID == unichar_id) return null_sid_;
612  ASSERT_HOST(contains_unichar_id(unichar_id));
613  return unichars[unichar_id].properties.script_id;
614  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
int UNICHARSET::get_script ( const char *const  unichar_repr) const
inline

Definition at line 725 of file unicharset.h.

725  {
726  return get_script(unichar_to_id(unichar_repr));
727  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
int get_script(UNICHAR_ID unichar_id) const
Definition: unicharset.h:610
int UNICHARSET::get_script ( const char *const  unichar_repr,
int  length 
) const
inline

Definition at line 790 of file unicharset.h.

791  {
792  return get_script(unichar_to_id(unichar_repr, length));
793  }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
int get_script(UNICHAR_ID unichar_id) const
Definition: unicharset.h:610
const char* UNICHARSET::get_script_from_script_id ( int  id) const
inline

Definition at line 801 of file unicharset.h.

801  {
802  if (id >= script_table_size_used || id < 0)
803  return null_script;
804  return script_table[id];
805  }
int UNICHARSET::get_script_id_from_name ( const char *  script_name) const

Definition at line 1080 of file unicharset.cpp.

1080  {
1081  for (int i = 0; i < script_table_size_used; ++i) {
1082  if (strcmp(script_name, script_table[i]) == 0)
1083  return i;
1084  }
1085  return 0; // 0 is always the null_script
1086 }
int UNICHARSET::get_script_table_size ( ) const
inline

Definition at line 796 of file unicharset.h.

796  {
797  return script_table_size_used;
798  }
void UNICHARSET::get_top_bottom ( UNICHAR_ID  unichar_id,
int *  min_bottom,
int *  max_bottom,
int *  min_top,
int *  max_top 
) const
inline

Definition at line 525 of file unicharset.h.

527  {
528  if (INVALID_UNICHAR_ID == unichar_id) {
529  *min_bottom = *min_top = 0;
530  *max_bottom = *max_top = 256; // kBlnCellHeight
531  return;
532  }
533  ASSERT_HOST(contains_unichar_id(unichar_id));
534  *min_bottom = unichars[unichar_id].properties.min_bottom;
535  *max_bottom = unichars[unichar_id].properties.max_bottom;
536  *min_top = unichars[unichar_id].properties.min_top;
537  *max_top = unichars[unichar_id].properties.max_top;
538  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
void UNICHARSET::get_width_stats ( UNICHAR_ID  unichar_id,
float *  width,
float *  width_sd 
) const
inline

Definition at line 553 of file unicharset.h.

554  {
555  if (INVALID_UNICHAR_ID == unichar_id) {
556  *width = 0.0f;
557  *width_sd = 0.0f;;
558  return;
559  }
560  ASSERT_HOST(contains_unichar_id(unichar_id));
561  *width = unichars[unichar_id].properties.width;
562  *width_sd = unichars[unichar_id].properties.width_sd;
563  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
int UNICHARSET::greek_sid ( ) const
inline

Definition at line 834 of file unicharset.h.

834 { return greek_sid_; }
int UNICHARSET::han_sid ( ) const
inline

Definition at line 835 of file unicharset.h.

835 { return han_sid_; }
bool UNICHARSET::has_special_codes ( ) const
inline

Definition at line 669 of file unicharset.h.

669  {
670  return get_fragment(UNICHAR_BROKEN) != NULL &&
673  }
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
Definition: unicharset.h:681
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
static const char * kSpecialUnicharCodes[SPECIAL_UNICHAR_CODES_COUNT]
Definition: unicharset.h:147
int UNICHARSET::hiragana_sid ( ) const
inline

Definition at line 836 of file unicharset.h.

836 { return hiragana_sid_; }
const char * UNICHARSET::id_to_unichar ( UNICHAR_ID  id) const

Definition at line 266 of file unicharset.cpp.

266  {
267  if (id == INVALID_UNICHAR_ID) {
268  return INVALID_UNICHAR;
269  }
270  ASSERT_HOST(id < this->size());
271  return unichars[id].representation;
272 }
int size() const
Definition: unicharset.h:296
#define ASSERT_HOST(x)
Definition: errcode.h:84
const char * UNICHARSET::id_to_unichar_ext ( UNICHAR_ID  id) const

Definition at line 274 of file unicharset.cpp.

274  {
275  if (id == INVALID_UNICHAR_ID) {
276  return INVALID_UNICHAR;
277  }
278  ASSERT_HOST(id < this->size());
279  // Resolve from the kCustomLigatures table if this is a private encoding.
280  if (get_isprivate(id)) {
281  const char* ch = id_to_unichar(id);
282  for (int i = 0; kCustomLigatures[i][0] != NULL; ++i) {
283  if (!strcmp(ch, kCustomLigatures[i][1])) {
284  return kCustomLigatures[i][0];
285  }
286  }
287  }
288  // Otherwise return the stored representation.
289  return unichars[id].representation;
290 }
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
static TESS_API const char * kCustomLigatures[][2]
Definition: unicharset.h:144
int size() const
Definition: unicharset.h:296
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool get_isprivate(UNICHAR_ID unichar_id) const
Definition: unicharset.cpp:363
bool UNICHARSET::is_null_script ( const char *  script) const
inline

Definition at line 815 of file unicharset.h.

815  {
816  return script == null_script;
817  }
int UNICHARSET::katakana_sid ( ) const
inline

Definition at line 837 of file unicharset.h.

837 { return katakana_sid_; }
int UNICHARSET::latin_sid ( ) const
inline

Definition at line 832 of file unicharset.h.

832 { return latin_sid_; }
bool UNICHARSET::load_from_file ( const char *const  filename,
bool  skip_fragments 
)
inline

Definition at line 345 of file unicharset.h.

345  {
346  FILE* file = fopen(filename, "rb");
347  if (file == NULL) return false;
348  bool result = load_from_file(file, skip_fragments);
349  fclose(file);
350  return result;
351  }
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:345
bool UNICHARSET::load_from_file ( const char *const  filename)
inline

Definition at line 353 of file unicharset.h.

353  {
354  return load_from_file(filename, false);
355  }
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:345
bool UNICHARSET::load_from_file ( FILE *  file,
bool  skip_fragments 
)

Definition at line 744 of file unicharset.cpp.

744  {
745  LocalFilePointer lfp(file);
748  bool success = load_via_fgets(fgets_cb, skip_fragments);
749  delete fgets_cb;
750  return success;
751 }
char * fgets(char *dst, int size)
Definition: unicharset.cpp:737
_ConstTessMemberResultCallback_0_0< false, R, T1 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)() const)
Definition: tesscallback.h:116
bool UNICHARSET::load_from_file ( FILE *  file)
inline

Definition at line 360 of file unicharset.h.

360 { return load_from_file(file, false); }
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:345
bool UNICHARSET::load_from_file ( tesseract::TFile file,
bool  skip_fragments 
)

Definition at line 753 of file unicharset.cpp.

753  {
756  bool success = load_via_fgets(fgets_cb, skip_fragments);
757  delete fgets_cb;
758  return success;
759 }
char * FGets(char *buffer, int buffer_size)
Definition: serialis.cpp:80
_ConstTessMemberResultCallback_0_0< false, R, T1 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)() const)
Definition: tesscallback.h:116
bool UNICHARSET::load_from_inmemory_file ( const char *const  memory,
int  mem_size,
bool  skip_fragments 
)

Definition at line 724 of file unicharset.cpp.

725  {
726  InMemoryFilePointer mem_fp(memory, mem_size);
729  bool success = load_via_fgets(fgets_cb, skip_fragments);
730  delete fgets_cb;
731  return success;
732 }
char * fgets(char *orig_dst, int size)
Definition: unicharset.cpp:702
_ConstTessMemberResultCallback_0_0< false, R, T1 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)() const)
Definition: tesscallback.h:116
bool UNICHARSET::load_from_inmemory_file ( const char *const  memory,
int  mem_size 
)
inline

Definition at line 338 of file unicharset.h.

338  {
339  return load_from_inmemory_file(memory, mem_size, false);
340  }
bool load_from_inmemory_file(const char *const memory, int mem_size, bool skip_fragments)
Definition: unicharset.cpp:724
bool UNICHARSET::major_right_to_left ( ) const

Definition at line 931 of file unicharset.cpp.

931  {
932  int ltr_count = 0;
933  int rtl_count = 0;
934  for (int id = 0; id < size_used; ++id) {
935  int dir = get_direction(id);
936  if (dir == UNICHARSET::U_LEFT_TO_RIGHT) ltr_count++;
937  if (dir == UNICHARSET::U_RIGHT_TO_LEFT ||
939  dir == UNICHARSET::U_ARABIC_NUMBER) rtl_count++;
940  }
941  return rtl_count > ltr_count;
942 }
Direction get_direction(UNICHAR_ID unichar_id) const
Definition: unicharset.h:637
const GenericVector<UNICHAR_ID>& UNICHARSET::normed_ids ( UNICHAR_ID  unichar_id) const
inline

Definition at line 782 of file unicharset.h.

782  {
783  return unichars[unichar_id].properties.normed_ids;
784  }
int UNICHARSET::null_sid ( ) const
inline

Definition at line 830 of file unicharset.h.

830 { return null_sid_; }
void UNICHARSET::PartialSetPropertiesFromOther ( int  start_index,
const UNICHARSET src 
)

Definition at line 380 of file unicharset.cpp.

381  {
382  for (int ch = start_index; ch < size_used; ++ch) {
383  const char* utf8 = id_to_unichar(ch);
384  UNICHAR_PROPERTIES properties;
385  if (src.GetStrProperties(utf8, &properties)) {
386  // Setup the script_id, other_case, and mirror properly.
387  const char* script = src.get_script_from_script_id(properties.script_id);
388  properties.script_id = add_script(script);
389  const char* other_case = src.id_to_unichar(properties.other_case);
390  if (contains_unichar(other_case)) {
391  properties.other_case = unichar_to_id(other_case);
392  } else {
393  properties.other_case = ch;
394  }
395  const char* mirror_str = src.id_to_unichar(properties.mirror);
396  if (contains_unichar(mirror_str)) {
397  properties.mirror = unichar_to_id(mirror_str);
398  } else {
399  properties.mirror = ch;
400  }
401  unichars[ch].properties.CopyFrom(properties);
402  set_normed_ids(ch);
403  }
404  }
405 }
void set_normed_ids(UNICHAR_ID unichar_id)
Definition: unicharset.cpp:348
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
const char * get_script_from_script_id(int id) const
Definition: unicharset.h:801
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
bool contains_unichar(const char *const unichar_repr) const
Definition: unicharset.cpp:644
int add_script(const char *script)
void UNICHARSET::post_load_setup ( )

Definition at line 867 of file unicharset.cpp.

867  {
868  // Number of alpha chars with the case property minus those without,
869  // in order to determine that half the alpha chars have case.
870  int net_case_alphas = 0;
871  int x_height_alphas = 0;
872  int cap_height_alphas = 0;
873  top_bottom_set_ = false;
874  for (UNICHAR_ID id = 0; id < size_used; ++id) {
875  int min_bottom = 0;
876  int max_bottom = MAX_UINT8;
877  int min_top = 0;
878  int max_top = MAX_UINT8;
879  get_top_bottom(id, &min_bottom, &max_bottom, &min_top, &max_top);
880  if (min_top > 0)
881  top_bottom_set_ = true;
882  if (get_isalpha(id)) {
883  if (get_islower(id) || get_isupper(id))
884  ++net_case_alphas;
885  else
886  --net_case_alphas;
887  if (min_top < kMeanlineThreshold && max_top < kMeanlineThreshold)
888  ++x_height_alphas;
889  else if (min_top > kMeanlineThreshold && max_top > kMeanlineThreshold)
890  ++cap_height_alphas;
891  }
892  set_normed_ids(id);
893  }
894 
895  script_has_upper_lower_ = net_case_alphas > 0;
896  script_has_xheight_ = script_has_upper_lower_ ||
897  (x_height_alphas > cap_height_alphas * kMinXHeightFraction &&
898  cap_height_alphas > x_height_alphas * kMinCapHeightFraction);
899 
900  null_sid_ = get_script_id_from_name(null_script);
901  ASSERT_HOST(null_sid_ == 0);
902  common_sid_ = get_script_id_from_name("Common");
903  latin_sid_ = get_script_id_from_name("Latin");
904  cyrillic_sid_ = get_script_id_from_name("Cyrillic");
905  greek_sid_ = get_script_id_from_name("Greek");
906  han_sid_ = get_script_id_from_name("Han");
907  hiragana_sid_ = get_script_id_from_name("Hiragana");
908  katakana_sid_ = get_script_id_from_name("Katakana");
909 
910  // Compute default script. Use the highest-counting alpha script, that is
911  // not the common script, as that still contains some "alphas".
912  int* script_counts = new int[script_table_size_used];
913  memset(script_counts, 0, sizeof(*script_counts) * script_table_size_used);
914  for (int id = 0; id < size_used; ++id) {
915  if (get_isalpha(id)) {
916  ++script_counts[get_script(id)];
917  }
918  }
919  default_sid_ = 0;
920  for (int s = 1; s < script_table_size_used; ++s) {
921  if (script_counts[s] > script_counts[default_sid_] && s != common_sid_)
922  default_sid_ = s;
923  }
924  delete [] script_counts;
925 }
int UNICHAR_ID
Definition: unichar.h:33
#define MAX_UINT8
Definition: host.h:121
void set_normed_ids(UNICHAR_ID unichar_id)
Definition: unicharset.cpp:348
bool get_isupper(UNICHAR_ID unichar_id) const
Definition: unicharset.h:462
const double kMinCapHeightFraction
Definition: unicharset.cpp:54
int get_script(UNICHAR_ID unichar_id) const
Definition: unicharset.h:610
int get_script_id_from_name(const char *script_name) const
bool get_isalpha(UNICHAR_ID unichar_id) const
Definition: unicharset.h:448
bool get_islower(UNICHAR_ID unichar_id) const
Definition: unicharset.h:455
void get_top_bottom(UNICHAR_ID unichar_id, int *min_bottom, int *max_bottom, int *min_top, int *max_top) const
Definition: unicharset.h:525
#define ASSERT_HOST(x)
Definition: errcode.h:84
const double kMinXHeightFraction
Definition: unicharset.cpp:53
bool UNICHARSET::PropertiesIncomplete ( UNICHAR_ID  unichar_id) const
inline

Definition at line 603 of file unicharset.h.

603  {
604  return unichars[unichar_id].properties.AnyRangeEmpty();
605  }
void UNICHARSET::reserve ( int  unichars_number)

Definition at line 179 of file unicharset.cpp.

179  {
180  if (unichars_number > size_reserved) {
181  UNICHAR_SLOT* unichars_new = new UNICHAR_SLOT[unichars_number];
182  for (int i = 0; i < size_used; ++i)
183  unichars_new[i] = unichars[i];
184  for (int j = size_used; j < unichars_number; ++j) {
185  unichars_new[j].properties.script_id = add_script(null_script);
186  }
187  delete[] unichars;
188  unichars = unichars_new;
189  size_reserved = unichars_number;
190  }
191 }
int add_script(const char *script)
bool UNICHARSET::save_to_file ( const char *const  filename) const
inline

Definition at line 305 of file unicharset.h.

305  {
306  FILE* file = fopen(filename, "w+b");
307  if (file == NULL) return false;
308  bool result = save_to_file(file);
309  fclose(file);
310  return result;
311  }
bool save_to_file(const char *const filename) const
Definition: unicharset.h:305
bool UNICHARSET::save_to_file ( FILE *  file) const
inline

Definition at line 315 of file unicharset.h.

315  {
316  STRING str;
317  if (!save_to_string(&str)) return false;
318  if (fwrite(&str[0], str.length(), 1, file) != 1) return false;
319  return true;
320  }
Definition: strngs.h:44
inT32 length() const
Definition: strngs.cpp:196
bool save_to_string(STRING *str) const
Definition: unicharset.cpp:661
bool UNICHARSET::save_to_file ( tesseract::TFile file) const
inline

Definition at line 321 of file unicharset.h.

321  {
322  STRING str;
323  if (!save_to_string(&str)) return false;
324  if (file->FWrite(&str[0], str.length(), 1) != 1) return false;
325  return true;
326  }
int FWrite(const void *buffer, int size, int count)
Definition: serialis.cpp:131
Definition: strngs.h:44
inT32 length() const
Definition: strngs.cpp:196
bool save_to_string(STRING *str) const
Definition: unicharset.cpp:661
bool UNICHARSET::save_to_string ( STRING str) const

Definition at line 661 of file unicharset.cpp.

661  {
662  const int kFileBufSize = 1024;
663  char buffer[kFileBufSize + 1];
664  snprintf(buffer, kFileBufSize, "%d\n", this->size());
665  *str = buffer;
666  for (UNICHAR_ID id = 0; id < this->size(); ++id) {
667  int min_bottom, max_bottom, min_top, max_top;
668  get_top_bottom(id, &min_bottom, &max_bottom, &min_top, &max_top);
669  float width, width_sd;
670  get_width_stats(id, &width, &width_sd);
671  float bearing, bearing_sd;
672  get_bearing_stats(id, &bearing, &bearing_sd);
673  float advance, advance_sd;
674  get_advance_stats(id, &advance, &advance_sd);
675  unsigned int properties = this->get_properties(id);
676  if (strcmp(this->id_to_unichar(id), " ") == 0) {
677  snprintf(buffer, kFileBufSize, "%s %x %s %d\n", "NULL", properties,
678  this->get_script_from_script_id(this->get_script(id)),
679  this->get_other_case(id));
680  } else {
681  snprintf(buffer, kFileBufSize,
682  "%s %x %d,%d,%d,%d,%g,%g,%g,%g,%g,%g %s %d %d %d %s\t# %s\n",
683  this->id_to_unichar(id), properties,
684  min_bottom, max_bottom, min_top, max_top, width, width_sd,
685  bearing, bearing_sd, advance, advance_sd,
686  this->get_script_from_script_id(this->get_script(id)),
687  this->get_other_case(id), this->get_direction(id),
688  this->get_mirror(id), this->get_normed_unichar(id),
689  this->debug_str(id).string());
690  }
691  *str += buffer;
692  }
693  return true;
694 }
void get_width_stats(UNICHAR_ID unichar_id, float *width, float *width_sd) const
Definition: unicharset.h:553
int UNICHAR_ID
Definition: unichar.h:33
void get_bearing_stats(UNICHAR_ID unichar_id, float *bearing, float *bearing_sd) const
Definition: unicharset.h:570
UNICHAR_ID get_mirror(UNICHAR_ID unichar_id) const
Definition: unicharset.h:644
STRING debug_str(UNICHAR_ID id) const
Definition: unicharset.cpp:318
int get_script(UNICHAR_ID unichar_id) const
Definition: unicharset.h:610
unsigned int get_properties(UNICHAR_ID unichar_id) const
Definition: unicharset.cpp:588
const char * get_script_from_script_id(int id) const
Definition: unicharset.h:801
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
const char * get_normed_unichar(UNICHAR_ID unichar_id) const
Definition: unicharset.h:775
Direction get_direction(UNICHAR_ID unichar_id) const
Definition: unicharset.h:637
void get_top_bottom(UNICHAR_ID unichar_id, int *min_bottom, int *max_bottom, int *min_top, int *max_top) const
Definition: unicharset.h:525
int size() const
Definition: unicharset.h:296
UNICHAR_ID get_other_case(UNICHAR_ID unichar_id) const
Definition: unicharset.h:630
void get_advance_stats(UNICHAR_ID unichar_id, float *advance, float *advance_sd) const
Definition: unicharset.h:587
bool UNICHARSET::script_has_upper_lower ( ) const
inline

Definition at line 841 of file unicharset.h.

841  {
842  return script_has_upper_lower_;
843  }
bool UNICHARSET::script_has_xheight ( ) const
inline

Definition at line 848 of file unicharset.h.

848  {
849  return script_has_xheight_;
850  }
void UNICHARSET::set_advance_stats ( UNICHAR_ID  unichar_id,
float  advance,
float  advance_sd 
)
inline

Definition at line 597 of file unicharset.h.

598  {
599  unichars[unichar_id].properties.advance = advance;
600  unichars[unichar_id].properties.advance_sd = advance_sd;
601  }
void UNICHARSET::set_bearing_stats ( UNICHAR_ID  unichar_id,
float  bearing,
float  bearing_sd 
)
inline

Definition at line 580 of file unicharset.h.

581  {
582  unichars[unichar_id].properties.bearing = bearing;
583  unichars[unichar_id].properties.bearing_sd = bearing_sd;
584  }
void UNICHARSET::set_black_and_whitelist ( const char *  blacklist,
const char *  whitelist,
const char *  unblacklist 
)

Definition at line 948 of file unicharset.cpp.

950  {
951  bool def_enabled = whitelist == NULL || whitelist[0] == '\0';
952  // Set everything to default
953  for (int ch = 0; ch < size_used; ++ch)
954  unichars[ch].properties.enabled = def_enabled;
955  if (!def_enabled) {
956  // Enable the whitelist.
957  GenericVector<UNICHAR_ID> encoding;
958  encode_string(whitelist, false, &encoding, NULL, NULL);
959  for (int i = 0; i < encoding.size(); ++i) {
960  if (encoding[i] != INVALID_UNICHAR_ID)
961  unichars[encoding[i]].properties.enabled = true;
962  }
963  }
964  if (blacklist != NULL && blacklist[0] != '\0') {
965  // Disable the blacklist.
966  GenericVector<UNICHAR_ID> encoding;
967  encode_string(blacklist, false, &encoding, NULL, NULL);
968  for (int i = 0; i < encoding.size(); ++i) {
969  if (encoding[i] != INVALID_UNICHAR_ID)
970  unichars[encoding[i]].properties.enabled = false;
971  }
972  }
973  if (unblacklist != NULL && unblacklist[0] != '\0') {
974  // Re-enable the unblacklist.
975  GenericVector<UNICHAR_ID> encoding;
976  encode_string(unblacklist, false, &encoding, NULL, NULL);
977  for (int i = 0; i < encoding.size(); ++i) {
978  if (encoding[i] != INVALID_UNICHAR_ID)
979  unichars[encoding[i]].properties.enabled = true;
980  }
981  }
982 }
int size() const
Definition: genericvector.h:72
bool encode_string(const char *str, bool give_up_on_failure, GenericVector< UNICHAR_ID > *encoding, GenericVector< char > *lengths, int *encoded_length) const
Definition: unicharset.cpp:234
void UNICHARSET::set_direction ( UNICHAR_ID  unichar_id,
UNICHARSET::Direction  value 
)
inline

Definition at line 429 of file unicharset.h.

429  {
430  unichars[unichar_id].properties.direction = value;
431  }
void UNICHARSET::set_isalpha ( UNICHAR_ID  unichar_id,
bool  value 
)
inline

Definition at line 388 of file unicharset.h.

388  {
389  unichars[unichar_id].properties.isalpha = value;
390  }
void UNICHARSET::set_isdigit ( UNICHAR_ID  unichar_id,
bool  value 
)
inline

Definition at line 403 of file unicharset.h.

403  {
404  unichars[unichar_id].properties.isdigit = value;
405  }
void UNICHARSET::set_islower ( UNICHAR_ID  unichar_id,
bool  value 
)
inline

Definition at line 393 of file unicharset.h.

393  {
394  unichars[unichar_id].properties.islower = value;
395  }
void UNICHARSET::set_isngram ( UNICHAR_ID  unichar_id,
bool  value 
)
inline

Definition at line 413 of file unicharset.h.

413  {
414  unichars[unichar_id].properties.isngram = value;
415  }
void UNICHARSET::set_ispunctuation ( UNICHAR_ID  unichar_id,
bool  value 
)
inline

Definition at line 408 of file unicharset.h.

408  {
409  unichars[unichar_id].properties.ispunctuation = value;
410  }
void UNICHARSET::set_isupper ( UNICHAR_ID  unichar_id,
bool  value 
)
inline

Definition at line 398 of file unicharset.h.

398  {
399  unichars[unichar_id].properties.isupper = value;
400  }
void UNICHARSET::set_mirror ( UNICHAR_ID  unichar_id,
UNICHAR_ID  mirror 
)
inline

Definition at line 434 of file unicharset.h.

434  {
435  unichars[unichar_id].properties.mirror = mirror;
436  }
void UNICHARSET::set_normed ( UNICHAR_ID  unichar_id,
const char *  normed 
)
inline

Definition at line 439 of file unicharset.h.

439  {
440  unichars[unichar_id].properties.normed = normed;
441  unichars[unichar_id].properties.normed_ids.truncate(0);
442  }
void UNICHARSET::set_normed_ids ( UNICHAR_ID  unichar_id)

Definition at line 348 of file unicharset.cpp.

348  {
349  unichars[unichar_id].properties.normed_ids.truncate(0);
350  if (unichar_id == UNICHAR_SPACE && id_to_unichar(unichar_id)[0] == ' ') {
351  unichars[unichar_id].properties.normed_ids.push_back(UNICHAR_SPACE);
352  } else if (!encode_string(unichars[unichar_id].properties.normed.string(),
353  true, &unichars[unichar_id].properties.normed_ids,
354  NULL, NULL)) {
355  unichars[unichar_id].properties.normed_ids.truncate(0);
356  unichars[unichar_id].properties.normed_ids.push_back(unichar_id);
357  }
358 }
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:266
bool encode_string(const char *str, bool give_up_on_failure, GenericVector< UNICHAR_ID > *encoding, GenericVector< char > *lengths, int *encoded_length) const
Definition: unicharset.cpp:234
void UNICHARSET::set_other_case ( UNICHAR_ID  unichar_id,
UNICHAR_ID  other_case 
)
inline

Definition at line 424 of file unicharset.h.

424  {
425  unichars[unichar_id].properties.other_case = other_case;
426  }
void UNICHARSET::set_ranges_empty ( )

Definition at line 371 of file unicharset.cpp.

371  {
372  for (int id = 0; id < size_used; ++id) {
373  unichars[id].properties.SetRangesEmpty();
374  }
375 }
void UNICHARSET::set_script ( UNICHAR_ID  unichar_id,
const char *  value 
)
inline

Definition at line 419 of file unicharset.h.

419  {
420  unichars[unichar_id].properties.script_id = add_script(value);
421  }
int add_script(const char *script)
void UNICHARSET::set_top_bottom ( UNICHAR_ID  unichar_id,
int  min_bottom,
int  max_bottom,
int  min_top,
int  max_top 
)
inline

Definition at line 539 of file unicharset.h.

541  {
542  unichars[unichar_id].properties.min_bottom =
543  static_cast<uinT8>(ClipToRange(min_bottom, 0, MAX_UINT8));
544  unichars[unichar_id].properties.max_bottom =
545  static_cast<uinT8>(ClipToRange(max_bottom, 0, MAX_UINT8));
546  unichars[unichar_id].properties.min_top =
547  static_cast<uinT8>(ClipToRange(min_top, 0, MAX_UINT8));
548  unichars[unichar_id].properties.max_top =
549  static_cast<uinT8>(ClipToRange(max_top, 0, MAX_UINT8));
550  }
#define MAX_UINT8
Definition: host.h:121
unsigned char uinT8
Definition: host.h:99
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:115
void UNICHARSET::set_width_stats ( UNICHAR_ID  unichar_id,
float  width,
float  width_sd 
)
inline

Definition at line 564 of file unicharset.h.

564  {
565  unichars[unichar_id].properties.width = width;
566  unichars[unichar_id].properties.width_sd = width_sd;
567  }
void UNICHARSET::SetPropertiesFromOther ( const UNICHARSET src)
inline

Definition at line 502 of file unicharset.h.

502  {
504  }
void PartialSetPropertiesFromOther(int start_index, const UNICHARSET &src)
Definition: unicharset.cpp:380
int UNICHARSET::size ( ) const
inline

Definition at line 296 of file unicharset.h.

296  {
297  return size_used;
298  }
bool UNICHARSET::SizesDistinct ( UNICHAR_ID  id1,
UNICHAR_ID  id2 
) const

Definition at line 472 of file unicharset.cpp.

472  {
473  int overlap = MIN(unichars[id1].properties.max_top,
474  unichars[id2].properties.max_top) -
475  MAX(unichars[id1].properties.min_top,
476  unichars[id2].properties.min_top);
477  return overlap <= 0;
478 }
#define MAX(x, y)
Definition: ndminx.h:24
#define MIN(x, y)
Definition: ndminx.h:28
int UNICHARSET::step ( const char *  str) const

Definition at line 211 of file unicharset.cpp.

211  {
212  GenericVector<UNICHAR_ID> encoding;
213  GenericVector<char> lengths;
214  encode_string(str, true, &encoding, &lengths, NULL);
215  if (encoding.empty() || encoding[0] == INVALID_UNICHAR_ID) return 0;
216  return lengths[0];
217 }
bool empty() const
Definition: genericvector.h:84
bool encode_string(const char *str, bool give_up_on_failure, GenericVector< UNICHAR_ID > *encoding, GenericVector< char > *lengths, int *encoded_length) const
Definition: unicharset.cpp:234
UNICHAR_ID UNICHARSET::to_lower ( UNICHAR_ID  unichar_id) const
inline

Definition at line 651 of file unicharset.h.

651  {
652  if (INVALID_UNICHAR_ID == unichar_id) return INVALID_UNICHAR_ID;
653  ASSERT_HOST(contains_unichar_id(unichar_id));
654  if (unichars[unichar_id].properties.islower) return unichar_id;
655  return unichars[unichar_id].properties.other_case;
656  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
UNICHAR_ID UNICHARSET::to_upper ( UNICHAR_ID  unichar_id) const
inline

Definition at line 659 of file unicharset.h.

659  {
660  if (INVALID_UNICHAR_ID == unichar_id) return INVALID_UNICHAR_ID;
661  ASSERT_HOST(contains_unichar_id(unichar_id));
662  if (unichars[unichar_id].properties.isupper) return unichar_id;
663  return unichars[unichar_id].properties.other_case;
664  }
#define ASSERT_HOST(x)
Definition: errcode.h:84
bool contains_unichar_id(UNICHAR_ID unichar_id) const
Definition: unicharset.h:241
bool UNICHARSET::top_bottom_useful ( ) const
inline

Definition at line 494 of file unicharset.h.

494  {
495  return top_bottom_set_;
496  }
void UNICHARSET::unichar_insert ( const char *const  unichar_repr)

Definition at line 612 of file unicharset.cpp.

612  {
613  if (!ids.contains(unichar_repr)) {
614  if (strlen(unichar_repr) > UNICHAR_LEN) {
615  fprintf(stderr, "Utf8 buffer too big, size=%d for %s\n",
616  int(strlen(unichar_repr)), unichar_repr);
617  return;
618  }
619  if (size_used == size_reserved) {
620  if (size_used == 0)
621  reserve(8);
622  else
623  reserve(2 * size_used);
624  }
625 
626  strcpy(unichars[size_used].representation, unichar_repr);
627  this->set_script(size_used, null_script);
628  // If the given unichar_repr represents a fragmented character, set
629  // fragment property to a pointer to CHAR_FRAGMENT class instance with
630  // information parsed from the unichar representation. Use the script
631  // of the base unichar for the fragmented character if possible.
632  CHAR_FRAGMENT *frag = CHAR_FRAGMENT::parse_from_string(unichar_repr);
633  this->unichars[size_used].properties.fragment = frag;
634  if (frag != NULL && this->contains_unichar(frag->get_unichar())) {
635  this->unichars[size_used].properties.script_id =
636  this->get_script(frag->get_unichar());
637  }
638  this->unichars[size_used].properties.enabled = true;
639  ids.insert(unichar_repr, size_used);
640  ++size_used;
641  }
642 }
void insert(const char *const unichar_repr, UNICHAR_ID id)
Definition: unicharmap.cpp:76
int get_script(UNICHAR_ID unichar_id) const
Definition: unicharset.h:610
static CHAR_FRAGMENT * parse_from_string(const char *str)
bool contains_unichar(const char *const unichar_repr) const
Definition: unicharset.cpp:644
void reserve(int unichars_number)
Definition: unicharset.cpp:179
#define UNICHAR_LEN
Definition: unichar.h:30
void set_script(UNICHAR_ID unichar_id, const char *value)
Definition: unicharset.h:419
bool contains(const char *const unichar_repr) const
Definition: unicharmap.cpp:101
const char * get_unichar() const
Definition: unicharset.h:64
UNICHAR_ID UNICHARSET::unichar_to_id ( const char *const  unichar_repr) const

Definition at line 194 of file unicharset.cpp.

194  {
195  return ids.contains(unichar_repr) ?
196  ids.unichar_to_id(unichar_repr) : INVALID_UNICHAR_ID;
197 }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharmap.cpp:36
bool contains(const char *const unichar_repr) const
Definition: unicharmap.cpp:101
UNICHAR_ID UNICHARSET::unichar_to_id ( const char *const  unichar_repr,
int  length 
) const

Definition at line 199 of file unicharset.cpp.

200  {
201  assert(length > 0 && length <= UNICHAR_LEN);
202  return ids.contains(unichar_repr, length) ?
203  ids.unichar_to_id(unichar_repr, length) : INVALID_UNICHAR_ID;
204 }
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharmap.cpp:36
#define UNICHAR_LEN
Definition: unichar.h:30
bool contains(const char *const unichar_repr) const
Definition: unicharmap.cpp:101

Member Data Documentation

const char * UNICHARSET::kCustomLigatures
static
Initial value:
= {
{"ct", "\uE003"},
{"ſh", "\uE006"},
{"ſi", "\uE007"},
{"ſl", "\uE008"},
{"ſſ", "\uE009"},
{NULL, NULL}
}

Definition at line 144 of file unicharset.h.

const char * UNICHARSET::kSpecialUnicharCodes
static
Initial value:
= {
" ",
"Joined",
"|Broken|0|1"
}

Definition at line 147 of file unicharset.h.


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