[HarfBuzz] Detecting mandatory ligatures
khaledhosny at eglug.org
Mon Apr 4 19:45:40 UTC 2016
On Tue, Mar 22, 2016 at 10:52:43PM +0000, Jamie Dale wrote:
> Hey all,
> I've spent today fixing some issues in our editable text controls, mostly
> relating to issues caused by the difference between characters and grapheme
> I've sorted most of my issues now, but I'm still having an issue the لا
> ligature in Arabic.
> My current code that performs picking on text, or applies formatting to
> text that spans a ligature, assumes that any ligature can be split into its
> component grapheme clusters, however this assumption does not hold true for
> that ligature as it cannot be split.
> Does HarfBuzz have a way to identify these mandatory ligatures, or failing
> that, how do people generally deal with this sort of thing? I have ICU
> available if it has anything that can help?
You just don’t try to identify mandatory ligatures. What we are doing in
Scribus (that bit of code is not published yet) is to treat all
ligatures as unbreakable. You simply find how many characters in a
ligature, distribute the width on them and find the width of the
selected part, draw the selection rectangle then render the ligature
twice once with the highlight color clipped to the width of the selected
area and once with the regular color clipped to the rest of the glyph
width. You can try to use hb_ot_layout_get_ligature_carets() to get
better positions than simply distributing the width over the number of
components, but very few fonts support it and you will need a fallback
I believe this is essentially what Firefox does as well.
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
More information about the HarfBuzz