robsch
robsch

Reputation: 9728

How does LIGATURES work in java/awt/font/TextAttribute?

I don't understand why those LIGATURES can be turned on and off? What should happen if there is a string containing ? I would think a string contains a ligature or not. Same is with used font. So what does it mean that ligature can be turned off?

Upvotes: 1

Views: 455

Answers (1)

A ligature in font land is a technical term meaning "a replacement when rendering of two or more codepoints in the data with an alternate shape" and is one of the ways in which fonts can perform automatic substitutions (other examples are full word substitutions, or positional substitutions which are important in for instance Arabic, where a letter is drawn differently depending on where in a word it is written).

Having string data that contains the single unicode "character" and then seeing that same thing rendered by the font you're using is not seeing a ligature; The data and the rendered form are the same, so what you're seeing is functionally identical to having an "a" in your data, and seeing that same "a" rendered by the font.

However, if your data contains the multiple letters fi (two letters) or ffl (three letters) and the font turns that into the single glyphs or respectively, then those are ligatures: what's in the data and what gets rendered are different. So it is that behaviour that you can turn on or off:

"Should the font be allowed to perform replacements in my data based on what the type designers for that font thought looks better, or should it render my data exactly, without ligature substitutions?"

Upvotes: 2

Related Questions