🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5Stack Core2, How to load Custom Font?

    Core 2
    2
    3
    3.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      AhmadAgb
      last edited by AhmadAgb

      I was reading: https://community.m5stack.com/topic/388/cahnge-font-size-in-python/ on how to load custom font on my Core2 Board and tried to do it myself.

      Given font file in .ttf format, I've generated 2 files: in .c and .bin format using the following online tool: https://lvgl.io/tools/font_conv_v5_3

      Then, I moved them to my Core2 Board and tried to use the new font like this (I'm working with MicroPython):

      from m5stack import *
      from m5stack_ui import *
      from uiflow import *
      from valera import *
      
      screen = M5Screen()
      screen.clean_screen()
      screen.set_screen_bg_color(0xFFFFFF)
      
      
      label0 = M5Label('Hi', x=149, y=86, color=0x000, parent=None)
      lcd.compileFont("./valera.c")
      lcd.font("./valera.c")
      

      But, every time I run the above code the program crashes and causes a restart to the device.
      Any suggestions on what could be the problem here?

      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by

        What crash is it, what the error message?

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 1
        • A
          AhmadAgb
          last edited by AhmadAgb

          I'm not seeing any error message, the device just restarts.
          I've tried to use the following code instead (without calling lcd.font):

          lcd.compileFont("./valera.c")
          label0 = M5Label('Hi', x=149, y=86, color=0x000, font=valera.fon, parent=None)
          

          While it doesn't cause restart the font isn't working (I've tried to search the generated files and compileFont doesn't seem to produce any .fon file, which shouldn't be the case)

          Side Note: my input .c file is less than 100 KB in size, as larger files caused crashes according to the comments in previous posts.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post