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

Can I use wider area while text rendering process? #22

Closed
ppkppk8520 opened this issue Aug 30, 2021 · 10 comments
Closed

Can I use wider area while text rendering process? #22

ppkppk8520 opened this issue Aug 30, 2021 · 10 comments

Comments

@ppkppk8520
Copy link

Because it is awkward that reading text vertically, I modified text_render.py to always render text horizontally.
But since original text area is too narrow, this result is still hard to read.
So, I want to know it is possible to modify code to use more wider area while text rendering process.(and how to)

Sorry for my poor English and thanks in advance.

@zyddnys
Copy link
Owner

zyddnys commented Aug 31, 2021

The only information available to the text renderer is the original text line positions, so if the original text is vertical and translated text is horizontal the rendered text will be too narrow.
You need a way to figure out where to put translated horizontal texts, which I can't figure out how to do.
As stated in README.md:

5. Text rendering area is determined by detected text lines, not speech bubbles. This works for images without speech bubbles, but making it impossible to decide where to put translated English text. I have no idea how to solve this.

@ppkppk8520
Copy link
Author

thanks for notifying me!

@marcussacana
Copy link

I has wrote a modification in the past year to this tool, that used the inpainting image to search the limit of the solid background color in the bubble and with that I was able to expand the text render area in a better way, well, I never pushed because I did in C# and called from python, isn't good for the project the way that I did it.

@marcussacana
Copy link

marcussacana commented May 8, 2022

Here, I did with this code: https://gist.github.com/marcussacana/2e6bfa87ebb1a6b11eb41708125aba7d
And I called like this

	import clr
	clr.AddReference("TextDraw")
	from TextDraw import GDI
	GDI.DrawText('./result/render.png', trans_text,  region.x, region.y, region.w, region.h, (255 << 24)|(region.fg_r << 16)|(region.fg_g << 8)|region.fg_b)

the output has like this:
image

@Snowad14
Copy link

Snowad14 commented Jun 17, 2022

Here, I did with this code: https://gist.github.com/marcussacana/2e6bfa87ebb1a6b11eb41708125aba7d And I called like this

	import clr
	clr.AddReference("TextDraw")
	from TextDraw import GDI
	GDI.DrawText('./result/render.png', trans_text,  region.x, region.y, region.w, region.h, (255 << 24)|(region.fg_r << 16)|(region.fg_g << 8)|region.fg_b)

the output has like this: image

I had a little trouble rewriting it on the new version but it gave me more readable results even if I think it's mostly the way the text is rendered that changes.
I tested it only on English to another non-vertical language it will surely be less good from Japanese to English

Normal :
Normal

Manga2eng :
MangaENG

This method (I forgot to remove the red rectangle)
New

@marcussacana
Copy link

Should change the font to be even better, that default one is very strange.
image
I don't know why, I remeber well to made this tools to try fill empty space much as possible, that red/blue squares are for that, to me debug the empty region that the tool found.
For some reason look like isn't working correctly, maybe I uploaded an outdated version of my code? lol

@marcussacana
Copy link

Ohh, maybe this:
image
very hard to see, but the image isn't really clean, this small detail stopped the text region to be expanded.

@Snowad14
Copy link

Snowad14 commented Jun 17, 2022

I don't think so, I tried with other ones that come from manga PLUS and it was always a bit the same
inpainted

@marcussacana
Copy link

Only debugging then, maybe a bug, because I remember well that thing as one of the worst part writing that code.

@marcussacana
Copy link

Ohh, during the call you set the argument NoExpand to true maybe?

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

4 participants