harfbuzz / uharfbuzz

A HarfBuzz Python binding
Apache License 2.0
68 stars 25 forks source link

Add hb_font.create_sub_font(font) #139

Closed behdad closed 2 years ago

behdad commented 2 years ago

Untested.

behdad commented 2 years ago

PTAL.

anthrotype commented 2 years ago

it would be good to confirm that it actually works as intended with a little test in https://github.com/harfbuzz/uharfbuzz/blob/main/tests/test_uharfbuzz.py

even as simple as loading a font, creating the sub font from it, then asserting that the returned value is actually a Font and that its id() is different (font2 is not font) even though the Face the two fonts refer to is the same (e.g. font2.face == font.face)

behdad commented 2 years ago

it would be good to confirm that it actually works as intended with a little test in https://github.com/harfbuzz/uharfbuzz/blob/main/tests/test_uharfbuzz.py

even as simple as loading a font, creating the sub font from it, then asserting that the returned value is actually a Font and that its id() is different (font2 is not font) even though the Face the two fonts refer to is the same (e.g. font2.face == font.face)

Thanks. Done. It fails. I don't know pyx enough to know what I'm doing wrong...

behdad commented 2 years ago

Looks like calling __new__ still calls __cinit__ after. Is that expected?

behdad commented 2 years ago

I suppose we can make the regular constructor create a subfont if it's passed a Font instead of a Face, instead of new API.

anthrotype commented 2 years ago

I'll take a look tomorrow

behdad commented 2 years ago

I managed to move it to constructor and have tests pass.