typemytype / drawbot

http://www.drawbot.com
Other
391 stars 61 forks source link

Formattedstring Strikethrough Attribute #537

Open connordavenport opened 11 months ago

connordavenport commented 11 months ago

Hey! Is it possible to add support for strikethrough in text? I was doing some googling and it came across this, not sure if its useful.

typemytype commented 11 months ago

this seems to work on Ventura.

will test on older macOS, as I remember this didnt worked like the article, you linked, mentioned.

import AppKit

f = FormattedString()

f.font("Times", 200)
f.underline("single")
f += "hello"

attributes = {
    AppKit.NSFontAttributeName : AppKit.NSFont.systemFontOfSize_(96),
    AppKit.NSForegroundColorAttributeName : AppKit.NSColor.blueColor(),
    AppKit.NSStrikethroughStyleAttributeName : AppKit.NSUnderlineStyleThick
}

txt = AppKit.NSAttributedString.alloc().initWithString_attributes_("striked", attributes)
f._attributedString.appendAttributedString_(txt)

print(f)
f += "foo"

text(f, (100, 100))
connordavenport commented 11 months ago

Hey @typemytype ! Oh this is awesome!, thanks I will finally update to Ventura and test it soon:) I can confirm that it is not working on 11.4 Big Sur

typemytype commented 11 months ago

looks like this on Ventura:

image
justvanrossum commented 11 months ago

Looks like this on 10.15:

image

At least it doesn't crash :)