Wrap and display Japanese sentences well with pyglet

Set the paragraph style wrap to " char ".

python


document = pyglet.text.decode_text(text_data)
document.set_style(0, 0, {
    "color": (255,255,255,255),
    "line_spacing": 24,
    "wrap": "char"
})
layout = pyglet.text.layout.TextLayout(document, 640, 480,
                                       multiline=True, batch=batch)

wagahai.png

It was prepared properly. I was about to write a wrapping text layout on my own.

In addition to " char ", " word ", True, False can be set for wrap. " word " is the same as True.

Recommended Posts

Wrap and display Japanese sentences well with pyglet
Calculate and display standard weight with python
(Mac) How to display Japanese with Matplotlib and Seaborn At MacOS Sierra
Display Japanese graphs with VS Code + matplotlib
How to display python Japanese with lolipop
Display Google Maps API with Rails and pin display
Coexistence of Fcitx and Zoom ~ With Japanese localization ~
Interactively display algebraic curves with Python and Jupyter
Japanese with matplotlib
Display serial number columns and variables with Bottle template
Display embedded images of mp3 and flac with mutagen
Separation of Japanese surname and given name with BERT
It's too troublesome to display Japanese with Vim's python3.
Display and shoot webcam video with Python Kivy [GUI]