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

FreeType FT_DivFix() wrong result #4262

Closed
metafloor opened this issue Apr 20, 2016 · 13 comments
Closed

FreeType FT_DivFix() wrong result #4262

metafloor opened this issue Apr 20, 2016 · 13 comments
Labels

Comments

@metafloor
Copy link

I have successfully compiled freetype in the past with older versions of freetype and emscripten. Upgraded to the latest version of each. Compiles without issue but I am getting a nonsense math result from within freetype.

Here is the problem code (freetype-2.6.3/src/cff/cf2ft.c line 73):

    printf("unitsPerEm=%d, CF2_MAX_SIZE=%d\n", unitsPerEm, CF2_MAX_SIZE);
    printf("cf2_intToFixed=%d\n", cf2_intToFixed(unitsPerEm));

    maxScale = FT_DivFix( CF2_MAX_SIZE, cf2_intToFixed( unitsPerEm ) );

    printf("maxScale=%d\n", maxScale);

The output from the printf()s show:

    unitsPerEm=1000, CF2_MAX_SIZE=131072000
    cf2_intToFixed=65536000
    maxScale=0

The result of FT_DivFix(a,b) should be: a * 0x10000 / b, which for the given values is 131072.

I have tried compiling with different levels of optimization with no luck.

Platform: 4.2.0-16-generic #19-Ubuntu SMP x86_64

Thanks!

@kripken
Copy link
Member

kripken commented Apr 21, 2016

Can you add this to the freetype test in tests/test_core.py? That way it is easy for us to reproduce, and also we'll have a test for after we fix things.

@metafloor
Copy link
Author

One problem is the test suite is running against freetype 2.4.4

I have verified that freetype 2.4.4 compiles and works correctly with the latest emscripten on linux x64.

freetype 2.5+ compiles but fails to render any character because FT_DivFix() always returns 0. I don't think a new test case is needed; just upgrade freetype to current 2.6.3 and the existing test case should fail.

@kripken
Copy link
Member

kripken commented May 9, 2016

Ok, I see. If you or someone else wants to make a PR with an update of freetype, that sounds like the next step here, and then we can debug on that PR.

@kripken
Copy link
Member

kripken commented May 9, 2016

Another option might be to make the test suite use freetype from ports, as the version there looks like 2.6. The PR could remove freetype in the emscripten repo, and use the ports one instead. Should be examples of using zlib from ports in the test suite.

@kripken
Copy link
Member

kripken commented May 9, 2016

Btw, were you trying on ports? It might have fixes that are necessary.

@maxabrams
Copy link

This bug persists with current versions of both. Results in CFF fonts being unusable.

@kripken
Copy link
Member

kripken commented Jun 28, 2016

Ok, then the next steps sounds like what was suggested a few comments back: a PR that moves the test suite to use freetype from ports, and shows the bug clearly.

@maxabrams
Copy link

maxabrams commented Jun 28, 2016

Edited to below --

More details can be found from Metafloor's wiki: https://github.com/metafloor/bwip-js/wiki/Compiling-FreeType

@kripken
Copy link
Member

kripken commented Jun 28, 2016

No special access is needed to make a PR. You need a fork of this repo, to create a branch there, and to open a PR for that in this repo.

@maxabrams
Copy link

maxabrams commented Jun 28, 2016

PR created #4419

@maxabrams
Copy link

Additional information: http://savannah.nongnu.org/bugs/?48309

Seems to be coming from 64 bit division

@kripken
Copy link
Member

kripken commented Jun 28, 2016

If it's indeed a 64-bit division issue, then we should create a standalone testcase of just that FT_DivFix method, being run on the input that it gets wrong.

@stale
Copy link

stale bot commented Aug 30, 2019

This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Aug 30, 2019
@stale stale bot closed this as completed Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants