Git Product home page Git Product logo

hf2gcode's Introduction

hf2gcode, a hershey font to g-code tracer

demo_hello_world.ngc in LinuxCNC (The image above shows src/demo_hello_word.ngc in LinuxCNCs simulator with sim/axis/axis_mm.ini)

The current release is "hf2gcode 0.3.0", please see topic "Bugs" or "TODO" below before you report a bug.

German "Umlaute" ÄÖÜäöü are only implementes in font rowmans (hf2gcode default) yet. Demo with German Umlaut, rendered with ncviewer.com

Available fonts in "hf2gcode 0.3.0": cursive, futural, futuram, gothgbt, gothgrt, gothiceng, gothicger, gothicita, gothitt, greekc, greek, greeks, rowmand, rowmans, rowmant, scriptc, scripts, symbolic, timesg, timesib, timesi, timesrb, timesr

Overview on http://www.tech-chat.de/png_album/

Dependencies

  • gcc, the GNU Compiler Collection, libc
  • GNU argp
  • (OPTIONAL) GNU Octave if you want to generate the hershey font overview svgs or to generated the hershey_font C declarations.

Build

cd src
make

Usage

./hf2gcode --usage
Usage: hf2gcode [-aclrmqu?V] [-h FONT] [-i FILE] [-o FILE] [-s SCALE]
        [-f FEED] [-x X0] [-y Y0] [-n YINC] [-p PREC] [--append]
        [--font=FONT] [--input=FILE] [--output=FILE] [--scale=SCALE]
        [--feed=FEED] [--xoffset=X0] [--yoffset=Y0] [--z-down=ZDown]
        [--z-up=ZUp] [--align-center] [--align-left] [--interline=YINC]
        [--align-right] [--min-gcode] [--no-post] [--no-pre]
        [--precision=PREC] [--quiet] [--inch] [--help] [--usage]
        [--version] [TEXT]

Help

  ./hf2gcode --help
  Usage: hf2gcode [OPTION...] [TEXT]
  hf2gcode, a hershey font to g-code tracer

    -a, --append               Append to output file instead of overwriting
    -h, --font=FONT            Use FONT instead of default font "rowmans"
    -i, --input=FILE           Read text from FILE instead of stdin
    -o, --output=FILE          Output to FILE instead of stdout
    -s, --scale=SCALE          Base unit/hershey font unit (default 0.5)

   G-code base settings:
    -f, --feed=FEED            Feed rate (default 200)
    -x, --xoffset=X0           X-Axis offset (default 0)
    -y, --yoffset=Y0           Y-Axis offset (default 0)
        --z-down=ZDown         PenDown Z value (default -1)
        --z-up=ZUp             PenUp Z value (default 1)

   Multiline settings:
    -c, --align-center         Center multiple lines
    -l, --align-left           Left align multiple lines (default)
    -n, --interline=YINC       Interline spacing in Y direction for multiple
                               lines (default 15)
    -r, --align-right          Right align multiple lines

   Miscellaneous:
    -m, --min-gcode            Generate minimalistic g-code, suppress comments
        --no-post              Don't include postamble
        --no-pre               Don't include preamble
    -p, --precision=PREC       Precision for G-Code generation (default 3)
    -q, --quiet                Don't produce any output to stdout
    -u, --inch                 Use United States customary units (inch instead of
                               mm) as base unit

    -?, --help                 Give this help list
        --usage                Give a short usage message
    -V, --version              Print program version

  Mandatory or optional arguments to long options are also mandatory or optional
  for any corresponding short options.

  Report bugs to <[email protected]>.

