Skip to content

Commit

Permalink
Rework glyp table generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Weber committed Apr 25, 2022
1 parent 350ebf2 commit 47ace18
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ Dependencies
------------
* gcc, the GNU Compiler Collection, libc
* [GNU argp](http://www.gnu.org/software/libc/manual/html_node/Argp.html)
* (OPTIONAL) GNU Octave if you want to generate the hershey font overview pngs and svgs or to generated the hershey_font C declarations.
* (OPTIONAL) photon if you want to generate a static HTML page with rendered fonts like http://www.tech-chat.de/png_album/
* (OPTIONAL) GNU Octave if you want to generate the hershey font overview svgs or to generated the hershey_font C declarations.

Build
-----
Expand Down Expand Up @@ -109,7 +108,7 @@ 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_png and rendered_svg: All fonts as PNG or SVG, generated from src/render_hf (see http://www.tech-chat.de/png_album/)
* 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
Expand Down
6 changes: 1 addition & 5 deletions hershey_fonts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
.SECONDARY:

fixed_hf = $(subst orig,fixed,$(wildcard orig/*.jhf))
rendered_hf_png = $(patsubst %.jhf,%.png,$(subst orig,rendered_png,$(wildcard orig/*.jhf)))
rendered_hf_svg = $(patsubst %.jhf,%.svg,$(subst orig,rendered_svg,$(wildcard orig/*.jhf)))
gen_c = $(patsubst %.jhf,%.h,$(subst orig,gen_c_src,$(wildcard orig/*.jhf)))

Expand All @@ -22,12 +21,9 @@ fixed/%.jhf: orig/%.jhf ./fix_linebreak.sh
./fix_linebreak.sh $< $@
find ./patches -name "$(basename $(notdir $@))_*.patch" -exec sh -c "patch -p1 < {}" \;

rendered_png/%.png rendered_svg/%.svg: fixed/%.jhf $(RENDER_DEP)
rendered_svg/%.svg: fixed/%.jhf $(RENDER_DEP)
octave -q --eval 'addpath("../src/"); render_hf("$<", "rendered_png", "rendered_svg")'

png_album: $(rendered_hf_png)
photon -J -s 0 -t 800x800 -E -d 1 -l40 -o png_album rendered_png

gen_c_src/%.h:fixed/%.jhf ../src/gen_C_code.m ../src/load_hf.m
@mkdir -p gen_c_src
octave -q --eval 'addpath("../src/"); gen_C_code("$<","$@")'
Expand Down
5 changes: 3 additions & 2 deletions src/plot_hf_glyph.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ function plot_hf_glyph(glyph, xo, yo, plot_margins=0)
hold on
plot([glyph.rightmargin+xo, glyph.rightmargin+xo], [10+yo -10+yo],"-r");
endif
text(xo-5,yo-20,num2str(glyph.num));
#text(xo-5,yo-20,num2str(glyph.num));
m=numel(glyph.x);
if (m>0)
for k=1:m+1
if (k==m+1 || (((glyph.x(k)==-50) && glyph.y(k)==0))) ## last element or Pen-Up command
px=glyph.x(s:k-1)+xo;
## inverted, in hershey font y positive down
py=-glyph.y(s:k-1)+yo;
plot(px, py)
plot(px, py, "-b")
if(!plot_margins)
hold on;
endif
Expand All @@ -44,4 +44,5 @@ function plot_hf_glyph(glyph, xo, yo, plot_margins=0)
endfor
endif
hold off
axis off
endfunction
18 changes: 5 additions & 13 deletions src/render_hf.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,19 @@

## -*- texinfo -*-
## @deftypefn {Function File} {} render_hf (@var{fn}, @var{outdir})
## Render hershey font using octave, export it to PNG and SVG image.
## Render hershey font using octave and export it as SVG.
## Its purpose is to get an overview over the available glyphs.
## Attention: outdir works only once, (not like mkdir -p).
## @seealso{plot_hf}
## @end deftypefn

function render_hf (fn, png_out = "./rendered_png", svg_out = "./rendered_svg")
function render_hf (fn, svg_out = "./rendered_svg")
[DIR, NAME, EXT] = fileparts (fn);

mkdir (png_out);
mkdir (svg_out);

fn_png = fullfile(png_out, [NAME ".png"]);
fn_svg = fullfile(svg_out, [NAME,".svg"]);
printf("Rendering %s and %s from %s...\n",fn_png,fn_svg,fn);
printf("Rendering %s from %s...\n", fn_svg, fn);
fflush(stdout);

hf = load_hf (fn);
figure("visible","off");
plot_hf(hf), axis square

print(fn_png,"-S1200,1200")
print(fn_svg,"-S1200,1200")
plot_hf(hf)
print (fn_svg)
endfunction

0 comments on commit 47ace18

Please sign in to comment.