Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better C interface #20

Open
be5invis opened this issue Aug 28, 2016 · 8 comments
Open

Better C interface #20

be5invis opened this issue Aug 28, 2016 · 8 comments

Comments

@be5invis
Copy link

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

@behdad
Copy link
Contributor

behdad commented Sep 2, 2016

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?

@be5invis
Copy link
Author

be5invis commented Sep 2, 2016

@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.

@behdad
Copy link
Contributor

behdad commented Sep 2, 2016

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

@be5invis
Copy link
Author

be5invis commented Sep 2, 2016

@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.

@behdad
Copy link
Contributor

behdad commented Sep 2, 2016

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

@be5invis
Copy link
Author

be5invis commented Sep 2, 2016

@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.

@behdad
Copy link
Contributor

behdad commented Sep 2, 2016

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.

@be5invis
Copy link
Author

be5invis commented Sep 3, 2016

@behdad I think that trade-off is acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants