Custom views with bold text and rounded corners
peiriannydd last edited by
Yes, thank you, this solved my problems, although using a label since <system-bold> doesn’t work with ui.draw_string seems like a bug workaround.
seems like a bug workaround.
Sure, but what else to do if the app is no more updated?
cvp last edited by
@peiriannydd other workaround
f = '<System>' ui.draw_string(self.text,(0,0,self.width,self.height), (f,20), 'black',ui.ALIGN_CENTER) ui.draw_string(self.text,(1,1,self.width-1,self.height-1), (f,20), 'black',ui.ALIGN_CENTER)
JonB last edited by
So, a way that should work would be to use UIFont to find the system font name, and then create a bold version, then find the name of that... Just an idea, have not pursued it yet
@JonB I did try:
<UICTFont: 0x103990c70> font-family: ".SFUI-Semibold"; font-weight: bold; font-style: normal; font-size: 20.00pt
JonB last edited by JonB
Also-- the "Text" part of the name can be replaced with Rounded, or Display. Apparently Text is supposed to used under 19pt, Display for 20pt+. I'm not sure what Rounded is for -- looks a little more informal.
I think apple tried to obfuscate system font names so people used their new API in iOS13, to prevent people hard coding fonts that might change later. Hence reason that .SFUI doesnt work
I assume draw_string is using UIFont.fontWithName_size_
JonB last edited by
I think compact is for watchOS, Pro for iOS.
Does UIFont have a .fontName() method?
@JonB neither ".SFProText-Bold" nor ".SFProDisplay-Bold" do work
I ask me if for SF standard system font, bold in name does work without a supplementary bold attribute
does UIFont have a .fontName() method?
@peiriannydd this works, in place of ui.draw_string
UIFont = ObjCClass('UIFont').boldSystemFontOfSize_(20.0) attrtext = ObjCClass('NSMutableAttributedString').alloc().initWithString_(ns(self.text)) attrtext.addAttribute_value_range_(ns('NSFont'), UIFont, NSRange(0,len(self.text))) attrtext.drawInRect_(CGRect(CGPoint(0, 0), CGSize(self.width, self.height)))
from objc_util import *