Wish Add support for kerning in BCTextEngine / BBCodeView

Sandman

Well-Known Member
Licensed User
This is regarding:
[B4X] BCTextEngine / BBCodeView - Text engine + BBCode parser + Rich Text View
https://www.b4x.com/android/forum/t...t-engine-bbcode-parser-rich-text-view.106207/

With BBCodeView, text is the king.
Kerning is currently not supported.
Examples showing bad kerning, taken from that thread:

1578652520094.png


1578652551900.png


I am very fond of BCTextEngine / BBCodeView, but I'm finding it very difficult to use it due to the lack of kerning, which makes the text look inferior to other text we have in our devices. So my wish is to add kerning to BCTextEngine / BBCodeView.

A thought about a potential solution
I have full respect for this potentially being a complex thing to add (working with typography and fonts can be quite mind-melting). My naïve view of this is that currently each character is rendered in a buffer, measured using a bounding box and then placed onto the resulting image. (I really don't know if this is how it's done, it's just my best guess, but I'll go ahead and assume it's not completely wrong.) This works fine to get a character shape, but it doesn't take the actual kerning tables (that are built into the font itself) into account. To my knowledge there is no way to directly access the values in those tables unless you use a font editor, which we don't want to do. However, if we instead would render a whole word off-screen, that would automatically (I think) use the kerning tables. This word could then be measured using the bounding box and be placed onto the resulting image. We would get small inconsistencies with how the characters connect to the surrounding spaces and delimiters, but that should be a lot less noticable. I'm not sure if this helps or not, but I thought it couldn't hurt to mention it - if it works it might make for a solution that doesn't involve soul-crushing pain.

(For the people unsure what kerning is, I recommend reading Learning the basics of kerning and perhaps the Wikipedia page about Kerning. Here is an image from the first link to illustrate
1578654552109.png


I'm also aware that some people really just can't see problematic or missing kerning very well. That's fine, but some of us are very aware of it, and find bad/missing kerning very painful on the eye.)
 

Sandman

Well-Known Member
Licensed User
I do plan to add support for kerning at some point.
Thank you very much. (And, like I said, I do realize that this probably is painful to do.)

The screenshots you posted are from B4J. It does look better on Android and iOS devices.
I wasn't aware, thanks for mentioning it. I'll try to make some tests the upcoming week and post back images to this thread, for completeness.
 

Erel

Administrator
Staff member
Licensed User
'll try to make some tests the upcoming week and post back images to this thread
Screenshots are important however a better test is to run the B4A example on a real phone and feel whether it is noticeable and to what level. It is noticeable in some edge cases, however I don't think that it is critical or a showstopper.
 

Sandman

Well-Known Member
Licensed User
Agreed, real-life tests are hard to beat. Anyway, I'll use my most friendly eye when looking at it - I really do want to use this lib.

The screenshots you posted are from B4J. It does look better on Android and iOS devices.
It's not really important or anything, but do you know why B4J (which probably means Java or perhaps JavaFX?) produces somewhat inferior font rendering? Just curious.
 
Top