2

X Error of failed request: BadLength (poly request too large or internal Xlib length error) Major opcode of failed request: 139 (RENDER) Minor opcode of failed request: 20 (RenderAddGlyphs) Serial number of failed request: 689 Current serial number in output stream: 783

Hello. I'm using ubuntu 18.04 Mate and I get this error when I execute the python code below. Yet the code is correct.

Here is the code that creates the bug:

import tkinter as tk
import tkinter.font as tkfont
from tkinter.scrolledtext import ScrolledText

root = tk.Tk()
frame = tk.LabelFrame(root, text="Polices")
frame.grid()
ft = tkfont.families()
txt = ScrolledText(frame, width=50, height=20)
txt.grid()

txt.insert("1.0", 'Polices:\n')
txt.tag_add("tagpolices", "1.0", "insert")

for i,f in enumerate(ft):
    font = tkfont.Font(frame, size=20, family=f)
    tag = f'tag{i}'
    txt.tag_config(tag, font=font)
    txt.insert("end", f, tag, '\n')

root.mainloop()

How to solve this problem?

fabien
  • 21
  • Hello, The font that generates the bug is: Noto Color Emoji – fabien Dec 13 '20 at 06:27
  • 1
    It looks like this may be the same problem as https://unix.stackexchange.com/questions/629281/gitk-crashes-when-viewing-commit-containing-emoji-x-error-of-failed-request-ba. If that's the case, a libXft bug appears to be responsible for the error.

    As @fabien says, the Noto Color Emoji font triggers the error, so uninstalling it would be a viable workaround.

    – David P Apr 12 '21 at 08:39
  • Thank @David P . Solded with apt remove --purge fonts-noto-color-emoji – fabien Apr 19 '21 at 14:43

1 Answers1

0

Before completely giving up, try

sudo apt install unifont

…as suggested in this blog post.

I'm not well-versed in Unicode or Tk or related issues with non-BMP fonts (other than a vague understanding of what they are). However, this context from the blog's author helps a bit:

I had that error with st terminal when I used an emoji, but after I installed Unifont, the problem disappeared. The solution I wrote is better than others, because other solutions include patching the source code of problematic applications or libXft. I do not think it is a user-friendly way.

In my case, I was suffering with an almost identical error in nvpy, when it went to sync any newly-created note with a wide character in it. Simply installing the unifont package seems to have fixed the problem.

Kevin E
  • 157