compreffor
compreffor copied to clipboard
Better C interface
The current C interface lacks some import parts, we still need Python to deal with it.
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 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.
I haven't looked at the code in a long time. Can you summarize what changes you like to see?
@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.
I see. Yes, I think we can do something like that.
@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.
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 I think that trade-off is acceptable.