LuisMayo / objection_engine

Library that turns comment chains into ace attorney scenes, used in several bots
MIT License
105 stars 20 forks source link

Improved Arabic/RTL support #93

Closed Meorge closed 1 year ago

Meorge commented 1 year ago

Implements issue #92.

https://user-images.githubusercontent.com/9957987/200884824-132dc7f5-e993-4b20-a1e4-d9d81d27a947.mp4

NOTE: With these changes, the user will need to have the KawkabMono-Regular.ttf file from the font's website in the assets/igiari folder.

LuisMayo commented 1 year ago

Hi!

This seems impressive already. I can't read Arabic text so I'm not sure, but if you say the new font is more readable I'll take your word for it. About the line breaking problem I'm going to spawn an issue for that. But that shouldn't stop this PR to get merged. Readability is more important than line breaking

Furthermore, bad line breaking has been an issue for a long time now, it also happens in english #55

As always I'll do a few tests and merge this accordingly. Again thanks for your work

Meorge commented 1 year ago

Because this pull request involved the animated arrow, I decided to go ahead and GIF-ify it. The GIF is below, and should be placed at assets/arrow.gif: arrow

Here is how it looks with the RTL test:

https://user-images.githubusercontent.com/9957987/201261268-14c41f7f-4e8a-4cc9-8d8b-ef88e3e04a2e.mp4

As such, this pull request should take care of #92 and #94 ! 😄

LuisMayo commented 1 year ago

Hi! With your permission I've added some code to ensure updating the engine will be transparent for users without them having to manually remove the assets folder.

That being said. I'm having trouble running example.py

Traceback (most recent call last):
  File "C:\Users\luis.mayo\Documents\GitHub\objection_engine\examples\example.py", line 24, in <module>
    render_comment_list(comments, f'output-{str(int(time()))}.mp4')
  File "C:\Users\luis.mayo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\objection_engine\renderer.py", line 62, in render_comment_list
    return anim.comments_to_scene(thread, name_music = music_code, output_filename=output_filename, resolution_scale=resolution_scale)
  File "C:\Users\luis.mayo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\objection_engine\anim.py", line 587, in comments_to_scene
    ace_attorney_anim(formatted_scenes, **kwargs)
  File "C:\Users\luis.mayo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\objection_engine\anim.py", line 442, in ace_attorney_anim
    sound_effects = do_video(config, root_filename, resolution_scale)
  File "C:\Users\luis.mayo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\objection_engine\anim.py", line 117, in do_video
    if obj["text"].use_rtl():
KeyError: 'text'

Can you confirm if it works fine in your machine? I'm currently on a new laptop may installation may be off.

Thanks for your work!

Meorge commented 1 year ago

When running the standard example, I got the same error. I must've only been testing it on the RTL test where there were no Objection bubbles, whoops 😅 Anyways, I added a quick check to fix that! I also moved the location of the print statement in your code so that it only runs if the file is not found. Being able to download individual assets from the server instead of just one zip file is a great idea!

LuisMayo commented 1 year ago

I push a 10 lines code and one is not in its place 🤦‍♂️

Anyway, this is good to go now. Thanks again for a well-done job!