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

Export #34

Open
1 task
davelab6 opened this issue Jun 14, 2016 · 17 comments
Open
1 task

Export #34

davelab6 opened this issue Jun 14, 2016 · 17 comments
Assignees

Comments

@davelab6
Copy link
Contributor

davelab6 commented Jun 14, 2016

  • The Number 3 feature is exporting a source-format font into a binary OTF (only)
@YashAgarwal
Copy link
Contributor

Having some errors with this
I've tried multiple ufo files but with some defcon doesn't show an error but ufo2ft does or vice versa

Error: defcon.errors.DefconError: the kerning data is not valid

Here is the code:
loading the font

 self.main_path = "ufo/sample.ufo"
 self.main_font = Font(self.main_path)        

the export function

def _write_ttf(self, button):
        ##NOT WORKING##
        ##Error: defcon.errors.DefconError: the kerning data is not valid##

        file_name = os.path.join(self.get_activity_root(), 'instance',
                                 '%s.ttf' % self.metadata['title'])

        #file_name = self.metadata['title'] + '.ttf' 

        ttf = compileTTF(self.main_font)
        ttf.save(file_name)

        jobject = datastore.create()
        jobject.metadata['icon-color'] = profile.get_color().to_string()
        jobject.metadata['mime_type'] = 'application/ttf'

        jobject.metadata['title'] = self.metadata['title']
        jobject.file_path = file_name

        # jobject.metadata['preview'] = \
        #    self._get_preview_image(file_name)

        datastore.write(jobject, transfer_ownership=True)
        self._object_id = jobject.object_id

        self._show_journal_alert(_('Success'),
                                 _('A TTF Font file was created in the Journal'))

@davelab6
Copy link
Contributor Author

    jobject.metadata['mime_type'] = 'application/ttf'

I suggest NOT doing TTFs, only OTFs.

@YashAgarwal
Copy link
Contributor

the commands are same for both of them, so its the same thing

On Thu, Jun 16, 2016 at 6:19 PM Dave Crossland [email protected]
wrote:

jobject.metadata['mime_type'] = 'application/ttf'

I suggest NOT doing TTFs, only OTFs.


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#34 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ACiNKsTfpi7IopjA1Gs4hd9HDmuQ4Hjjks5qMUZjgaJpZM4I1Q0f
.

@davelab6
Copy link
Contributor Author

Can you successfully export both kinds? :)

@YashAgarwal
Copy link
Contributor

Yes, I can
(but only outside sugar for now)
here is the code snippet for doing that

from ufo2ft import compileOTF, compileTTF
from defcon import Font

ufo = Font('abc.ufo')
otf = compileOTF(ufo)
ttf = compileTTF(ufo)
ttf.save('MyFont-Regular.ttf')
otf.save('MyFont-Regular.otf')

@davelab6
Copy link
Contributor Author

If the only problem is with kerning, then we can just ignore kerning for the 1.0 release

@davelab6
Copy link
Contributor Author

here is the code snippet for doing that

I recommend using fontmake itself; your example misses steps like

https://github.com/googlei18n/fontmake/blob/master/Lib/fontmake/font_project.py#L129-L135

@davelab6
Copy link
Contributor Author

davelab6 commented Jul 6, 2016

I believe the next step is to confirm this works in the upcoming .xo release

@davelab6 davelab6 assigned YashAgarwal and unassigned eliheuer and davelab6 Jul 30, 2016
@YashAgarwal
Copy link
Contributor

I'm getting the following error "can't find module compreffor" when using the module ufo2ft
this is the git repo for this module but I don't know how I should include this in my sugar activity as it requires a ./setup.py install

@YashAgarwal
Copy link
Contributor

YashAgarwal commented Aug 1, 2016

