Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor: Warning: Unable to open font (...)

I cannot add label in Cyrillic, such as “Кухня”:

Traceback (most recent call last):
  File "E:\HassWP\python-3.7.7\lib\site-packages\homeassistant\helpers\entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "E:\HassWP\python-3.7.7\lib\site-packages\homeassistant\helpers\entity.py", line 472, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "E:\HassWP\python-3.7.7\lib\concurrent\futures\thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\camera.py", line 186, in update
    self._image_config)
  File "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\xiaomi_cloud_connector.py", line 105, in get_map
    map_data = MapDataParser.parse(unzipped, colors, drawables, texts, sizes, image_config)
  File "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\map_data_parser.py", line 76, in parse
    MapDataParser.draw_elements(colors, drawables, texts, sizes, map_data)
  File "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\map_data_parser.py", line 237, in draw_elements
    ImageHandler.draw_texts(map_data.image, texts)
  File "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\image_handler.py", line 171, in draw_texts
    text_config[CONF_FONT], text_config[CONF_FONT_SIZE])
  File "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\image_handler.py", line 206, in __draw_text__
    w, h = draw.textsize(text, font)
  File "E:\HassWP\config\deps\Python37\site-packages\PIL\ImageDraw.py", line 430, in textsize
    return font.getsize(text, direction, features, language, stroke_width)
  File "E:\HassWP\config\deps\Python37\site-packages\PIL\ImageFont.py", line 128, in getsize
    return self.font.getsize(text)
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-6: ordinal not in range(256)

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 22 (8 by maintainers)

Most upvoted comments

I will try to find a way to attach a font file

Using TTF stored in a config is much better, as it doesn’t require manual changes after every HA update. I will check if it is possible