MCPcopy Create free account
hub / github.com/creatale/node-dv / ExtractFontName

Function ExtractFontName

deps/tesseract/classify/blobclass.cpp:46–60  ·  view source on GitHub ↗

---------------------------------------------------------------------------- Public Code ----------------------------------------------------------------------------**/ Finds the name of the training font and returns it in fontname, by cutting it out based on the expectation that the filename is of the form: /path/to/dir/[lang].[fontname].exp[num] The [lang], [fontname] and [num] field

Source from the content-addressed store, hash-verified

44// The [lang], [fontname] and [num] fields should not have '.' characters.
45// If the global parameter classify_font_name is set, its value is used instead.
46void ExtractFontName(const STRING& filename, STRING* fontname) {
47 *fontname = classify_font_name;
48 if (*fontname == kUnknownFontName) {
49 // filename is expected to be of the form [lang].[fontname].exp[num]
50 // The [lang], [fontname] and [num] fields should not have '.' characters.
51 const char *basename = strrchr(filename.string(), '/');
52 const char *firstdot = strchr(basename ? basename : filename.string(), '.');
53 const char *lastdot = strrchr(filename.string(), '.');
54 if (firstdot != lastdot && firstdot != NULL && lastdot != NULL) {
55 ++firstdot;
56 *fontname = firstdot;
57 fontname->truncate_at(lastdot - firstdot);
58 }
59 }
60}
61
62/*---------------------------------------------------------------------------*/
63// Extracts features from the given blob and saves them in the tr_file_data_

Callers 1

RecognizeMethod · 0.85

Calls 2

truncate_atMethod · 0.80
stringMethod · 0.45

Tested by

no test coverage detected