Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rougier/freetype-py
Browse files Browse the repository at this point in the history
* 'master' of github.com:rougier/freetype-py:
  Depends on libfreetype6... duh
  Fix some Lintian issues
  py2dsc freetype-py-0.4.1.tar.gz
  Fallback to memory API when failed to deocde filename
  Encode filename to filesystem encoding
  Add long_description in setup
  Set classifiers to indicate this project supoorts both Python 2 and 3
  Fix warnings during installation
  • Loading branch information
rougier committed Oct 1, 2014
2 parents c8ff5aa + ecf9c89 commit 001a610
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 7 deletions.
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Distributed under the terms of the new BSD license.
#
# -----------------------------------------------------------------------------
include examples/*.py
recursive-include examples *
include MANIFEST.in
include LICENSE.txt
include README.txt
include README.rst
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
freetype-py (0.4.1-1) unstable; urgency=low

* source package automatically created by stdeb 0.8.2

-- Olivier Mehani <[email protected]> Mon, 29 Sep 2014 21:37:23 +1000
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
16 changes: 16 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Source: freetype-py
Maintainer: Nicolas P. Rougier <[email protected]>
Section: python
Priority: optional
Build-Depends: python-all (>= 2.6.6-3), debhelper (>= 9)
Standards-Version: 3.9.5

Package: python-freetype-py
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}, libfreetype6
Description: Freetype python bindings
Freetype python provides bindings for the FreeType library. Only the
high-level API is bound.
.
Documentation available at:
http://freetype-py.readthedocs.org/en/latest/
59 changes: 59 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: freetype-py
Source: https://github.com/rougier/freetype-py

Files: *
Copyright: 2011-2014 Nicolas P. Rougier <[email protected]>
License: BSD
freetype-py is licensed under the terms of the new or revised BSD
license, as follows:
.
Copyright (c) 2011-2014, Nicolas P. Rougier All rights reserved.
.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
.
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
.
Neither the name of the freetype-py Development Team nor the names
of its contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Files: debian/*
Copyright: 2014 Olivier Mehani <[email protected]>
License: GPL-2+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
2 changes: 2 additions & 0 deletions debian/python-freetype-py.lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
new-package-should-close-itp-bug
invalid-short-name-in-dep5-copyright
8 changes: 8 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/make -f

# This file was automatically generated by stdeb 0.8.2 at
# Mon, 29 Sep 2014 21:37:23 +1000
export PYBUILD_NAME=freetype-py
%:
dh $@ --with python2 --buildsystem=pybuild

1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
35 changes: 32 additions & 3 deletions freetype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ def set_lcd_filter_weights(a,b,c,d,e):
'set_lcd_filter_weights require freetype > 2.4.0')


def _encode_filename(filename):
encoded = filename.encode(sys.getfilesystemencoding())
if "?" not in filename and b"?" in encoded:
# A bug, decoding mbcs always ignore exception, still isn't fixed in Python 2,
# view http://bugs.python.org/issue850997 for detail
raise UnicodeError()
return encoded



# -----------------------------------------------------------------------------
# Direct wrapper (simple renaming)
Expand Down Expand Up @@ -1045,8 +1054,16 @@ def __init__( self, filename, index = 0 ):
face = FT_Face( )
self._FT_Face = None
#error = FT_New_Face( library, filename, 0, byref(face) )
u_filename = c_char_p(filename.encode())
error = FT_New_Face( library, u_filename, index, byref(face) )
self._filebodys = []
try:
u_filename = c_char_p(_encode_filename(filename))
error = FT_New_Face( library, u_filename, index, byref(face) )
except UnicodeError:
with open(filename, mode='rb') as f:
filebody = f.read()
error = FT_New_Memory_Face( library, filebody, len(filebody),
index, byref(face) )
self._filebodys.append(filebody) # prevent gc
if error: raise FT_Exception( error )
self._filename = filename
self._index = index
Expand Down Expand Up @@ -1080,7 +1097,19 @@ def attach_file( self, filename ):
attachments.
'''

error = FT_Attach_File( self._FT_Face, filename)
try:
u_filename = c_char_p(_encode_filename(filename))
error = FT_Attach_File( self._FT_Face, u_filename )
except UnicodeError:
with open(filename, mode='rb') as f:
filebody = f.read()
parameters = FT_Open_Args()
parameters.flags = FT_OPEN_MEMORY
parameters.memory_base = filebody
parameters.memory_size = len(filebody)
parameters.stream = None
error = FT_Attach_Stream( self._FT_Face, parameters )
self._filebodys.append(filebody) # prevent gc
if error: raise FT_Exception( error)


Expand Down
11 changes: 9 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@
# Distributed under the terms of the new BSD license.
# -----------------------------------------------------------------------------
from distutils.core import setup
from os import path
from codecs import open

here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()

setup( name = 'freetype-py',
version = '0.4.2',
description = 'Freetype python bindings',
long_description = long_description,
author = 'Nicolas P. Rougier',
author_email= '[email protected]',
url = 'https://github.com/rougier/freetype-py',
packages = ['freetype', 'freetype.ft_enums'],
data_files = ['examples/Vera.ttf',],
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: X11 Applications',
Expand All @@ -23,7 +29,8 @@
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Multimedia :: Graphics',
],
)

0 comments on commit 001a610

Please sign in to comment.