Component not found: font

My code that I copied from my old computer is showing this error “Component not found: font.”, in this part of the code. In this sense, I have already installed the fonts in homeassistant and still the error persists.

font:
  - file: "esphome/stocky.ttf"
    id: my_font
    size: 14
  - file: "esphome/arial.ttf"
    id: my_font2
    size: 13

display:
  - platform: ssd1306_i2c
    id: oled
    setup_priority: -100
    model: "SSD1306 128x64"
    address: 0x3C
    pages:
      - id: page1
        lambda: |-
          it.printf(3, 20, id(my_font), "Acqua Callidus");
      - id: page2
        lambda: |-
          it.printf(0, 20, id(my_font2), "Humidity: %.2f%%", id(office_humidity).state);
      - id: page3
        lambda: |-
          it.printf(0, 20, id(my_font2), "Pressure: %.2fhPa", id(outside_pressure).state);    
      - id: page4
        lambda: |-
          it.printf(0, 20, id(my_font2), "Temperature: %.2f°C", id(office_temperature).state);

Your config suggests that the font files are in /config/esphome/esphome -

file (Required ): The path (relative to where the .yaml file is) of the font file.

This is the correct way, but it doesn’t work either
font:

  • file: “/homeassistant/esphome/stocky.ttf”
    id: my_font
    size: 14
  • file: “/homeassistant/esphome/arial.ttf”
    id: my_font2
    size: 13

Relative to where the yaml files are placed. relative

The files are in the esphome folder, before it was working normally

Try following the docs. I am no way sure what your error is, but following the docs is the best plan.

If I read the error correctly, it is not the font files that are missing, but it does not understand font: itself. What version of esphome are you using? Also, the docs state you need additional packages. If you use the ESPHome addon you should already have it, if you have a different install you may not.