Skip to content

Instantly share code, notes, and snippets.

@ccgus
Last active March 25, 2020 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccgus/9bddc5b273b0f5e3b014db93fe16630c to your computer and use it in GitHub Desktop.
Save ccgus/9bddc5b273b0f5e3b014db93fe16630c to your computer and use it in GitHub Desktop.
from AppKit import *
from Foundation import *
html = NSString.stringWithString_("<b style='font-size: 20px; font-family: HelveticaNeue'>Hi</b>")
d = html.dataUsingEncoding_(NSUTF8StringEncoding);
ats = NSAttributedString.alloc().initWithHTML_options_documentAttributes_(d, None, None)[0];
ps = ats.attribute_atIndex_effectiveRange_(NSParagraphStyleAttributeName, 0, None)[0]
print(ps.minimumLineHeight())
print(ps.maximumLineHeight())
@ccgus
Copy link
Author

ccgus commented Mar 25, 2020

On 10.15.3 you get:
25.0
0.0

On 10.15.4 you get:
0.0
0.0

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