Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-latin characters are displayed as '?' #5

Open
Levitanus opened this issue Jan 27, 2022 · 1 comment
Open

Non-latin characters are displayed as '?' #5

Levitanus opened this issue Jan 27, 2022 · 1 comment

Comments

@Levitanus
Copy link

Levitanus commented Jan 27, 2022

Linux 5.11.0-49-lowlatency #55-Ubuntu SMP PREEMPT Wed Jan 12 18:18:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Reaper 6.44, sws-2.12.1.3-Linux-x86_64

изображение

I see some troubles of unicode rendering. At the first glance I thought this is a problem of the selected font, but tests with Cyrillic font (as from python as from lua) showed it is not a matter.

Later I thought it is connected to the way strings has to be packed for the C-interface. In the reapy project, we've made hacks of original reaper_python for correct working of various strings and pointers. But, as far as I tried (not very long) — I didn't succeed with the problem.

As long as I can see it is not a issue of reascript itself, as Russian characters in the track name are visible as from ReaConsole as from the print statements (in the track manager example), but not in ImGui window.

So, at the moment, I think the problem is on the ReaImGui side. Later I'll try to make a minimal working unicode text example with JS_* API to test whether some characters can be drawn or not.

I'll carefully say Reaper and SWELL leaks some points of unicode support, generally, in Chinese symbols. But Russian works well.


The code below uses wrap I'm preparing, but It does exactly the same as original python port.

import reapy as reaper

ctx = reaper.ImGui.CreateContext('My script')
size = 25
font = reaper.ImGui.CreateFont('/home/levitanus/Загрузки/fonts/Montserrat/Montserrat-Light.ttf', size)
reaper.ImGui.AttachFont(ctx, font)

click_count, text = 0, '(例子) - chineeze, (рыба) russian'


def frame():
    global click_count, text

    if reaper.ImGui.Button(ctx, 'Click me!'):
        click_count = click_count + 1
    if click_count % 2 == 1:
        reaper.ImGui.SameLine(ctx)
        reaper.ImGui.Text(ctx, 'hello dear imgui!')

    rv, text = reaper.ImGui.InputText(ctx, 'text input', text, 1024 * 2)


def loop():
    reaper.ImGui.PushFont(ctx, font)
    reaper.ImGui.SetNextWindowSize(
        ctx, 400, 80, reaper.ImGui.Cond_FirstUseEver()
    )
    visible, open = reaper.ImGui.Begin(ctx, 'My script', True)
    if visible:
        frame()
        reaper.ImGui.End(ctx)

    reaper.ImGui.PopFont(ctx)

    if open:
        reaper.defer(loop)
    else:
        reaper.ImGui.DestroyContext(ctx)


reaper.defer(loop)
@cfillion
Copy link
Owner

cfillion commented Jan 27, 2022

At this time, ReaImGui rasterizes glyphs only from the Basic Latin and Latin Supplement Unicode blocks (U+0020 to U+00FF). UTF-8 is fully supported internally, however characters outside those blocks are displayed as '?'.

Dynamically finding and rasterizing glyphs on an on-demand basis is not currently possible, until a solution like ocornut/imgui#3471 gets finished and merged into Dear ImGui.

A temporary workaround could be to allow scripts to customize the range of characters to load from the font. However that still won't let them render all possible character from the entire Unicode, as loading everything would be slow and take way too much video memory.

@cfillion cfillion changed the title Unicode render Non-latin characters are displayed as '?' Jul 18, 2023
cfillion added a commit that referenced this issue Mar 23, 2024
Stack trace of the ~1s hang on the second call to GDKOpenGL::render:

    #0  0x00007ffff7a080bf in __GI___poll
        (fds=fds@entry=0x7fffffffc388, nfds=nfds@entry=1, timeout=timeout@entry=-1)
        at ../sysdeps/unix/sysv/linux/poll.c:29
    #1  0x00007ffff76d620b in poll (__timeout=-1, __nfds=1, __fds=0x7fffffffc388)
        at /usr/include/bits/poll2.h:39
    #2  _xcb_conn_wait
        (c=c@entry=0x11c0140, vector=vector@entry=0x0, count=count@entry=0x0, cond=<optimized out>)
        at /usr/src/debug/libxcb/libxcb-1.16.1/src/xcb_conn.c:510
    #3  0x00007ffff76d829b in _xcb_conn_wait
        (count=0x0, vector=0x0, cond=<optimized out>, c=0x11c0140)
        at /usr/src/debug/libxcb/libxcb-1.16.1/src/xcb_conn.c:476
    #4  xcb_wait_for_special_event (c=0x11c0140, se=0x35bca30)
        at /usr/src/debug/libxcb/libxcb-1.16.1/src/xcb_in.c:806
    #5  0x00007ffff5dad3bf in dri3_wait_for_event_locked ()
        at ../mesa-24.0.3/src/loader/loader_dri3_helper.c:591
    #6  dri3_wait_for_event_locked () at ../mesa-24.0.3/src/loader/loader_dri3_helper.c:572
    #7  0x00007ffff5dada12 in loader_dri3_wait_for_sbc ()
        at ../mesa-24.0.3/src/loader/loader_dri3_helper.c:664
    #8  loader_dri3_swapbuffer_barrier () at ../mesa-24.0.3/src/loader/loader_dri3_helper.c:2343
    #9  0x00007fffc48308da in dri_st_framebuffer_flush_swapbuffers ()
        at ../mesa-24.0.3/src/gallium/frontends/dri/dri_drawable.c:143
    #10 0x00007fffc48f6a99 in st_manager_flush_swapbuffers ()
        at ../mesa-24.0.3/src/mesa/state_tracker/st_manager.c:1270
    #11 st_finish () at ../mesa-24.0.3/src/mesa/state_tracker/st_cb_flush.c:85
    #12 0x00007fffc4a36421 in st_glFinish ()
        at ../mesa-24.0.3/src/mesa/state_tracker/st_cb_flush.c:109
    #13 _mesa_Finish () at ../mesa-24.0.3/src/mesa/main/context.c:1660
    #14 0x00007ffff6de8e8c in gdk_x11_gl_context_end_frame
        (context=0x32f8650 [GdkX11GLContext], painted=0x372ee50, damage=<optimized out>)
        at ../gtk/gdk/x11/gdkglcontext-x11.c:263
    #15 0x00007ffff6da4f6d in gdk_gl_context_end_frame
        (damage=0x0, painted=0x372ee50, context=0x32f8650 [GdkX11GLContext])
        at ../gtk/gdk/gdkglcontext.c:396
    #16 gdk_window_end_paint_internal (window=window@entry=0x3037a50 [GdkX11Window])
        at ../gtk/gdk/gdkwindow.c:3072
    #17 0x00007ffff6da50f7 in gdk_window_end_draw_frame
        (context=0x35bde50 [GdkDrawingContext], window=0x3037a50 [GdkX11Window])
        at ../gtk/gdk/gdkwindow.c:3311
    #18 gdk_window_end_draw_frame
        (window=0x3037a50 [GdkX11Window], context=0x35bde50 [GdkDrawingContext])
        at ../gtk/gdk/gdkwindow.c:3294
    #19 0x00007fffd782938e in GDKOpenGL::render (this=0x30134b0, userData=0x0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants