Почему fAwesome6 не работает

.KOHTOP.

Активный
Автор темы
219
35
Версия MoonLoader
.027.0-preview
1697987059732.png

Из-за чего такое может быть?

Предполагаю это из-за этого:

Lua:
imgui.OnInitialize(function()



    sW, sH = getScreenResolution()
    u32 = imgui.ColorConvertFloat4ToU32
    imgui.GetIO().IniFilename = nil
    local config = imgui.ImFontConfig()
    config.MergeMode = true
    config.PixelSnapH = true
    iconRanges = imgui.new.ImWchar[3](faicons.min_range, faicons.max_range, 0)
    imgui.GetIO().Fonts:AddFontFromMemoryCompressedBase85TTF(faicons.get_font_data_base85('solid'), 14, config, iconRanges)
    local FONTS = imgui.GetIO().Fonts
    local STYLE = imgui.GetStyle()
    local COLOR = STYLE.Colors
    local VEC4, c = imgui.ImVec4, imgui.Col
    font = { B = {}, R = {} }

    if doesFileExist(getWorkingDirectory()..'\\AdminTools\\avatar.jpg') then -- находим необходимую картинку с названием example.png в папке moonloader/resource/
        Image = imgui.CreateTextureFromFile(getWorkingDirectory() .. '\\AdminTools\\avatar.jpg') -- если найдена, то записываем в переменную хендл картинки
    end
    if doesFileExist(getWorkingDirectory()..'\\AdminTools\\avatar.jpg') then -- находим необходимую картинку с названием example.png в папке moonloader/resource/
        Share = imgui.CreateTextureFromFile(getWorkingDirectory() .. '\\AdminTools\\resource\\share.png') -- если найдена, то записываем в переменную хендл картинки
    end
    local builder = imgui.ImFontGlyphRangesBuilder()
    builder:AddRanges(FONTS:GetGlyphRangesCyrillic())
    builder:AddText("‚„…†‡€‰‹‘’“”•–-™›№")
    local range = imgui.ImVector_ImWchar()
    builder:BuildRanges(range)

    config.MergeMode = true
    config.PixelSnapH = true
    iconRanges = imgui.new.ImWchar[3](faicons.min_range, faicons.max_range, 0)
    imgui.GetIO().Fonts:AddFontFromMemoryCompressedBase85TTF(faicons.get_font_data_base85('solid'), 14, config, iconRanges)

    font['R'][15] = FONTS:AddFontFromMemoryCompressedBase85TTF(base85.SF_R, 15, nil, range[0].Data)
    font['B'][15] = FONTS:AddFontFromMemoryCompressedBase85TTF(base85.SF_B, 15, nil, range[0].Data)
    font['R'][20] = FONTS:AddFontFromMemoryCompressedBase85TTF(base85.SF_R, 20, nil, range[0].Data)
    font['B'][20] = FONTS:AddFontFromMemoryCompressedBase85TTF(base85.SF_B, 20, nil, range[0].Data)
    font['R'][70] = FONTS:AddFontFromMemoryCompressedBase85TTF(base85.SF_R, 70, nil, range[0].Data)
    font['B'][70] = FONTS:AddFontFromMemoryCompressedBase85TTF(base85.SF_B, 70, nil, range[0].Data)

    img = imgui.CreateTextureFromFileInMemory(imgui.new('const char*', base85.img), #base85.img)

    -- STYLE
    if target ~= -1 then
        imgui.SwitchContext()
        imgui.GetStyle().WindowPadding = imgui.ImVec2(10, 10)
        imgui.GetStyle().ItemSpacing = imgui.ImVec2(5, 5)
        imgui.GetStyle().WindowRounding = 5.0
        imgui.GetStyle().Colors[imgui.Col.WindowBg] = imgui.ImVec4(0.16, 0.16, 0.22, 0.50)
    else
        imgui.SwitchContext()
        STYLE.WindowPadding        = imgui.ImVec2(5, 5)
        STYLE.ItemSpacing        = imgui.ImVec2(10, 10)
        STYLE.WindowBorderSize    = 5.0
        STYLE.WindowRounding    = 10.0
        STYLE.ChildRounding        = 10.0
        STYLE.FrameRounding        = 5.0

        COLOR[c.Text]                    = VEC4(1.00, 1.00, 1.00, 1.00)
        COLOR[c.TextDisabled]            = VEC4(1.00, 1.00, 1.00, 0.80)
        COLOR[c.WindowBg]                = VEC4(0.13, 0.12, 0.18, 1.00)
        COLOR[c.ChildBg]                = VEC4(0.18, 0.17, 0.23, 1.00)
        COLOR[c.PopupBg]                = VEC4(0.30, 0.30, 0.30, 1.00)
        COLOR[c.Border]                    = VEC4(0.60, 0.50, 0.95, 1.00)
        COLOR[c.Separator]                = VEC4(0.50, 0.50, 0.50, 0.90)
        COLOR[c.FrameBg]                = VEC4(0.60, 0.50, 0.95, 0.20)
        COLOR[c.FrameBgHovered]            = VEC4(0.60, 0.50, 0.95, 0.50)
        COLOR[c.FrameBgActive]            = VEC4(0.60, 0.50, 0.95, 1.00)
        COLOR[c.SliderGrab]                = VEC4(1.00, 1.00, 1.00, 0.50)
        COLOR[c.SliderGrabActive]        = VEC4(1.00, 1.00, 1.00, 1.00)
        COLOR[c.CheckMark]                = VEC4(1.00, 1.00, 1.00, 1.00)
        COLOR[c.Button]                    = VEC4(0.60, 0.50, 0.95, 0.50)
        COLOR[c.ButtonHovered]            = VEC4(0.65, 0.55, 0.75, 0.50)
        COLOR[c.ButtonActive]            = VEC4(0.65, 0.55, 0.75, 1.00)
        COLOR[c.ScrollbarBg]            = VEC4(0.60, 0.50, 0.95, 0.30)
        COLOR[c.ScrollbarGrab]            = VEC4(0.60, 0.50, 0.95, 0.80)
        COLOR[c.ScrollbarGrabHovered]    = VEC4(0.60, 0.50, 0.95, 0.30)
        COLOR[c.ScrollbarGrabActive]    = VEC4(0.60, 0.50, 0.95, 0.30)
        COLOR[c.TextSelectedBg]         = VEC4(1.00, 1.00, 1.00, 0.30)
        COLOR[c.ModalWindowDimBg]       = VEC4(0.00, 0.00, 0.00, 0.60)
    end
end)
 
Решение
Посмотреть вложение 218716
Кодировка сбилась, так и так нужен UTF-8
я хз как по нормальному решить эту проблему, можешь просто проставить где надо кодировку, либо не стирать u8 и просто рендерить иконку через обычный имгуи текст
Lua:
imgui.Text(faicons('user')) imgui.SameLine()
imgui.TextColoredRGB('{ffffff}Логин: {ff0000}')

.KOHTOP.

Активный
Автор темы
219
35
скорее всего ты заключил иконку в u8, например
Lua:
u8((faicons("H3")..'Логин') - неправильно
(faicons("H3")..u8('Логин') - правильно
Код:
local nav = {
    current = 1,
    pages = {
        faicons('star') .. 'Аккаунт',
        '312',
        '534'
    }
}
 

.KOHTOP.

Активный
Автор темы
219
35
кинь строку с этой иконкой и текстом логин
Lua:
imgui.TextColoredRGB(faicons('user') .. '{ffffff}Логин: {ff0000}' .. login)

Что добавил (из твоего гайда):
local faicons = require('fAwesome6')

    config.MergeMode = true
    config.PixelSnapH = true
    iconRanges = imgui.new.ImWchar[3](faicons.min_range, faicons.max_range, 0)
    imgui.GetIO().Fonts:AddFontFromMemoryCompressedBase85TTF(faicons.get_font_data_base85('solid'), 14, config, iconRanges)
 

MLycoris

Режим чтения
Проверенный
1,821
1,860
Lua:
imgui.TextColoredRGB(faicons('user') .. '{ffffff}Логин: {ff0000}' .. login)

Что добавил (из твоего гайда):
local faicons = require('fAwesome6')

    config.MergeMode = true
    config.PixelSnapH = true
    iconRanges = imgui.new.ImWchar[3](faicons.min_range, faicons.max_range, 0)
    imgui.GetIO().Fonts:AddFontFromMemoryCompressedBase85TTF(faicons.get_font_data_base85('solid'), 14, config, iconRanges)
найди в функции TextColoredRGB вот эти строки в конце и сотри из них u8, но теперь придется ставить перед текстом u8, как в стандартном imgui.Text
1697989131533.png

если не понял, то вот держи
Lua:
function imgui.TextColoredRGB(text)
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4
    local explode_argb = function(argb)
        local a = bit.band(bit.rshift(argb, 24), 0xFF)
        local r = bit.band(bit.rshift(argb, 16), 0xFF)
        local g = bit.band(bit.rshift(argb, 8), 0xFF)
        local b = bit.band(argb, 0xFF)
        return a, r, g, b
    end
    local getcolor = function(color)
        if color:sub(1, 6):upper() == 'SSSSSS' then
            local r, g, b = colors[1].x, colors[1].y, colors[1].z
            local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
            return ImVec4(r, g, b, a / 255)
        end
        local color = type(color) == 'string' and tonumber(color, 16) or color
        if type(color) ~= 'number' then return end
        local r, g, b, a = explode_argb(color)
        return imgui.ImVec4(r/255, g/255, b/255, a/255)
    end
    local render_text = function(text_)
        for w in text_:gmatch('[^\r\n]+') do
            local text, colors_, m = {}, {}, 1
            w = w:gsub('{(......)}', '{%1FF}')
            while w:find('{........}') do
                local n, k = w:find('{........}')
                local color = getcolor(w:sub(n + 1, k - 1))
                if color then
                    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
                    colors_[#colors_ + 1] = color
                    m = n
                end
                w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], text[i])
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else imgui.Text(w) end
        end
    end
    render_text(text)
end
 

.KOHTOP.

Активный
Автор темы
219
35
найди в функции TextColoredRGB вот эти строки в конце и сотри из них u8, но теперь придется ставить перед текстом u8, как в стандартном imgui.Text
Посмотреть вложение 218715
если не понял, то вот держи
Lua:
function imgui.TextColoredRGB(text)
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4
    local explode_argb = function(argb)
        local a = bit.band(bit.rshift(argb, 24), 0xFF)
        local r = bit.band(bit.rshift(argb, 16), 0xFF)
        local g = bit.band(bit.rshift(argb, 8), 0xFF)
        local b = bit.band(argb, 0xFF)
        return a, r, g, b
    end
    local getcolor = function(color)
        if color:sub(1, 6):upper() == 'SSSSSS' then
            local r, g, b = colors[1].x, colors[1].y, colors[1].z
            local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
            return ImVec4(r, g, b, a / 255)
        end
        local color = type(color) == 'string' and tonumber(color, 16) or color
        if type(color) ~= 'number' then return end
        local r, g, b, a = explode_argb(color)
        return imgui.ImVec4(r/255, g/255, b/255, a/255)
    end
    local render_text = function(text_)
        for w in text_:gmatch('[^\r\n]+') do
            local text, colors_, m = {}, {}, 1
            w = w:gsub('{(......)}', '{%1FF}')
            while w:find('{........}') do
                local n, k = w:find('{........}')
                local color = getcolor(w:sub(n + 1, k - 1))
                if color then
                    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
                    colors_[#colors_ + 1] = color
                    m = n
                end
                w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], text[i])
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else imgui.Text(w) end
        end
    end
    render_text(text)
end
1697989339443.png

Кодировка сбилась, так и так нужен UTF-8
 

MLycoris

Режим чтения
Проверенный
1,821
1,860
Посмотреть вложение 218716
Кодировка сбилась, так и так нужен UTF-8
я хз как по нормальному решить эту проблему, можешь просто проставить где надо кодировку, либо не стирать u8 и просто рендерить иконку через обычный имгуи текст
Lua:
imgui.Text(faicons('user')) imgui.SameLine()
imgui.TextColoredRGB('{ffffff}Логин: {ff0000}')
 

.KOHTOP.

Активный
Автор темы
219
35
Не работает
я хз как по нормальному решить эту проблему, можешь просто проставить где надо кодировку, либо не стирать u8 и просто рендерить иконку через обычный имгуи текст
Lua:
imgui.Text(faicons('user')) imgui.SameLine()
imgui.TextColoredRGB('{ffffff}Логин: {ff0000}')
Работает