tesseract v5.3.3.20231005
unicharset_training_utils.h
Go to the documentation of this file.
1
2// File: unicharset_training_utils.h
3// Description: Training utilities for UNICHARSET.
4// Author: Ray Smith
5//
6// (C) Copyright 2014, Google Inc.
7// Licensed under the Apache License, Version 2.0 (the "License");
8// you may not use this file except in compliance with the License.
9// You may obtain a copy of the License at
10// http://www.apache.org/licenses/LICENSE-2.0
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
18
19#ifndef TESSERACT_TRAINING_UNICHARSET_TRAINING_UTILS_H_
20#define TESSERACT_TRAINING_UNICHARSET_TRAINING_UTILS_H_
21
22#include "export.h"
23
24#include <tesseract/export.h>
25
26#include <string>
27
28namespace tesseract {
29
30class UNICHARSET;
31
32// Helper sets the character attribute properties and sets up the script table.
33// Does not set tops and bottoms.
34TESS_UNICHARSET_TRAINING_API
35void SetupBasicProperties(bool report_errors, bool decompose, UNICHARSET *unicharset);
36// Default behavior is to compose, until it is proven that decomposed benefits
37// at least one language.
38inline void SetupBasicProperties(bool report_errors, UNICHARSET *unicharset) {
39 SetupBasicProperties(report_errors, false, unicharset);
40}
41// Helper sets the properties from universal script unicharsets, if found.
42TESS_UNICHARSET_TRAINING_API
43void SetScriptProperties(const std::string &script_dir, UNICHARSET *unicharset);
44// Helper gets the combined x-heights string.
45std::string GetXheightString(const std::string &script_dir, const UNICHARSET &unicharset);
46
47// Helper to set the properties for an input unicharset file, writes to the
48// output file. If an appropriate script unicharset can be found in the
49// script_dir directory, then the tops and bottoms are expanded using the
50// script unicharset.
51// If non-empty, xheight data for the fonts are written to the xheights_file.
52TESS_UNICHARSET_TRAINING_API
53void SetPropertiesForInputFile(const std::string &script_dir,
54 const std::string &input_unicharset_file,
55 const std::string &output_unicharset_file,
56 const std::string &output_xheights_file);
57
58} // namespace tesseract.
59
60#endif // TESSERACT_TRAINING_UNICHARSET_TRAINING_UTILS_H_
std::string GetXheightString(const std::string &script_dir, const UNICHARSET &unicharset)
void SetupBasicProperties(bool report_errors, bool decompose, UNICHARSET *unicharset)
void SetPropertiesForInputFile(const std::string &script_dir, const std::string &input_unicharset_file, const std::string &output_unicharset_file, const std::string &output_xheights_file)
void SetScriptProperties(const std::string &script_dir, UNICHARSET *unicharset)