Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Custom views with bold text and rounded corners
-
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.
-
@peiriannydd Said
seems like a bug workaround.
Sure, but what else to do if the app is no more updated?
-
@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)
-
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
-
Try
".SFCompactText-Bold"
Or
".SFProText-Bold"
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_
-
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
-
-
@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)))
Nb: needs
from objc_util import *