include(${CMAKE_CURRENT_LIST_DIR}/fonts_symbols.cmake)

string(JOIN "," LVGL_SYMBOLS ${LVGL_SYMBOLS_CLASSIQUES})
message(STATUS "LVGL SYMBOL RANGE = ${LVGL_SYMBOLS}")

function (make_font fontName fileName fontSize)
    execute_process(COMMAND podman run -v ${PROJECT_DIR}/components/domotic_display/fonts:/app -w /app lvfontconv lv_font_conv --bpp 4 --size ${fontSize} --no-compress --font ${fontName}.ttf --symbols "0123456789.°àéèêëûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz %,'!? ():/-" --format lvgl -o ${fileName}_${fontSize}.c --font fa-solid-900.ttf --range ${LVGL_SYMBOLS}) 
endfunction()

make_font(Montserrat-Medium montserrat_medium 12 )
make_font(Montserrat-Medium montserrat_medium 18)
make_font(Montserrat-Medium montserrat_medium 24)
make_font(Roboto-Medium roboto_medium 36)
make_font(Roboto-Medium roboto_medium 72)
make_font(Super_Malibu super_malibu 80)


#execute_process(COMMAND podman run -v /home/marc/rgb_lcd/components/domotic_display/fonts:/app -w /app lvfontconv lv_font_conv --bpp 4 --size 36 --no-compress --font Roboto-Medium.ttf --symbols "0123456789.°àéèûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz %,'():ê/-" --format lvgl -o roboto_medium_36.c --font fa-solid-900.ttf --range 61461,0xf0c2,0xf575) 
#execute_process(COMMAND podman run -v /home/marc/rgb_lcd/components/domotic_display/fonts:/app -w /app lvfontconv lv_font_conv --bpp 4 --size 72 --no-compress --font Roboto-Medium.ttf --symbols "0123456789.°àéèûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz %,'():ê/-" --format lvgl -o roboto_medium_72.c --font fa-solid-900.ttf --range 61461,0xf0c2,0xf575) 


SET(comps meteofrance eventsManager lvgl RemindMe)
if(${IDF_TARGET} STREQUAL "esp32p4" OR ${IDF_TARGET} STREQUAL "esp32s3")
    #esp32_p4_function_ev_board
    idf_component_register(SRC_DIRS . fonts
                        INCLUDE_DIRS "include"
                        REQUIRES ${comps} esp_lvgl_port esp32_p4_function_ev_board )
    target_compile_options(${COMPONENT_LIB} PUBLIC -DLV_LVGL_H_INCLUDE_SIMPLE)

    lvgl_port_create_c_image("images/wifi_ok.png" "images/" "ARGB8888" "NONE")
    lvgl_port_create_c_image("images/wifi_ko.png" "images/" "ARGB8888" "NONE")
    lvgl_port_create_c_image("images/mqtt_ok.png" "images/" "AUTO" "NONE")
    lvgl_port_create_c_image("images/mqtt_ko.png" "images/" "ARGB8888" "NONE")
    lvgl_port_add_images(${COMPONENT_LIB} "images/")
    #littlefs_create_partition_image(littlefs images_meteo FLASH_IN_PROJECT)
elseif(${IDF_TARGET} STREQUAL "linux")
    idf_component_register(SRC_DIRS . fonts images
                        INCLUDE_DIRS "include"
                        REQUIRES ${comps})
                        message("Including SDL2 support")
    find_package(SDL2 REQUIRED)
    target_link_libraries(${COMPONENT_LIB} PUBLIC
        -Wl,--no-as-needed
        SDL2
        -Wl,--as-needed
    )

    target_compile_options(${COMPONENT_LIB} PUBLIC -DLV_LVGL_H_INCLUDE_SIMPLE)
endif()
                
