googlefonts / cu2qu

Cubic-to-quadratic bezier curve conversion
Apache License 2.0
64 stars 21 forks source link

module 'cu2qu' has no attribute 'ufo' #180

Closed laerm0 closed 5 years ago

laerm0 commented 5 years ago

Hello –

I was trying to use this on my Open Sans work but it looks like the skeleton of a script provided is incorrect. @felipesanches was helping me with the script and it looks like that the module isn't as documented in the readme.

My script:

from defcon import Font
import cu2qu
import ipdb; ipdb.set_trace()

light_font = Font('source/Open Sans-Light.ufo')
bold_font = Font('source/Open Sans-Bold.ufo')
extrabold_font = Font('source/Open Sans-ExtraBold.ufo')
lightcond_font = Font('source/Open Sans-Light Condensed.ufo')
boldcond_font = Font('source/Open Sans-Bold Condensed.ufo')
extraboldcond_font = Font('source/Open Sans-ExtraBold Condensed.ufo')

cu2qu.ufo.fonts_to_quadratic([light_font, bold_font, extrabold_font, lightcond_font, boldcond_font, extraboldcond_font])

running in ipdb:

screenshot_2019-04-11_23-11-59
anthrotype commented 5 years ago

Yes, like the error said. You should import like this:

from cu2qu.ufo import fonts_to_quadratic

or if you like the fully qualified import:

import cu2qu.ufo

Then you use it like:

cu2qu.ufo.fonts_to_quadratic

BTW, why don’t you just use the cu2qu console script?

laerm0 commented 5 years ago

I changed my script to read:

from defcon import Font
from cu2qu.ufo import fonts_to_quadratic

# import ipdb; ipdb.set_trace()

light_font = Font('source/Open Sans-Light.ufo')
bold_font = Font('source/Open Sans-Bold.ufo')
extrabold_font = Font('source/Open Sans-ExtraBold.ufo')
lightcond_font = Font('source/Open Sans-Light Condensed.ufo')
boldcond_font = Font('source/Open Sans-Bold Condensed.ufo')
extraboldcond_font = Font('source/Open Sans-ExtraBold Condensed.ufo')

cu2qu.ufo.fonts_to_quadratic([light_font, bold_font, extrabold_font, lightcond_font, boldcond_font, extraboldcond_font])

Same error: NameError: name 'cu2qu' is not defined

screenshot_2019-04-12_01-04-38

BTW, why don’t you just use the cu2qu console script?

I didn't know there was one. There's nothing about it in the readme.

anthrotype commented 5 years ago

if you did from cu2qu.ufo import fonts_to_quadratic, then you call the function as fonts_to_quadratic, without cu2qu.ufo in front.

I didn't know there was one.

I believe I did mention it in our private email conversation.

There's nothing about it in the readme.

Fair enough :) We should add a reference to that in the README.md

anthrotype commented 5 years ago

I updated README https://github.com/googlei18n/cu2qu/commit/e8e8ddebb4ef8e15d8e14ab820883f1d619aa4c2

laerm0 commented 5 years ago

Ahhhh, I see now. Sorry I missed that in the email thread. Thanks very much, I am good now. Sorry to bug you. :)

anthrotype commented 5 years ago

Np, feel free to "debug" me :)