On Sun, Oct 13, 2013 at 10:15 AM, Khaled Hosny <khaledhosny@eglug.org> wrote:
An external module is fine by me, I’m not concerned about LuaTeX itself
since even the current loader is not integrated, I’m rather concerned
about the ability to use the new loader and shaper with ConTeXt.

A minimal luatex wrapper for harfbuzz for Linux x86_64 is quite straight



Build configuration:

Unicode callbacks (you want at least one):
    Glib:            true
    ICU:            false
    UCDN:            false

Font callbacks (the more the better):
    FreeType:        true

Tools used for command-line utilities:
    Cairo:            true

Additional shapers (the more the better):
    Graphite2:        false

Platform shapers (not normally needed):
    CoreText:        false
    Uniscribe:        false

Other features:
    Documentation:        false
    GObject bindings:    false
    Introspection:        false


core.i
%module core
%{
#include "harfbuzz/hb-ot.h"
#include "harfbuzz/hb-ft.h"
#include "harfbuzz/hb-glib.h"
#include <ft2build.h>
#include FT_FREETYPE_H
%}
%include "harfbuzz/hb-common.h"
%include "harfbuzz/hb-blob.h"
%include "harfbuzz/hb-buffer.h"
%include "harfbuzz/hb-deprecated.h"
%include "harfbuzz/hb-face.h"
%include "harfbuzz/hb-font.h"
%include "harfbuzz/hb-set.h"
%include "harfbuzz/hb-shape.h"
%include "harfbuzz/hb-shape-plan.h"
%include "harfbuzz/hb-unicode.h"
%include "harfbuzz/hb-version.h"
%include "harfbuzz/hb.h";
%include "harfbuzz/hb-ft.h";
%include "harfbuzz/hb-glib.h";
%include "harfbuzz/hb-ot.h";
%include "harfbuzz/hb-ot-layout.h";
%include "harfbuzz/hb-ot-tag.h";
%include "harfbuzz/hb-shape.h";

##
## build-gcc.sh
##
. ./vars.sh
swig  -cpperraswarn  -c++  -lua core.i

rm -vf core_wrap.o
g++   -O2 -fPIC -I./harfbuzz -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$LUAINC52 -c core_wrap.cxx  -o core_wrap.o

rm -vf core.so
g++ -Wall -shared -O2 -Wl,-rpath,'$ORIGIN/.' $CFLAGS \
    core_wrap.o  \
    -llua5.2  $LIBS \
    -o core.so


##
##t vars.sh
##
SWIGPATH=/home/luigisvn/projects/swiglib/swig-2.0.9/linux_x86_64
LUAINC52=/usr/include/lua5.2

CFLAGS="-I./harfbuzz -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -O2 -Wall -L./swiglib/harfbuzz"
LIBS="-lharfbuzz"
export PATH=$SWIGPATH/bin:$LLVMPATH/bin:${PATH}


--
-- test.lua
--
local f,error=package.loadlib("./swiglib/harfbuzz/core.so","luaopen_core");
if not(f) then print(error) return end;
local helpers=f(); for k,v in pairs(helpers) do print(k,v) end

$>luatex test.lua

An idea for freetype is
https://github.com/luigiScarso/ftlua

As Hams wrote
""
In principle one can plug in anything if it behaves nicely, but of course one cannot expect existing mechanisms (we have additional features and such) to be dropped in favor of something else without pretty good reason.
Btw, for me (that is personal) i think that it's not bad to have an alternative shaper like we have in context if only because a standard (like opentype) is no standard if there is only one (to be used) implementation.
""
It's also  important to have a shaper that behaves in the same way in windows/linux/mac without depends on too many external libs
-- at the ctx meeting in brejlov 2010   there was a talk by a dutch company about this.

--
luigi