ah, I figured out how to add the compreffor module but now I'm getting an error in it

  File "/home/broot/sugar-build/activities/edit-fonts-activity/EditFonts.py", line 443, in _export_otf
    otf = compileOTF(globals.FONT)
  File "third_party/ufo2ft/__init__.py", line 31, in compileOTF
    otf = postProcessor.process(useProductionNames, optimizeCff)
  File "third_party/ufo2ft/otfPostProcessor.py", line 25, in process
    comp.compress()
  File "third_party/compreffor/__init__.py", line 115, in compress
    self.run_executable()
  File "third_party/compreffor/__init__.py", line 135, in run_executable
    cxxCompressor.compreff(self.font, use_lib=False, **self.options)
  File "third_party/compreffor/cxxCompressor.py", line 248, in compreff
    subrs, glyph_encodings = read_data(td, results)
  File "third_party/compreffor/cxxCompressor.py", line 127, in read_data
    num_subrs = struct.unpack_from('<I', results[:4])[0]
struct.error: unpack_from requires a buffer of at least 4 bytes

@davelab6
Copy link
Contributor Author

davelab6 commented Aug 1, 2016

I suggest reporting the bug upstream

@YashAgarwal
Copy link
Contributor

YashAgarwal commented Aug 3, 2016

the previous error was due to the ufo2ft module
Now I'm trying to use fontmake, It works fine on my system but in sugar it requires a dependency which I don't know how to add
this is the error I'm getting

bash-4.2$ python -m fontmake -u ../test_fonts/sample.ufo
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/broot/sugar-build/activities/edit-fonts-activity/third_party/fontmake/__main__.py", line 17, in <module>
    from fontmake.font_project import FontProject
  File "fontmake/font_project.py", line 25, in <module>
    from booleanOperations import BooleanOperationManager
  File "booleanOperations/__init__.py", line 2, in <module>
    from .booleanOperationManager import BooleanOperationManager
  File "booleanOperations/booleanOperationManager.py", line 3, in <module>
    from . import pyClipper
ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by booleanOperations/pyClipper.so)

@YashAgarwal
Copy link
Contributor

Can anyone help with the above error?

@davelab6
Copy link
Contributor Author

davelab6 commented Aug 7, 2016

The problem is that the booleanOperations/pyClipper.so is compiled and linked against a different copy of the C runtime /lib64/libstdc++.so.6

You can try installing the https://pypi.python.org/pypi/pyclipper package and using that instead of the .so file included in the git repo

@YashAgarwal
Copy link
Contributor

yesterday in IM @davelab6 suggested to use the selective functions out of FontProject to avoid pyclipper by avoiding booleanOperations completely
but on running

import fontmake.font_project import FontProject

in a python interpreter in the terminal activity inside sugar importing booleanOperation can not be avoided and hence we get the same GLIBXX not found error

If I comment out the booleanOperations import statement in the font_project still there are other modules like compreffor which require the same GLIBXX and hence we get the same error

I think if we can somehow add the fontmake's setup.py file to the activities setup.py so that it is compiled with the activity itself

@YashAgarwal
Copy link
Contributor

YashAgarwal commented Aug 18, 2016

@walterbender can you have a look at this
running

import fontmake.font_project import FontProject

still gives the error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "fontmake/font_project.py", line 25, in <module>
    from booleanOperations import BooleanOperationManager
  File "booleanOperations/__init__.py", line 2, in <module>
    from .booleanOperationManager import BooleanOperationManager
  File "booleanOperations/booleanOperationManager.py", line 3, in <module>
    from . import pyClipper
ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by booleanOperations/pyClipper.so)

I've tried copying the way using in the Physics activity but that doesn't even get called because here the booleanOperations/booleanOperationManager.py file directly includes the pyClipper.so

then I tried importing the ``libstdc++.so` file before importing fontmake,

from ctypes import cdll
from sys import path
path.insert(0, 'third_party/pyclipper/pyclipper_64')
libstdc = cdll.LoadLibrary("third_party/pyclipper/pyclipper_64/libstdc++.so")
libstdc = cdll.LoadLibrary("third_party/pyclipper/pyclipper_64/libstdc++.so.6")

but then I get the error on this line

libstdc = cdll.LoadLibrary("third_party/pyclipper/pyclipper_64/libstdc++.so")

saying(roughly)

OSError: File or directory doesn't exist      

but I can see the file in the directory mentioned

PS: all this was tried in a sugar dev env on my 64bit Ubuntu 16.04 using the terminal activity

@davelab6
Copy link
Contributor Author

@YashAgarwal I suggest looking again at avoiding booleanOperations. With only a few days left, I would prefer to have a .xo that can export fonts with overlaps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants