Package: type2nc
type2nc - convert font outline to Klartext codetype2nc converts the outline of characters in a font file to Klartext
code. The resulting nc program can be used on TNC controls to engrave
text in the corresponding font. The nc program can be used similarly to
the engraving cycle 225 with QS-parameters.Contributorsdrunsinn, TobFleischi, Klartext and GuggiJrForumGerman:Industry ArenaRequirementsTo use the resulting Klartext code on a control, it has to have the following
cycles and functions:cycle 7cycle 10cycle 26INSTRSTRLENSTRCOMPFN 9FN 10FN 12FN 18 ID210 NR2FN 18 ID220 NR2 IDX1 and 2FN 18 ID270 NR1 IDX1 and 2For ease of use it is possible to use cycle 225 for parameter definition. If the
control has cycle 225 you can add use command line option--use_cycle_def.Testing was done on a machine with TNC 620 with software version 817600-03. As
long as the requirements listed above are met, it should work fine.
Support for smaller controls like TNC 128 is untested but the output does not
contain any circular path's.InstallationTo be able to use type2nc, you need python 3 and the following library's
installed on your system:numpy>=1.6.2scipy>=0.19.0freetype-py>=1.1argparse >=1.4.0Hershey-Fonts>= 2.1.0Install from Python Packaging IndexTo install type2nc and its dependencies from the Python Packaging Index,
first install python3. After a successful setup, typepip3 install type2ncon the command line.
To get freetype up and running, you might have to install the binary's
for the library. On Linux and macOS, the library is probably already
installed. For Windows, follow the instructions onthis github repo.Program UsageFirst, choose a font that has the necessary characters you
need. Not every font comes with all characters defined by the
Unicode standard. If a character is not available in your font,
it will be replaced with a placeholder. Some sources for fonts:https://fonts.google.com/https://www.google.com/get/noto/https://fontlibrary.org/http://www.fontspace.com/category/openhttps://www.theleagueofmoveabletype.com/The library for reading Hershey Fonts comes bundled with a set of
fonts. The GUI lets you select them individually as files or all by
enabling the option "Include Default Hershey Fonts".Make sure you have the necessary rights to use the font.Open a command prompt and run python3 type2nc.py or double-click thetype2nc.pyfileSelect one or more font files and/or select the option to use the default
Hersehy fontscreate and select an output folder for the resultsenter a step size for the conversion. As the outline of a character
consists of curves, these have to be broken down into smaller line
segments. The smaller the selected step size, the smother the curves
will be. A smaller step size can also increase the resulting file size
(several hundred mb).the program will read the font file and convert the outlines to
Klartext code. This may take some time, depending on the step size
selected earlierWhen the program is finished, it will display some statistics about
the generated codeAfter it is finished, you will find a nc program for every font file
you selected earlier. There will also be a demo program calledtype2nc_demo.Hwith a usage example.Command line interfaceThe program can also be used from the command line. To get information on the
available options, runpython3 type2nc.py -hOutput:`usage: type2nc.py [-h] [-i font input file [font input file ...]] [-o output folder]
[-s step size] [-r] [-c] [-z]Create Klartext NC code from font filesoptional arguments:
-h, --help            show this help message and exit
-i font input file [font input file ...], --input font input file [font input file ...]
path of one or more font files
-o output folder, --out output folder
path to the output folder. If not set, use current directory.
-s step size, --step_size step size
step size: between 0.001 (very fine) and 0.2 (very coarse)
-r, --remove_empty    if set, output won't contain labels for empty chars. overrides -c
-c, --reduce_empty    if set, output will contain labels for empty characters but no actual data
-z, --use_cycle_def   if set, demo output will use cycle 225 for definition of parameters`NC-Code UsageThe nc program uses the Q parameters also used by cycle 225:QS500: Text to engraveQ203: Z-coordinate of surfaceQ201: milling depthQ200: safe distance for rapid feed between charactersQ206: plunging feed rateQ207: milling feed rateQ513: approximate height of the engraved textQ374: angle of the text base lineInternally the nc program uses the following parameters:QL10toQL32: local Q-parameter for internal calculationsQS1andQS3: String-Parameter used as temporary storageAfter setting the Q parameters, make a PGM CALL to the generated .H-file with the code for the selected font.Known Issues / ProblemsMissing Freetype libraryOn Windows, when you install freetype-py, the necessary dll files are not
installed automatically. When trying to run type2nc, you get an error message
ending inRuntimeError: Freetype library not found. To fix this, follow
the instructions onthis github repo.Characters not availibelTo reduce the file size of the output file, it was chosen to limit the
range of characters to specific sections of the Unicode standard:BASIC_LATIN: 0x0020 to 0x007EC1_CTRL_AND_LATIN1_SUPPLEMENT: 0x0080 to 0x00FFIPA_EEXTENTIONS: 0x0250 to 0x02AFGREEK_AND_COPTIC_CHARS: 0x0370 to 0x03FFCYRILLIC_CHARS: 0x0400 to 0x04FFCYRILLIC_SUPPLEMENT_CHARS: 0x0500 to 0x052FARMENIAN_CHARS: 0x0530 to 0x058FHEBREW_CHARS: 0x0590 to 0x05FFARABIC_CHARS: 0x0600 to 0x06FFSYRIAC_CHARS: 0x0700 to 0x074FARABIC_SUPPLEMENT_CHARS: 0x0750 to 0x077FGENERAL_PUNCTUATION: 0x2000 to 0x206FARROW_CHARS: 0x2190 to 0x21FFMATHEMATICAL_CHARS: 0x2200 to 0x22FFMISC_TECH_CHARS: 0x2300 to 0x23FFMISC_SYMBOLS: 0x2600 to 0x26FFDINGBATS: 0x2700 to 0x27BFCJK_UNIFIED_IDEOGRAPHS_PART1: 0x4E00 to 0x9FFFThis results in a total of 23535 charactersIf you need more or other characters, let me know and i will add them.Windows InstallerThere is no All-In-One installer available. If there is enough interest, i may
look into building an installer version.