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

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
  • 153
  • 5