Re: [ft-devel] ttfautohint: fun with assembler code
On 05/07/2011 01:35 PM, Werner LEMBERG wrote: Thanks for you suggestions! Working with bytecode instructions must be actively trained, like any other programming language, then the obstacles diminish. Just for the fun of it, I installed the xgridfit. Learnt and wrote a xgridfit version of the compute_stem_width() function. Porting the pseudo code was fairly straight forward. Xgridfit has quite a rich set of APIs. But the generated code is much longer than your hand craft version, 400+ lines vs 150 lines. A lot of stack management codes. Xgridfit lost in code size... ?xml version=1.0? xgridfit xmlns=http://xgridfit.sourceforge.net/Xgridfit2; infileempty.sfd/infile outfileempty2.sfd/outfile control-value name=std_width value=50/ function name=stem-width return=yes param name=width/ param name=is_serif/ param name=is_round/ variable name=dist/ variable name=delta/ absolute value=width result-to=dist/ if test=is_serif and (dist lt; (3 * 64)) set-equal target=return source=width/ else if test=is_round set-equal target=dist source=64/ else minimum value1=56 value2=dist result-to=dist/ /else /if /else /if absolute value=dist - control-value(std_width) result-to=delta/ if test=delta lt; 40 minimum value1=48 value2=control-value(std_width) result-to=dist/ else if test=dist lt; 3 * 64 set-equal target=delta source=dist/ floor value=dist result-to=dist/ set-equal target=delta source=delta - dist/ if test=delta lt; 10 add value1=dist value2=delta result-to=dist/ elseif test=delta lt; 32 set-equal source=dist + 10 target=dist/ elseif test=delta lt; 54 set-equal source=dist + 54 target=dist/ else set-equal source=dist + delta target=dist/ /else /if/else /if/else /if else set-equal source=floor(dist + 32) target=dist/ /else /if /else /if if test=width lt; 0 set-equal target=dist source=negative(dist)/ /if set-equal target=return source=dist/ /function pre-program /pre-program /xgridfit PUSHB_1 4 FDEF DEPTH PUSHB_1 17 SWAP WS PUSHB_1 19 PUSHB_1 18 RS PUSHB_1 2 ADD WS PUSHB_2 4 0 WS DEPTH PUSHB_1 17 RS SUB PUSHB_1 1 ADD CINDEX ABS PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS DEPTH PUSHB_1 17 RS SUB PUSHB_1 2 ADD CINDEX PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 3 PUSHB_1 64 MUL LT AND IF DEPTH PUSHB_1 17 RS SUB PUSHB_1 1 ADD CINDEX PUSHB_1 4 SWAP WS ELSE DEPTH PUSHB_1 17 RS SUB PUSHB_1 3 ADD CINDEX IF PUSHB_1 64 PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS ELSE PUSHB_1 56 PUSHB_1 18 RS PUSHB_1 1 ADD RS MIN PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS EIF EIF PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 0 RCVT SUB ABS PUSHB_1 18 RS PUSHB_1 2 ADD SWAP WS PUSHB_1 18 RS PUSHB_1 2 ADD RS PUSHB_1 40 LT IF PUSHB_1 48 PUSHB_1 0 RCVT MIN PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS ELSE PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 3 PUSHB_1 64 MUL LT IF PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 18 RS PUSHB_1 2 ADD SWAP WS PUSHB_1 18 RS PUSHB_1 1 ADD RS FLOOR PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS PUSHB_1 18 RS PUSHB_1 2 ADD RS PUSHB_1 18 RS PUSHB_1 1 ADD RS SUB PUSHB_1 18 RS PUSHB_1 2 ADD SWAP WS PUSHB_1 18 RS PUSHB_1 2 ADD RS PUSHB_1 10 LT IF PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 18 RS PUSHB_1 2 ADD RS ADD PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS ELSE PUSHB_1 18 RS PUSHB_1 2 ADD RS PUSHB_1 32 LT IF PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 10 ADD PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS ELSE PUSHB_1 18 RS PUSHB_1 2 ADD RS PUSHB_1 54 LT IF PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 54 ADD PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS ELSE PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 18 RS PUSHB_1 2 ADD RS ADD PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS EIF EIF EIF ELSE PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 32 ADD FLOOR PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS EIF EIF DEPTH PUSHB_1 17 RS SUB PUSHB_1 1 ADD CINDEX PUSHB_1 0 LT IF PUSHB_1 18 RS PUSHB_1 1 ADD RS NEG PUSHB_1 18 RS PUSHB_1 1 ADD SWAP WS EIF PUSHB_1 18 RS PUSHB_1 1 ADD RS PUSHB_1 4 SWAP WS POP POP POP ENDF ___ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] ttfautohint: fun with assembler code
Thanks for you suggestions! Working with bytecode instructions must be actively trained, like any other programming language, then the obstacles diminish. Maybe you can make use of the xgridfit tool to semi auto-gen the TT instructions. Maybe. However, the idea was to write a library in C, not dependent on other external programs. In the last few days I make good progress (for example, code for creating a `prep' table has been added together with some more `fpgm' functions), and it will take just a few days, I believe, to have first (bad) hinting results. Werner ___ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel