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

A dirty solution to #891 #960

Closed
wants to merge 5 commits into from
Closed

A dirty solution to #891 #960

wants to merge 5 commits into from

Conversation

jackyyf
Copy link
Contributor

@jackyyf jackyyf commented Oct 14, 2014

Currently we have no good solution to handle embedded bitmap fonts (#891), so we should avoid using them, until a final patch is available.

  Since embedded bitmap font works incorrectly, we should avoid using
them, until a final patch is available and tested. I've added
`FT_LOAD_NO_BITMAP` to ALL(3) places in `_imagingft.c`, which did
(not much) actually fixed the issue. A notice has also been added to
`_imagingft.c`.
@jackyyf
Copy link
Contributor Author

jackyyf commented Oct 16, 2014

Any comment on this pull request? I do know it's dirty, but I think it's the best solution at this time :|

@wiredfool
Copy link
Member

I haven't had time to review -- the SSL bug has taken up too much of my time this week.

@wiredfool
Copy link
Member

Can you add a test case for this using a freely distributable font?

@jackyyf
Copy link
Contributor Author

jackyyf commented Oct 21, 2014

I'll try find one :)

Strangely, the bitmap version of DejaVu Sans is always vertical
one pixer longer.
StringIO does not exists on py3, which leads to failure of building.
@jackyyf
Copy link
Contributor Author

jackyyf commented Nov 7, 2014

Just a note that on my PC, test suite failed on my test(passed on travis), because of different font size between outline one and bitmap one (first one is exactly one pixel smaller than the second one), don't know why.

draw_bitmap.text((0, 0), text, fill=(0, 0, 0), font=font_bitmap)
draw_outline.text((0, 0), text, fill=(0, 0, 0), font=font_outline)
self.assert_image_similar(im_bitmap, im_outline, 0.01)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this at the bottom so the script is runnable as a standalone:

if __name__ == '__main__':
    unittest.main()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we still need it? I thought that this legacy code, because tests are run via nosetests Tests/test_imagefont_bitmap.py

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@homm Travis CI runs the tests using nosetests, but at least I find it useful when debugging just a single test locally (or creating/adding new tests). Sure, there's a nose command to run a single test, but it's much easier and transparent to be able to do python Tests/test_etc.py, and it's only an extra couple of lines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the contrary, it is much easier to run single tests with nose.

# Run test class:
$ nosetests -v Tests/test_image_transpose.py:TestImageTranspose
# Run individual test:
$ nosetests -v Tests/test_image_transpose.py:TestImageTranspose.test_rotate_270

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. When I said single test I meant a single file, and python Tests/test_etc.py is the standard way to run a Python script, and a useful basic, extra option to having to remember a nose command and its syntax, especially for new contributors who may never have seen nosetests before.

@jackyyf
Copy link
Contributor Author

jackyyf commented Jan 6, 2015

When will my pull request merged? I have to use custom hacked version of Pillow here and there in my own project :|

@aclark4life
Copy link
Member

@jackyyf You probably need @wiredfool or @hugovk to review

@hugovk
Copy link
Member

hugovk commented Jan 6, 2015

@jackyyf I'd like @wiredfool to check this.

In the meantime, you can pip install from your own branch, something like this:

pip install git+https://github.com/jackyyf/Pillow.git@bitmap-hack

@wiredfool
Copy link
Member

Sorry, I missed that you had added the font and the testcases. I'll take a look.

@wiredfool
Copy link
Member

Looking @ this on my Mavericks machine, the tests are failing due to different font metrics between the bitmap and truetype font.

On master, the test fails with AssertionError: average pixel value difference 152.1070 > epsilon 0.0100 , in this branch it fails with AssertionError: average pixel value difference 76.0391 > epsilon 0.0100 . Looking at the images that come out, it's just off by a pixel or so, offsetting the outline draw by 1 pixel gets the epsilon down to 10. This offset is what your original test had.

Looking on Ubuntu, the metrics and renderings pass the test as committed.

On linux, size_outline = size_bitmap = (212, 28), on the mac: size_outline = (212, 27) size_bitmap = (212, 28). So if we take that into account, and up the permissible error to something like 20, we should be able to easily distinguish between failures and successes.

I've put that together on my wiredfool:pr960 branch. Once the tests pass, I'll merge that.

@hugovk
Copy link
Member

hugovk commented Jan 8, 2015

#1072 merged.

Thanks!

@hugovk hugovk closed this Jan 8, 2015
@jackyyf jackyyf deleted the bitmap-hack branch January 8, 2015 13:34
@coveralls
Copy link

Coverage Status

Coverage increased (+11.3%) to 85.345% when pulling 36a8aba on jackyyf:bitmap-hack into ce09d40 on python-pillow:master.

@homm
Copy link
Member

homm commented May 18, 2016

Coverage increased (+11.3%) to 85.345%

Whoa!

@hugovk
Copy link
Member

hugovk commented May 18, 2016

A Coveralls glitch, unless Pillow has been replaced by two .js files without me noticing: https://coveralls.io/builds/6232236

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

Successfully merging this pull request may close these issues.

None yet

6 participants