Design and structure

  • hershey_fonts/orig/*.jhf: original hershey fonts, see hershey_fonts/README
  • hershey_fonts/fixed/*.jhf: generated with fix_linebreak.sh from orig
  • OPTIONAL hershey_fonts/rendered_svg: All fonts as SVG, generated from src/render_hf (see http://www.tech-chat.de/png_album/)
  • hershey_fonts/gen_c_src/*.h: Font declarations, generated with src/gen_C_code.m
  • src/libhf2gcode.c and .h: Actual type setting/tracing
  • src/hf2gcode.c: A command line interface program to call libhf2gcode

The libhf2gcode should also be compilable with avr-gcc and run on an AVR Atmega32. Only font "rowmans" and "scripts" are available if the MACRO AVR is set. The Needler project reads user input from 8x8 matrix keyboard, generates the g-code with libhf2gcode and sends the generated g-code to grbl which controlls the stepper for the CNC mill.

Testing the generated output

The resulting g-code can be tested with LinuxCNC as simulator or any other software which reads g-code. There are LinuxCNC simulator binaries for various Ubuntus (IMHO outdated) or you might compile the source:

http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Build_A_Simulator_Manually

Short summary for Debian 7.0 wheezy:

  git clone git://git.linuxcnc.org/git/linuxcnc.git linuxcnc
  cd linuxcnc/debian && ./configure sim
  cd .. && dpkg-checkbuilddeps

Install the dependencies with apt-get or aptitude

  cd src && ./autogen.sh && ./configure --enable-simulator
  make

Then run ./linuxcnc in linuxcnc/scripts and select a simulated machinge e.g. sim/axis/axis_mm.ini

TODO / not yet implemented features

  • Multiline align-right or align-center ist not yet implemented, please use the default "align-left" instead.

  • Don't lift the pen if the start position of the next glyph is the same as the end position of the current. For example see a text which uses font "scripts".

Bugs

Zarro Boogs Found

License

GPLv3, see file LICENSE

Unsorted Links

hf2gcode's People

Contributors

andy1978 avatar arceye avatar jackcarrozzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hf2gcode's Issues

multi-line text: x offset should apply to each line

If I try to generate g-code from an input file with line breaks, the x offset only indents the first line, but not the following lines.

e.g. hf2gcode --font=scripts -o out.nc -i in.txt -s 0.3 -y 100 -x 100

Couldnot make on raspberry pi

pi@raspberrypi:~/hf2gcode $ make
make -C src
make[1]: Entering directory '/home/pi/hf2gcode/src'
make -C ../hershey_fonts src
make[2]: Entering directory '/home/pi/hf2gcode/hershey_fonts'
./fix_linebreak.sh orig/greeks.jhf fixed/greeks.jhf
removing unwanted linebreak and CR in orig/greeks.jhf
./fix_linebreak.sh: line 7: gawk: command not found
make[2]: *** [Makefile:19: fixed/greeks.jhf] Error 127
rm fixed/greeks.jhf
make[2]: Leaving directory '/home/pi/hf2gcode/hershey_fonts'
make[1]: *** [Makefile:11: hf2gcode] Error 2
make[1]: Leaving directory '/home/pi/hf2gcode/src'
make: *** [Makefile:4: simple] Error 2

G-Code output too long for GRBL and LinuxCNC

Please split the text and add some line-breaks to the "( text='...' )" G-Code output:

https://github.com/Andy1978/hf2gcode/blob/master/src/hf2gcode.c#L298

hf2gcode generated G-Code with long input texts does not work on GRBL and LinuxCNC:

  • The GRBL motion controller has a line length limit (– 50 for older versions, 70 for 0.8c dev or later),
  • The LinuxCNC / Machinekit NIST rs274 G-Code interpreter has a line length limit, too (– don't know the exact values but just ran into this):
Interpreter exited with error:
Command too long
( text="123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456

Error when building project

Hey Andy,

I'm having an error when building this program. I've installed the make command using Chocolatey, and when I run that command on the src folder, this is the output:

C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe -C ../hershey_fonts src
make[1]: Entering directory 'C:/Users/techmaster/Downloads/hf2gcode-master/hershey_fonts'
./fix_linebreak.sh orig/astrology.jhf fixed/astrology.jhf
process_begin: CreateProcess(NULL, bash C:\Users\techmaster\Downloads\hf2gcode-master\hershey_fonts\fix_linebreak.sh orig/astrology.jhf fixed/astrology.jhf, ...) failed.
make (e=2): The system cannot find the file specified.
make[1]: *** [Makefile:21: fixed/astrology.jhf] Error 2
make[1]: Leaving directory 'C:/Users/techmaster/Downloads/hf2gcode-master/hershey_fonts'
make: *** [Makefile:12: hf2gcode] Error 2
PS C:\Users\techmaster\Downloads\hf2gcode-master\src>

As you can see. it cannot find fixed/astrology.jhf. Running the make command leaves two empty folders, however. These folders are -p and fixed.

Didn't get proper gcode file

Hi there,

I tried to build this project:

make -C ../hershey_fonts src
make[1]: Entering directory '/home/pi/dev/hf2gcode/hershey_fonts'
./fix_linebreak.sh orig/greeks.jhf fixed/greeks.jhf
removing unwanted linebreak and CR in orig/greeks.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/greeks.jhf","gen_c_src/greeks.h")'
./fix_linebreak.sh orig/gothiceng.jhf fixed/gothiceng.jhf
removing unwanted linebreak and CR in orig/gothiceng.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/gothiceng.jhf","gen_c_src/gothiceng.h")'
./fix_linebreak.sh orig/timesr.jhf fixed/timesr.jhf
removing unwanted linebreak and CR in orig/timesr.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/timesr.jhf","gen_c_src/timesr.h")'
./fix_linebreak.sh orig/music.jhf fixed/music.jhf
removing unwanted linebreak and CR in orig/music.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/music.jhf","gen_c_src/music.h")'
./fix_linebreak.sh orig/astrology.jhf fixed/astrology.jhf
removing unwanted linebreak and CR in orig/astrology.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/astrology.jhf","gen_c_src/astrology.h")'
./fix_linebreak.sh orig/scripts.jhf fixed/scripts.jhf
removing unwanted linebreak and CR in orig/scripts.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/scripts.jhf","gen_c_src/scripts.h")'
./fix_linebreak.sh orig/cyrilc_1.jhf fixed/cyrilc_1.jhf
removing unwanted linebreak and CR in orig/cyrilc_1.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/cyrilc_1.jhf","gen_c_src/cyrilc_1.h")'
./fix_linebreak.sh orig/gothgbt.jhf fixed/gothgbt.jhf
removing unwanted linebreak and CR in orig/gothgbt.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/gothgbt.jhf","gen_c_src/gothgbt.h")'
./fix_linebreak.sh orig/symbolic.jhf fixed/symbolic.jhf
removing unwanted linebreak and CR in orig/symbolic.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/symbolic.jhf","gen_c_src/symbolic.h")'
./fix_linebreak.sh orig/futuram.jhf fixed/futuram.jhf
removing unwanted linebreak and CR in orig/futuram.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/futuram.jhf","gen_c_src/futuram.h")'
./fix_linebreak.sh orig/cyrillic.jhf fixed/cyrillic.jhf
removing unwanted linebreak and CR in orig/cyrillic.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/cyrillic.jhf","gen_c_src/cyrillic.h")'
./fix_linebreak.sh orig/timesib.jhf fixed/timesib.jhf
removing unwanted linebreak and CR in orig/timesib.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/timesib.jhf","gen_c_src/timesib.h")'
./fix_linebreak.sh orig/mathlow.jhf fixed/mathlow.jhf
removing unwanted linebreak and CR in orig/mathlow.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/mathlow.jhf","gen_c_src/mathlow.h")'
./fix_linebreak.sh orig/greek.jhf fixed/greek.jhf
removing unwanted linebreak and CR in orig/greek.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/greek.jhf","gen_c_src/greek.h")'
./fix_linebreak.sh orig/markers.jhf fixed/markers.jhf
removing unwanted linebreak and CR in orig/markers.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/markers.jhf","gen_c_src/markers.h")'
./fix_linebreak.sh orig/timesg.jhf fixed/timesg.jhf
removing unwanted linebreak and CR in orig/timesg.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/timesg.jhf","gen_c_src/timesg.h")'
./fix_linebreak.sh orig/meteorology.jhf fixed/meteorology.jhf
removing unwanted linebreak and CR in orig/meteorology.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/meteorology.jhf","gen_c_src/meteorology.h")'
./fix_linebreak.sh orig/japanese.jhf fixed/japanese.jhf
removing unwanted linebreak and CR in orig/japanese.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/japanese.jhf","gen_c_src/japanese.h")'
./fix_linebreak.sh orig/timesrb.jhf fixed/timesrb.jhf
removing unwanted linebreak and CR in orig/timesrb.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/timesrb.jhf","gen_c_src/timesrb.h")'
./fix_linebreak.sh orig/gothgrt.jhf fixed/gothgrt.jhf
removing unwanted linebreak and CR in orig/gothgrt.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/gothgrt.jhf","gen_c_src/gothgrt.h")'
./fix_linebreak.sh orig/greekc.jhf fixed/greekc.jhf
removing unwanted linebreak and CR in orig/greekc.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/greekc.jhf","gen_c_src/greekc.h")'
./fix_linebreak.sh orig/mathupp.jhf fixed/mathupp.jhf
removing unwanted linebreak and CR in orig/mathupp.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/mathupp.jhf","gen_c_src/mathupp.h")'
./fix_linebreak.sh orig/rowmans.jhf fixed/rowmans.jhf
removing unwanted linebreak and CR in orig/rowmans.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/rowmans.jhf","gen_c_src/rowmans.h")'
./fix_linebreak.sh orig/timesi.jhf fixed/timesi.jhf
removing unwanted linebreak and CR in orig/timesi.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/timesi.jhf","gen_c_src/timesi.h")'
./fix_linebreak.sh orig/cursive.jhf fixed/cursive.jhf
removing unwanted linebreak and CR in orig/cursive.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/cursive.jhf","gen_c_src/cursive.h")'
./fix_linebreak.sh orig/gothitt.jhf fixed/gothitt.jhf
removing unwanted linebreak and CR in orig/gothitt.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/gothitt.jhf","gen_c_src/gothitt.h")'
./fix_linebreak.sh orig/rowmant.jhf fixed/rowmant.jhf
removing unwanted linebreak and CR in orig/rowmant.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/rowmant.jhf","gen_c_src/rowmant.h")'
./fix_linebreak.sh orig/gothicita.jhf fixed/gothicita.jhf
removing unwanted linebreak and CR in orig/gothicita.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/gothicita.jhf","gen_c_src/gothicita.h")'
./fix_linebreak.sh orig/scriptc.jhf fixed/scriptc.jhf
removing unwanted linebreak and CR in orig/scriptc.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/scriptc.jhf","gen_c_src/scriptc.h")'
./fix_linebreak.sh orig/gothicger.jhf fixed/gothicger.jhf
removing unwanted linebreak and CR in orig/gothicger.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/gothicger.jhf","gen_c_src/gothicger.h")'
./fix_linebreak.sh orig/futural.jhf fixed/futural.jhf
removing unwanted linebreak and CR in orig/futural.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/futural.jhf","gen_c_src/futural.h")'
./fix_linebreak.sh orig/rowmand.jhf fixed/rowmand.jhf
removing unwanted linebreak and CR in orig/rowmand.jhf
octave -q --eval 'addpath("../src/"); gen_C_code("fixed/rowmand.jhf","gen_c_src/rowmand.h")'
rm fixed/futural.jhf fixed/japanese.jhf fixed/cyrilc_1.jhf fixed/timesr.jhf fixed/scripts.jhf fixed/meteorology.jhf fixed/astrology.jhf fixed/greek.jhf fixed/rowmans.jhf fixed/cursive.jhf fixed/mathlow.jhf fixed/music.jhf fixed/greekc.jhf fixed/timesi.jhf fixed/gothgrt.jhf fixed/gothicita.jhf fixed/timesrb.jhf fixed/greeks.jhf fixed/timesib.jhf fixed/gothicger.jhf fixed/rowmant.jhf fixed/gothitt.jhf fixed/symbolic.jhf fixed/gothgbt.jhf fixed/cyrillic.jhf fixed/mathupp.jhf fixed/markers.jhf fixed/scriptc.jhf fixed/futuram.jhf fixed/gothiceng.jhf fixed/rowmand.jhf fixed/timesg.jhf
make[1]: Leaving directory '/home/pi/dev/hf2gcode/hershey_fonts'
gcc -Wall -Wextra -O0 -ggdb hf2gcode.c libhf2gcode.c -o hf2gcode
libhf2gcode.c: In function ‘get_gcode_line’:
libhf2gcode.c:406:12: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (x==-50 && y==0) /Pen-Up/
^~
./hf2gcode -i demo.txt -o demo_hello_world.ngc -y 23
./hf2gcode -m -s 0.3 -p 2 -f 800 -i demo.txt -o demo_hello_world_needler.ngc -y 23
./hf2gcode -i demo.txt --font=scripts -o demo_hello_world_scripts.ngc -y 23

but when I open the ngc file, it doesn't have the letters I am expecting. I am wondering what I missed. Thank you.

This is what I get:
Screenshot at Oct 24 10-15-37

demo_hello_world_scripts.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.