Skip to content

Support Freetype+Harfbuzz #748

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

Closed
Ghabry opened this issue Feb 1, 2016 · 25 comments
Closed

Support Freetype+Harfbuzz #748

Ghabry opened this issue Feb 1, 2016 · 25 comments

Comments

@Ghabry
Copy link
Member

Ghabry commented Feb 1, 2016

Will be needed to handle complex scripts that use combining diacritic marks.

@fdelapena
Copy link
Contributor

@pureexe do RPG Maker 2000/2003 Thai-scripted games exist? (Apart of your translation).
Because RPG Maker 2000 resolution is small, and Thai script for 6×12px width (half width) looks too small to display all diacritics, maybe is worth to break the half fixed width limitation of RPG_RT and use a variable width (or even 12×12px full width) in EasyRPG Player. However, if there exist games translated already, maybe they won't fit if they use too long lines (RPG Maker allows 50 half-width glyphs per line).

@pureexe
Copy link
Contributor

pureexe commented Feb 2, 2016

For now, We don't have any Thai scripted game created with RPG Maker 2000/2003 yet.

but 12x12 is enough for display thai character.

this is yanderella with nearly correct thai language display.

We use moded RM2000 font you can download it here.

https://www.dropbox.com/s/n6w75c3m0sv5c7n/rm2000.fon?dl=0

and run with this game file (this is test not full game so file just 4MB) http://www.mediafire.com/download/yz4yjzzeiqo9fdz/yanderella-thai-test.rar

@Ghabry
Copy link
Member Author

Ghabry commented Feb 2, 2016

Could you write this text normally here on github?
So we can see how the correct rendering should look like.

@pureexe
Copy link
Contributor

pureexe commented Feb 2, 2016

กาลครั้งหนึ่งนานมาแล้ว
มีหญิงสาวสวยนามว่า ซินเดอเรลล่า

@Ghabry
Copy link
Member Author

Ghabry commented Feb 2, 2016

Okay by measuring I would say that we need at least 22 pixel of height to fit everything with something above (รั้) and below (ญิ) beautifully. Needs some testing if freetype can somehow squash this in less.

I think the long term solution for this is to modify the whole rendering code of the Player to render with more pixels...

@fdelapena
Copy link
Contributor

@pureexe how readable would you consider this?

test

It is just a font rendering test using a fixed width font (Arundina Sans Mono) using freetype+harfbuzz at 11 px height (with auto width), seems to fit exactly 6 px width as RPG_RT does, which is good.

@pureexe
Copy link
Contributor

pureexe commented Feb 2, 2016

@fdelapena wow! pretty good.
it's 100% display correctly.

@whateverzone
Copy link

@fdelapena That's great! It seemed to display perfectly. Only that the fonts looked a bit blurry but that's not a big problem anyways.

Thank you for showing that to us!

We will looking forward to see RM2000/2003 to be able to support Thai perfectly.

@Ghabry
Copy link
Member Author

Ghabry commented Feb 3, 2016

@whateverzone
I'm currently investigating ways to improve the rendering by using higher resolutions. This will result in great font rendering because doubling the resolution already gives 4 times the pixel.
But the blurry font is a good start. When a better rendering is implemented it will "just work" without any ingame changes :)

@fdelapena
I would be interested in a screenshot without AA :D

@whateverzone
Copy link

@Ghabry Wow! Thank you for telling me that!
I hope your investigation goes well. We really want to see RM2000/2003's games with Thai version and also translation works such as Ib, Wadanohara etc.

Thank you very much for helping us ^^.

@Ghabry Ghabry modified the milestone: 0.5.0 Feb 4, 2016
@Ghabry
Copy link
Member Author

Ghabry commented Feb 6, 2016

Here some real rendering tests in the engine. Without harfbuzz, so the diacritics are wrong:

Normal resolution (1x / 320x240)
screenshot_6

HiRes (2x / 640x480):
screenshot_7

@pureexe
Copy link
Contributor

pureexe commented Feb 8, 2016

@Ghabry
Can you make diacritics display correctly?

@Ghabry
Copy link
Member Author

Ghabry commented Feb 8, 2016

@pureexe
Not with the current codebase. But is of course possible to implement. The font rendering on the screenshot is already modified code, so this is the first step for fixing diacritics.
Just wanted to show you a real version so you can check how readable 1x and 2x is. Do you consider 1x readable?

