@omz @Webmaster4o Well done, works for me too.
@JonB Thank you, I extended the functions based on your answer. If you find something about 1/3 screen console, please let me know.
# coding: utf-8
import ui
import objc_util
def getDefaultConsoleFont():
defaults=objc_util.ObjCClass('NSUserDefaults').standardUserDefaults()
return (str(defaults.stringForKey_('OutputFontName')),\
defaults.integerForKey_('OutputFontSize'))
def getCurrentConsoleFont():
app=objc_util.ObjCClass('UIApplication').sharedApplication()
cv=app.delegate().consoleViewController()
cv.view()
font=cv.outputFont()
font_family=str(font.familyNameForCSSFontFamilyValue())
#font_family2=str(font.familyName())
font_size=font.pointSize()
char_width=font.advancementForGlyph_(68).width
line_height=font.lineHeight()
return (font_family, font_size), char_width, line_height
def getConsoleCharWidth():
font,charWidth,lineHeight=getCurrentConsoleFont()
screenWidth=ui.get_screen_size().width
#charWidth=ui.measure_string('.',font=font).width
return int(screenWidth / charWidth-1.5)
if __name__ == '__main__':
ccwidth=getConsoleCharWidth()
currentFont,_,_=getCurrentConsoleFont()
defaultFont=getDefaultConsoleFont()
print('currentConsoleFont='+str(currentFont))
print('defaultConsoleFont='+str(defaultFont))
print('consoleCharWidth = '+str(ccwidth))
print('='*ccwidth)
Sorry for copy paste, it's a bit long.