---------------------------------------------------------------------------- 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
| 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. |
| 46 | void 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_ |
no test coverage detected