Skip to content

Force larger font size? #58

@VaporwareII

Description

@VaporwareII

I've been playing with longer and shorter text blocks, but the font seems to skew small in expectation of a longer word or sentence. I was trying to create a square with a single character to see how large it would become and it was surprisingly small. The textblock should be 120ish pixels square, and I requested a crazy 300 pt font size with no padding.

IMG-2561

# import from epdlib
from epdlib import Screen
from epdlib import Layout
#from epdlib import Block
from epdlib import constants

import logging
from time import sleep

# obnoxious levels of debugging output that might help you diagnose problems
logging.root.setLevel('DEBUG')

# create screen and layout objects
my_screen = Screen(epd='epd2in13_V3')
my_layout = Layout(resolution=my_screen.resolution)

# define a layout with a single text block
layout = {
             'Troop1': {
                'type': 'TextBlock',    
                'image': None,
                #'max_lines': 1,
                #'maxchar': 1,
                'width': 1/2,
                'height': 1,
                'padding': 0,
                'abs_coordinates': (0, 0),   # X = 0, Y will be calculated
                'relative': False,           # this block is not relative to any other. It has an ABSOLUTE position (0, 0)
                #'hcenter': True,
                #'vcenter': True,
                'font': str(constants.absolute_path/'../fonts/Font.ttc'),             
                'font_size': 300,            # Calculate the font size because none was provided
                #'text_wrap': True,
                'fill': 'White',
                'bkground': 'Black'
            }
}
# assign the layout definition to the layout property of the Layout() object
my_layout.layout = layout

# tell the layout what to put in the 'title' block
my_layout.update_contents({'Troop1': '5'})

# concatenate all the images in the layout into a single large image (PIL.paste for those keeping score)
# and write it to the EPD
my_screen.writeEPD(my_layout.concat())
print('sleeping for 10 seconds')
sleep(10)
my_screen.clearEPD()

%Run helloworld.py
DEBUG:root:configuring waveshare_epd.epd2in13_V3
DEBUG:root:Clear() function has color parameter
DEBUG:root:args_spec: ['self', 'image']
DEBUG:root:epd configuration {'epd': <waveshare_epd.epd2in13_V3.EPD object at 0x7f87c65580>, 'resolution': [250, 122], 'clear_args': {}, 'one_bit_display': True, 'constants': None, 'mode': '1'}
DEBUG:root:rotation=0, resolution=[250, 122]
DEBUG:root:mirror output: False
DEBUG:root:[[----checking default values for layout----]
DEBUG:root:section: [------------Troop1------------]
DEBUG:root:adding "max_lines: 1"
DEBUG:root:adding "maxchar: None"
DEBUG:root:adding "dimensions: None"
DEBUG:root:[[....calculating layouts....]]
INFO:root:section: [............Troop1............]
DEBUG:root:resolution: [250, 122]
DEBUG:root:width: 0.5, height: 1
DEBUG:root:absolute coordinates provided
DEBUG:root:block coordinates: (0, 0)
DEBUG:root:layout config: resolution, [250, 122], force_onebit: False, mode: 1
INFO:root:[[____SETTING SECTION BLOCKS____]]
INFO:root:setting section: [____________Troop1____________]
DEBUG:root:scaling font size
DEBUG:root:x target size reached
DEBUG:root:calculated font size: 34
DEBUG:root:setting block type: TextBlock
DEBUG:root:set bkground: Black
INFO:root:using WaveShare color: Black
DEBUG:root:converting "(0, 0, 0)" to mode: 1
DEBUG:root:using 0
DEBUG:root:checking fill and background color
DEBUG:root:converting "None" to mode: 1
DEBUG:root:using 0
DEBUG:root:border config: {'fill': 0}
DEBUG:root:converting "0" to mode: 1
DEBUG:root:using 0
DEBUG:root:border config: {'fill': 0, 'width': 0}
DEBUG:root:set fill: White
INFO:root:using WaveShare color: White
DEBUG:root:converting "(255, 255, 255)" to mode: 1
DEBUG:root:using 255
DEBUG:root:checking fill and background color
DEBUG:root:block area: (125, 122)
DEBUG:root:padded area: [125, 122]
DEBUG:root:creating Block
DEBUG:root:resetting font to match size 34
DEBUG:root:calculating maximum characters for font ('WenQuanYi Micro Hei', 'Regular') at size 34
DEBUG:root:calculated average character width: 18.665995975855132
DEBUG:root:maximum characters per line: 7
DEBUG:root:formatting string: NONE
DEBUG:root:text size: (93, 34)
DEBUG:root:paste coordinates: (0, 0)
DEBUG:root:formatting string: 5
DEBUG:root:text size: (19, 33)
DEBUG:root:paste coordinates: (0, 0)
DEBUG:root:initing display

I'm wondering if this is related to just using the default font? It could also be something in my environment since I didn't set up a pipenv.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions