Closed madig closed 5 years ago
:white_check_mark: Build freetype-py 1.0.114 completed (commit https://github.com/rougier/freetype-py/commit/e23a551703 by @madig)
Bah. Can't get attaching bytes to work because FT_Open_Args
-> memory_base
expects c_ubyte
when it should be POINTER(c_ubyte)
, which also doesn't work. Did this ever work?
from the CI failures, I think you need to update the multibuild submodule
:white_check_mark: Build freetype-py 1.0.115 completed (commit https://github.com/rougier/freetype-py/commit/d301b4d0b1 by @madig)
I lost patience with attach_file
, no idea what the problem is. Maybe in another PR.
Edit: I have this code:
def attach_file( self, path_or_stream ):
if hasattr(path_or_stream, "read"):
error = self._attach_memory(path_or_stream.read())
else:
try:
u_filename = c_char_p(_encode_filename(path_or_stream))
error = FT_Attach_File(self._FT_Face, u_filename)
except UnicodeError:
with open(path_or_stream, mode="rb") as f:
filebody = f.read()
error = self._attach_memory(filebody)
if error:
raise FT_Exception(error)
def _attach_memory(self, byte_stream):
parameters = FT_Open_Args()
parameters.flags = FT_OPEN_MEMORY
parameters.memory_base = POINTER(FT_Byte)(byte_stream)
parameters.memory_size = len(byte_stream)
parameters.stream = None
error = FT_Attach_Stream(self._FT_Face, parameters)
if error:
raise FT_Exception(error)
self._filebodys.append(byte_stream) # prevent gc
return error
This errors with "Invalid argument". Meh.
:white_check_mark: Build freetype-py 1.0.116 completed (commit https://github.com/rougier/freetype-py/commit/eb4a387387 by @madig)
@rougier Please have a look. Can merge and tag if you give your ok. Do you know what Face::_filename
is used for?
@madig what Face::_filename
are you referring to exactly?
https://github.com/rougier/freetype-py/pull/106/files#diff-c981959bb975a2ca7046d119aeb25b02L990
I removed it in this PR, but maybe you know what it's used for?
I can imagine the idea was to keep the reference to the filename but I'm not sure it is actually used elsewhere.
I couldn't find a reference to it in the code 🤔 I can leave it in if it's unclear, but only assign when I think a path is passed in?
Well, if it is not used, maybe it's better to remove it completely.
I like your attitude. So! Anything else to do here?
Nope. Let's pull the trigger.
The fourth PR to tackle loading a font from memory instead of from disk.
file_or_stream
argument for being abytes
object won't work, accept aio.BytesIO
object instead.from_file
class method. It would make more sense whenFace::__init__
is refactored to not have any logic and just stores what it's given.Not sure what to do about
Face::_filename
. it doesn't seem to be used anywhere.Working on
attach_file
, I need a test case.Closes https://github.com/rougier/freetype-py/pull/33, https://github.com/rougier/freetype-py/pull/103, https://github.com/rougier/freetype-py/pull/104