Giter Club home page Giter Club logo

Comments (22)

PiotrMachowski avatar PiotrMachowski commented on June 1, 2024 2

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

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

PiotrMachowski avatar PiotrMachowski commented on June 1, 2024 1

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

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

PiotrMachowski avatar PiotrMachowski commented on June 1, 2024

It's impossible using default font, but when you use a font that supports latin characters everything works:
image

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

Thanks, just need to know all of my font available. I am using HA in docker.

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

PiotrMachowski avatar PiotrMachowski commented on June 1, 2024

Here you have a command that should retrieve all available fonts:
https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor#texts-configuration

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

On RPi I have another error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 471, in async_device_update
    await self.hass.async_add_executor_job(self.update)  # type: ignore
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 185, in update
    self._map_data = self._connector.get_map(map_name, self._colors, self._drawables, self._texts, self._sizes,
  File "/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 "/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 "/config/custom_components/xiaomi_cloud_map_extractor/map_data_parser.py", line 237, in draw_elements
    ImageHandler.draw_texts(map_data.image, texts)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 170, in draw_texts
    ImageHandler.__draw_text__(image, text_config[CONF_TEXT], x, y, text_config[CONF_COLOR],
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 205, in __draw_text__
    font = ImageFont.truetype(font_file, font_size)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 655, in truetype
    return freetype(font)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 652, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 169, in __init__
    if core.HAVE_RAQM:
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 43, in __getattr__
    raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

PiotrMachowski avatar PiotrMachowski commented on June 1, 2024

Can you check which version of pillow/PIL you have?

pip3 list

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

I am trying to figure out how deps are installed for HA in docker... Which python is used and where to run the command.

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

Pillow 7.2.0

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

I am trying to run the next:

apk add --no-cache g++ freetype-dev jpeg-dev
pip uninstall pillow
pip install --no-cache-dir pillow

to make sure pillow will be compiled with libfreetype. I am not sure if this will be a persistent solution for HA in docker.

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

It looks like no fonts preinstalled in homeassistant docker image

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

Solution for me was to jump inside HA container and run the next commands:

apk add --no-cache g++ freetype-dev jpeg-dev
pip uninstall pillow
pip install --no-cache-dir pillow
apk add font-noto

and use NotoSansDisplay-Light.ttf font.

BTW it will be nice to choose TTF file stored somewhere in the config folder.

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

vacuum_fonts_fix

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

But there is still an issue with Pillow installed(compiled during installation) without libfreetype. I don't know if there is any solution for that. That how homeassistant processing requirements, looks like no options to control that. So I still have to run the command after every update of HA.

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

8osman avatar 8osman commented on June 1, 2024

I've hit the same problem, unfortunately my understanding is too limited to follow the instructions above.

I'm left with "ImportError: The _imagingft C module is not installed"

My home assistant is also installed within docker.

Thanks for the great work, really looking forward to being able to utilise this! :-)

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

leva3000 avatar leva3000 commented on June 1, 2024

After HA was updated to 0.116.2 I cannot fix the issue with the above commands. Every time I see The _imagingft C module is not installed error.

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

XxCabbyoO avatar XxCabbyoO commented on June 1, 2024

After HA was updated to 0.116.2 I cannot fix the issue with the above commands. Every time I see The _imagingft C module is not installed error.

I have the same error. So there is currently no solution to fix the Problem?

RPI4

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

PiotrMachowski avatar PiotrMachowski commented on June 1, 2024

Unfortunately I haven't found a solution yet

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

PiotrMachowski avatar PiotrMachowski commented on June 1, 2024

I have added handling to errors thrown during fonts loading.

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

Nicols07 avatar Nicols07 commented on June 1, 2024

I use HA on Docker with my NAS Synology. No fonts TTF on Synology...

it's Ok wihout font: "FreeSans.ttf" but i can't change the font_size...

texts:
      - text: "Room 1"
        x: 25
        y: 25
        color: [125, 20, 213]
        font_size: 100
      - text: "Room 2"
        x: 25
        y: 75
        color: [125, 20, 213, 127]
        font_size: 10

image

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

PiotrMachowski avatar PiotrMachowski commented on June 1, 2024

@Nicols07 unfortunately it's not possible to change size for a default font

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

tmjo avatar tmjo commented on June 1, 2024

Hi! I came over this issue when troubleshooting a similar issue with one of my own integrations. Not sure if it helps for this case, but I found a workaround by using bitmap fonts and then converting to PIL-fonts. Quite cumbersome solution, but it works better in my case. More info here if you're interested.

from home-assistant-custom-components-xiaomi-cloud-map-extractor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.