Giter Club home page Giter Club logo

Comments (11)

adrientetar avatar adrientetar commented on July 18, 2024

It seems I also need to keep a reference to the Face object when calling hb.Face.create_for_tables(..) otherwise I get OSError: exception: privileged instruction when calling hb_shape.

from harfpy.

adrientetar avatar adrientetar commented on July 18, 2024

Still get some access violations after that..

Traceback (most recent call last):
  File "c:\users\admin\downloads\trufont\lib\trufont\controls\glyphCanvasView.py", line 342, in keyPressEvent
    self._redirectEvent(event, self._currentTool.keyPressEvent)
  File "c:\users\admin\downloads\trufont\lib\trufont\controls\glyphCanvasView.py", line 465, in _redirectEvent
    callback(event)
  File "c:\users\admin\downloads\trufont\lib\trufont\drawingTools\textTool.py", line 123, in keyPressEvent
    self.layoutLine.insert(text)
  File "c:\users\admin\downloads\trufont\lib\trufont\objects\layoutLine.py", line 100, in insert
    self.updateView()
  File "c:\users\admin\downloads\trufont\lib\trufont\objects\layoutLine.py", line 170, in updateView
    self._shapeAndSetText()
  File "c:\users\admin\downloads\trufont\lib\trufont\objects\layoutLine.py", line 149, in _shapeAndSetText
    records = self.engine.process(names)
  File "c:\users\admin\downloads\trufont\lib\trufont\objects\layoutEngine.py", line 256, in process
    hb.shape(self._hbFont, buf, list(self._fontFeatures.values()))
  File "c:\users\admin\downloads\harfpy\harfbuzz.py", line 4194, in shape
    hb.hb_shape(font._hbobj, buffer._hbobj, c_features, nr_features)
OSError: exception: access violation reading 0xBEE7AE64

cc @khaledhosny

from harfpy.

adrientetar avatar adrientetar commented on July 18, 2024

Ah, apparently storing a reference to the hb.FontFuncs I use fixes the last access violation.

from harfpy.

ldo avatar ldo commented on July 18, 2024

In other words, a Font object needs to keep a reference to the parent Face?

from harfpy.

adrientetar avatar adrientetar commented on July 18, 2024

I think so in the create_for_tables case which is similar to create_for_array (a reference to the data source should be kept). It can be left to the user, but in that case it should probably be documented.

from harfpy.

khaledhosny avatar khaledhosny commented on July 18, 2024

hb_font_t keeps a reference of its hb_face_t, so I think the Python objects should do something similar.

from harfpy.

adrientetar avatar adrientetar commented on July 18, 2024

sgtm. The Font.face method would then return the cached Face object, this would keep the source data alive.

from harfpy.

ldo avatar ldo commented on July 18, 2024

OK, I have done this in 99b3562. See if it fixes the problem.

from harfpy.

adrientetar avatar adrientetar commented on July 18, 2024

Thanks. I think the same should be done for FontFuncs, a reference to it should be stored when Font.set_funcs is called.

About my question in the first post, would you know how to use the hb.Blob.create rather than create for array? (see first post)

from harfpy.

ldo avatar ldo commented on July 18, 2024

There is a subtlety to getting the memory address for bytes and bytearray objects. Blob.create_for_array can now accept these as of 5a887d5 (copying the same code I used in Qahirah, thanks to a tip from Eryk Sun). You can just use that, or you can look at the code to figure out how to do it with Blob.create for yourself.

from harfpy.

ldo avatar ldo commented on July 18, 2024

Font.font_funcs and Buffer.unicode_funcs now have associated references saved to prevent premature disposal as of e5c5fe0.

from harfpy.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.