Support for languages using Diacritics as multi-codepoint joiners (#11806)

* Diacritics support - achieving 1-Char-Per-Glyph via a fake alphabet

* Diacritics support - Redesign state engine and polishing

* Diacritics support - Unit test

* Diacritics support - Expand unit test to cover more cases

* Diacritics support - Expand unit test to cover more cases

* Clarify a function name

* Change format of diacritic definitions

* Refactor DiacriticSupport to per-language class with statics in Companion

* Update DiacriticSupport to use CharCategory and enable support of surrogate pairs

* Documentation
This commit is contained in:
SomeTroglodyte
2024-06-29 22:39:46 +02:00
committed by GitHub
parent 0f2a697ba6
commit b5622df92d
10 changed files with 432 additions and 32 deletions

View File

@ -61,8 +61,12 @@ class DesktopFont : FontImplementation {
return font.size
}
override fun getCharPixmap(char: Char): Pixmap {
var width = metric.charWidth(char)
override fun getCharPixmap(char: Char) = getCharPixmapCommon(char.toString(), metric.charWidth(char))
override fun getCharPixmap(symbolString: String) = getCharPixmapCommon(symbolString, metric.stringWidth(symbolString))
private fun getCharPixmapCommon(symbolString: String, measuredWidth: Int): Pixmap {
var width = measuredWidth
var height = metric.height
if (width == 0) {
// This happens e.g. for the Tab character
@ -75,7 +79,7 @@ class DesktopFont : FontImplementation {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
g.font = font
g.color = Color.WHITE
g.drawString(char.toString(), 0, metric.leading + metric.ascent)
g.drawString(symbolString, 0, metric.leading + metric.ascent)
val pixmap = Pixmap(bi.width, bi.height, Pixmap.Format.RGBA8888)
val data = bi.getRGB(0, 0, bi.width, bi.height, null, 0, bi.width)