compreffor icon indicating copy to clipboard operation
compreffor copied to clipboard

Better C interface

Open be5invis opened this issue 8 years ago • 8 comments

The current C interface lacks some import parts, we still need Python to deal with it.

be5invis avatar Aug 28 '16 14:08 be5invis

If you mean the parts decoding SFNT and CFF table, then that's a lot of code; there's not much point reimplementing that in this module. Maybe FreeType allows loading those?

behdad avatar Sep 02 '16 16:09 behdad

@behdad I just care about the subroutinizer algorithm. I have already a decoder and an encoder, all parts (like - the charstring INDEX) are avaliable. There is even an IL for charstrings.

be5invis avatar Sep 02 '16 20:09 be5invis

I haven't looked at the code in a long time. Can you summarize what changes you like to see?

behdad avatar Sep 02 '16 22:09 behdad

@behdad A simple interface, pretty like the existing

extern "C" uint32_t* compreff(unsigned char* dataStream, int numRounds, unsigned& outputLength);

However, instead of returning a “result” which is needed to decode, provide a more “direct” output like this:

typedef struct {
    uint32_t length;
    uint8_t  data;
} CFFIndex;

typedef struct {
    CFFIndex *charStrings;
    CFFIndex *globalSubroutines;
    uint32_t NumOfLocalSubroutines;
    CFFIndex **localSubroutines;
} ComprefforResult;

extern "C" ComprefforResult *compreff(const CFFIndex *inputCharStrings, const whatever *fdSelect, uint32_t fdCount, uint32_t rounds);

In the returned result->charStrings, all duplicate instructions are replaced with calls.

be5invis avatar Sep 02 '16 22:09 be5invis

I see. Yes, I think we can do something like that.

behdad avatar Sep 02 '16 22:09 behdad

@behdad I’d like your C interface’s input and output plain enough. That is, can be used directly when building a CFF font. And prehaps, you can drop the fdSelect part, and use one unified local subroutine table for ALL subfonts in a CID FDArray. In my case, all input charstrings do not contain any subroutine call.

be5invis avatar Sep 02 '16 22:09 be5invis

And prehaps, you can drop the fdSelect part, and use one unified local subroutine table for ALL subfonts in a CID FDArray. In my case, all input charstrings do not contain any subroutine call.

Sure that's possible but comes at a theoretical cost. Not important for most fonts though, I agree.

behdad avatar Sep 02 '16 22:09 behdad

@behdad I think that trade-off is acceptable.

be5invis avatar Sep 03 '16 15:09 be5invis