# pdic2c.pl

## Description

`pdic2c.pl` is a sample tool that converts text format pattern data obtained by running the character recognition demo `characterRecognition-2` into C source files that can be used directly by the program.

## How to Use

### Start Command

`% perl pdic2c.pl [-ch] [-C OUTPUT_SOURCE] [-H OUTPUT_HEADER] [-i INCLUDE_FILE] [-p PREFIX] NORMALIZE_SIZE [PATTERN_FILES]...`

The text data contained in the files specified in `PATTERN_FILES` is interpreted as sample character dictionary data. The C source file and the header are consecutively output as standard output. The normalized size of the output data is specified in `NORMALIZE_SIZE`. `PATTERN_FILES` can be omitted. When it is, the data is read from standard input.

When either `-c, -h` is specified as an option, either the source file or the header file is output. When it's unspecified, both are output. Also, if each of the `-C, -H` options are specified, instead of regular output, it is possible to specify the source file name and header file name of the output destination.

There is a code in the source file that #includes the header file. The path name is specified with the `-i` option. When there is no `-i` option, only the file name part of the path name that is specified by the `-H` option is used. When nothing is specified, `patternDict.h` is used.

The `-p`option can be used to specify the prefix attached to the identifier in the generated source file.``

### Character Dictionary Text Data Fonts

`pdic2c.pl` interprets text data as one item per line on the basis of the following forms:

    line   ::= "PatternName" Kind Correction NormalizeSize '|' stroke+
    stroke ::= point+ '|'
    point  ::= '(' X ',' Y ')'

Format | Description | Details
--- | --- | ---
`"Pattern Name"` | Item Name | This is the name of the characters shown in this item. Code values are assigned starting at 0 in the order that the names appear and the correspondence between the code and the name are output as a `PatternName` matrix.
`Kind` | Type of Character | This is the value that is output to the `PRCPrototypeEntry` kind.
`Correction` | Corrected Value | This is the value that is output to the `PRCPrototypeEntry` correction.
`NormalizeSize` | Normalize Size | For this item, the values assume a bounding box so that the upper left is (0, 0) and lower right is (NormalizeSize-1, NormalizeSize-1). When these differ from the arguments of `pdic2c.pl`, output will take place after the coordinate values that follow this item have been enlarged or reduced to match the size of the argument.
`'|'` | Break | The vertical line indicates that the pen left the paper once and the line stopped.
`(X, Y)` | Coordinates | This indicates the pattern coordinates. Please be careful to note that, in order to align with the screen coordinates, that the upper left is (0, 0).
# ... | Comment | This is interpreted as an explicit comment row and it reads it and discards it without doing anything.

Scenarios for the use of this tool include the character recognition sample demo `characterRecognition-2` in which the pattern data output as debug output when the Y button is pressed is cut and pasted and text format character sample data are created. By passing that test file to `pdic2c.pl`, it is possible to generate source code for the list of character samples used with character recognition API.

When all are sent to standard output, the first half is a header file for other source codes using a figure list, and the second half is a source file containing concrete data. Divide and rewrite them accordingly when you use them.

## Location

`$NitroSDK/tools/bin/pdic2c.pl`

## See Also

`Character Recognition Sample Demo characterRecognition-2`

## Revision History

10/04/2005 Noted addition of arguments.
10/28/2004 Changed regularize to normalize.
2004/06/30 Initial version.

CONFIDENTIAL