@pureexe
Copy link
Contributor

pureexe commented Feb 8, 2016

@Ghabry
I confirmed 1x and 2x is readable font.

@whateverzone
Do you think is it readable?

@whateverzone
Copy link

@pureexe Yes, I do.

@Ghabry
Copy link
Member Author

Ghabry commented Oct 2, 2016

Update for the Thai people. Working again on this, hope I can get some results soon ^^ (around November)

@pureexe
Copy link
Contributor

pureexe commented Oct 2, 2016

Thank you for working on this again.

@whateverzone
Copy link

Hello! It's been a while. I just wondered if you are still working on this or not.

@Ghabry
Copy link
Member Author

Ghabry commented Oct 29, 2017

Yes, I finally made some progress :D. Though this is still not complete because I also have to rework the messagebox code which renders char-by-char and this won't work with harfbuzz.

screenshot_20171029_215343

@Ghabry
Copy link
Member Author

Ghabry commented Oct 29, 2017

I think the 1bit-rendering looks better on that resolution:

screenshot_20171029_230731

@Ghabry
Copy link
Member Author

Ghabry commented Oct 30, 2017

Works now in message boxes. Due to tecnical reasons (need to split at most \-command codes) the rendering gets worse as I can't render in one go. To fix this I would need to analyze the right part of the bounding box and crop the empty rows :/

Well and some stuff just can't be simulated because Freetype moves some glyphs below others for esthetics.

screenshot_20171030_191550

Using a different "Hinter". Does this look better or worse?

screenshot_20171030_194450

@Ghabry
Copy link
Member Author

Ghabry commented Oct 30, 2017

About the configuration. I don't want to support font-config or any font substitution now because have no idea how to use this and not worth the afford by now imo.

I would propose a configuration in the RPG_RT.ini:

[EasyRPG]
Font=Arial;12;Mincho;11
Font2=Verdana;11

The font depends on which Font is selected for the system graphic. When one font is not defined it uses the normal built-in one.

Assuming the System graphic Font is the 1st this will look in the "Font" folder of the game for Arial.ttf and Mincho.ttf and render Arial glyphs with size 12 and when a glyph is missing in the font it renders a Mincho glyph with size 11.

As a "flow chart":

           Missing              Missing           Missing
Arial 12pt -------> Mincho 11pt -------> built-in -------> <?>

Same for the command line: --font and --font2

@Ghabry Ghabry modified the milestones: 0.6.1, 0.7.0 May 5, 2019
@Ghabry Ghabry modified the milestones: 0.7.1, 0.7.2 May 29, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Nov 6, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Nov 6, 2022
@Ghabry
Copy link
Member Author

Ghabry commented Nov 6, 2022

WIP Harfbuzz branch: https://github.com/Ghabry/easyrpg-player/commits/harfbuzz

Wasn't that hard. Only lost two hours because I forgot to divide offset with 64 🤦 . Not very intuitive because normal Freetype doesn't need this divide for offset (bitmap) 🙄

Size calculation has some bugs and it doesn't work for the message box yet. The message box is hard to do because the text appears glyph by glyph and it has all this command processing etc.

Comparison (click to enlarge):

Left is w/o HB, Right is w/ HB

The Thai rendering of the stacked glyphs is correct now (trust me, I compared this with SDL_TTF and in Chrome ;))

out

Spot the difference ;) (look for ligatures and letters that are "moved under" other letters like e.g. in case of 'To')

out2

@Ghabry
Copy link
Member Author

Ghabry commented Nov 6, 2022

Added (Experimental) shaping support for Window Message. Even works properly for color codes etc. :)

screenshot_12

Sans Serif vs. Serif:

กาลครั้งหนึ่ง
Alexกำลังเรียนภาษาไทย
Unicodeเจ๋งมาก!

out

@pureexe better late than never I guess 🤔

@pureexe
Copy link
Contributor

pureexe commented Nov 7, 2022

Looking good!
Better late than never 😊

@Ghabry Ghabry modified the milestones: 0.7.2, 0.7.1 Nov 9, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Nov 14, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Nov 14, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Dec 5, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Dec 7, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Dec 14, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Dec 22, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Dec 22, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Dec 22, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Jan 28, 2023
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants