51 assert (Templates !=
nullptr);
52 assert (Class !=
nullptr);
60 assert (Templates->
Class[ClassId] ==
nullptr);
61 Templates->
Class[ClassId] = Class;
76 assert (
Config !=
nullptr);
163 Templates->
Class[i] =
nullptr;
185 if (templates !=
nullptr) {
186 for (
int i = 0; i < (templates->
Templates)->NumClasses; i++)
205 int NumProtos = MaxProtoId + 1;
211 Config->MaxProtoId = MaxProtoId;
214 Config->FontinfoId = FontinfoId;
249 fprintf (
File,
"\n\nSUMMARY OF ADAPTED TEMPLATES:\n\n");
250 fprintf (
File,
"Num classes = %d; Num permanent classes = %d\n\n",
252 fprintf (
File,
" Id NC NPC NP NPP\n");
253 fprintf (
File,
"------------------------\n");
255 for (
int i = 0; i < (Templates->
Templates)->NumClasses; i++) {
257 AClass = Templates->
Class[i];
259 fprintf (
File,
"%5d %s %3d %3d %3d %3d\n",
266 fprintf (
File,
"\n");
301 fp->
FRead(&NumTempProtos,
sizeof(
int), 1);
303 for (i = 0; i < NumTempProtos; i++) {
310 fp->
FRead(&NumConfigs,
sizeof(
int), 1);
311 for (i = 0; i < NumConfigs; i++)
344 for (
int i = 0; i < (Templates->
Templates)->NumClasses; i++) {
366 fp->
FRead(&NumAmbigs,
sizeof(NumAmbigs), 1);
369 Config->Ambigs[NumAmbigs] = -1;
426 fwrite(&NumTempProtos,
sizeof(
int), 1, File);
434 fwrite(&NumConfigs,
sizeof(
int), 1, File);
435 for (i = 0; i < NumConfigs; i++)
464 for (i = 0; i < (Templates->
Templates)->NumClasses; i++) {
483 uint8_t NumAmbigs = 0;
485 assert (
Config !=
nullptr);
486 while (
Config->Ambigs[NumAmbigs] > 0) ++NumAmbigs;
488 fwrite(&NumAmbigs,
sizeof(uint8_t), 1, File);
490 fwrite(&(
Config->FontinfoId),
sizeof(
int), 1, File);
505 assert (
Config !=
nullptr);
508 fwrite(
Config->Protos, sizeof (uint32_t),
Config->ProtoVectorSize, File);
void AddAdaptedClass(ADAPT_TEMPLATES Templates, ADAPT_CLASS Class, CLASS_ID ClassId)
void WritePermConfig(FILE *File, PERM_CONFIG Config)
ADAPT_TEMPLATES ReadAdaptedTemplates(TFile *File)
int FRead(void *buffer, size_t size, int count)
TEMP_CONFIG_STRUCT * TEMP_CONFIG
void free_int_templates(INT_TEMPLATES templates)
ADAPT_CLASS_STRUCT * ADAPT_CLASS
#define WordsInVectorOfSize(NumBits)
INT_CLASS Class[MAX_NUM_CLASSES]
void WriteTempConfig(FILE *File, TEMP_CONFIG Config)
int GetFontinfoId(ADAPT_CLASS Class, uint8_t ConfigId)
TEMP_CONFIG ReadTempConfig(TFile *fp)
#define zero_all_bits(array, length)
ADAPT_TEMPLATES_STRUCT * ADAPT_TEMPLATES
ADAPT_TEMPLATES NewAdaptedTemplates(bool InitFromUnicharset)
#define UnusedClassIdIn(T, c)
void FreeBitVector(BIT_VECTOR BitVector)
void free_adapted_templates(ADAPT_TEMPLATES templates)
#define TempConfigFor(Class, ConfigId)
void FreeTempConfig(TEMP_CONFIG Config)
ADAPT_CLASS Class[MAX_NUM_CLASSES]
void destroy_nodes(LIST list, void_dest destructor)
#define PermConfigFor(Class, ConfigId)
BIT_VECTOR NewBitVector(int NumBits)
TEMP_PROTO NewTempProto()
void WriteIntTemplates(FILE *File, INT_TEMPLATES Templates, const UNICHARSET &target_unicharset)
LIST push_last(LIST list, void *item)
void free_adapted_class(ADAPT_CLASS adapt_class)
void PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
TEMP_CONFIG NewTempConfig(int MaxProtoId, int FontinfoId)
#define ConfigIsPermanent(Class, ConfigId)
PERM_CONFIG_STRUCT * PERM_CONFIG
#define IsEmptyAdaptedClass(Class)
ADAPT_CLASS NewAdaptedClass()
void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
ADAPTED_CONFIG Config[MAX_NUM_CONFIGS]
INT_TEMPLATES ReadIntTemplates(TFile *fp)
const char * id_to_unichar(UNICHAR_ID id) const
INT_TEMPLATES NewIntTemplates()
ADAPT_CLASS ReadAdaptedClass(TFile *fp)
void AddIntClass(INT_TEMPLATES Templates, CLASS_ID ClassId, INT_CLASS Class)
TEMP_PROTO_STRUCT * TEMP_PROTO
void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs)
INT_CLASS NewIntClass(int MaxNumProtos, int MaxNumConfigs)
void FreeTempProto(void *arg)
#define test_bit(array, bit)
PERM_CONFIG ReadPermConfig(TFile *fp)