[haiku-development] Re: Complex font rendering in Haiku

  • From: "Linuxero" <dmarc-noreply@xxxxxxxxxxxxx> (Redacted sender "mageia" for DMARC)
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 14 Apr 2019 19:23:24 +0200

...


Well, maybe we should start at how text-rendering currently works in
Haiku. As you perhaps know, Haiku applications link against libbe.so.
The classes of the Interface Kit live in libbe.so among other stuff. An
application makes an instance of a BView and uses the BView methods to
draw stuff in that view. There are for example multiple versions of
BView::DrawText():

https://www.haiku-os.org/legacy-docs/bebook/BView.html#BView_Drawing

Some applications may need to do more than just draw text. They may need
to know where to place a blinking input cursor. So they need to know
where individual glyphs will be positioned. They could use BFont to get
that information:

https://www.haiku-os.org/legacy-docs/bebook/BFont.html#BFont_GetEscapements

In all these cases, what actually happens is that a running BApplication
has a communication link with the app_server. You can think of it as a
bidirectional socket (called "ports" in Haiku). The BView or BFont
implementation write the parameters from these method invokations into
the link, and then app_server receives it, processes it and does
something in return, which could be rendering something to the screen,
or sending information back through the link.

As a result, app_server needs to link against Harfbuzz. And the actual
implementation of anything regarding complex text rendering, will be
inside app_server. And the BView and BFont classes will need to be
extended to provide new methods, but those will only communicate with
the app_server.


At what point are we with Harfbuzz integration?

Your job will be to figure out what those new BView and BFont methods
should be, in order to provide all the functionality that applications
will need. You need to figure out which information you will require
from applications. As an example: Do you want to force applications to
provide chunks of text only in a single language? Or do you want them to
be able to pass a complete text consisting of mutliple lanuages and with
mixed right-to-left and left-to-right and or top-to-bottom directions...
How do you want to handle the actual text shaping? It means that there
will be no longer a one to one mapping of chars to positions. Instead,
multiple chars can be shaped into one, with only a single position.


I have taken some time to read through the book online in order to have
a better understanding of the system internals. I still need to fully
understand a few things. Then I need to read the documentation  of Harfbuzz.

Once you have the the API figured out, you can start actually
implementing. It may be helpful to look at existing use-cases. For
example WebPositive and the WebKit port are the first to need complex
text rendering. What is actually the WebKit code? I believe it renders
chunks that consist only of one language and one direction. So that
would be my aim: Have the application provide the lanugage and direction
information. This needs to be fed into Harfbuzz then (according to the
sample app).

I hope I have given some pointers of what code to look at and how to
approach this. Please just ask if you need to know more. :-)


Fair enough. Thanks


Best regards,
-Stephan



-- 
Be good, be happy and never let the lovely smile on your nice lips fade away
Beatitude Sham; There are the angels of God with their wings spread wide
open all over Sham.
Indeed; when wheedling blandishments prevail, faith dwells in Sham.
Oh God; bestow our Sham with Your blessings.

Other related posts: