kerning for the pairs such as Pr,Fu,Fo,etc

This commit is contained in:
minjaesong
2021-11-20 18:36:45 +09:00
parent f43a81de3f
commit ab2669b555
3 changed files with 23 additions and 16 deletions

BIN
demo.PNG

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 142 KiB

View File

@@ -5,11 +5,11 @@
### Legends ### Legends
# #
# ͞ A·B < unset for lowheight miniscules, as in e # A·B < unset for lowheight miniscules, as in e
# |·| < space we don't care # |·| < space we don't care
#――C·D < middle hole for majuscules, as in C # C·D < middle hole for majuscules, as in C
# E·F < middle hole for miniscules, as in c # E·F < middle hole for miniscules, as in c
# ͟ G·H # G·H
# ――― < baseline # ――― < baseline
# |·| # |·|
# J·K # J·K
@@ -61,12 +61,14 @@
# ` must have a bit unset # ` must have a bit unset
- ͟A͟B͟C͟D͟E͟F͟G͟H͟J͟K͟ ͟ ͟ ͟A͟B͟C͟D͟E͟F͟G͟H͟J͟K͟ - ͟A͟B͟C͟D͟E͟F͟G͟H͟J͟K͟ ͟ ͟ ͟A͟B͟C͟D͟E͟F͟G͟H͟J͟K͟
- _@_`___`__ — `_________ # Γe,TJ ; Ye,YJ,Ve,VJ,TA,ΓA,VA,Vʌ,YA,Yʌ,yA,yʌ,/a,/d - _@_`___`__ — `_________ # Γe,TJ ; Ye,YJ,Ve,VJ,TA,ΓA,VA,Vʌ,YA,Yʌ,yA,yʌ,/a,/d
- _@_@___`__ — `___`_@___ # Pɺ but NOT PJ - _@_@___`__ — `___`_@___ # Pɺ but NOT Po,PJ
- _@_@___`__ — `___@_____ # Fo,PJ (always 1 px)
- ___`_`____ — `___@_`___ # Cꟶ,Kꟶ,Lꟶ,Γꟶ - ___`_`____ — `___@_`___ # Cꟶ,Kꟶ,Lꟶ,Γꟶ
- ___`_`____ — `_@___`___ # CꟵ,KꟵ,LꟵ,ΓꟵ - ___`_`____ — `_@___`___ # CꟵ,KꟵ,LꟵ,ΓꟵ
----------------------------------------------------- -----------------------------------------------------
- _`________ — @_`___`___ # eꞀ,LT ; eY,LY,eV,LV,AT,AꞀ,AY,Ay,λY,λy,a\,b\ - _`________ — @_`___`___ # eꞀ,LT ; eY,LY,eV,LV,AT,AꞀ,AY,Ay,λY,λy,a\,b\
- _`___`_@__ — @_@___`___ # Lꟼ but NOT bꟼ - _`___`_@__ — @_@___`___ # Lꟼ but NOT oꟼ,bꟼ
- _`___@____ — @_@___`___ # oꟼ,bꟼ (always 1 px)
- _`___@_`__ — __`_`_____ # ⱶƆ,ⱶJ - _`___@_`__ — __`_`_____ # ⱶƆ,ⱶJ
- _`_@___`__ — __`_`_____ # ⱵƆ,ⱵJ - _`_@___`__ — __`_`_____ # ⱵƆ,ⱵJ

View File

@@ -1359,12 +1359,13 @@ class TerrarumSansBitmap(
val maskL = glyphProps[prevChar]?.kerningMask val maskL = glyphProps[prevChar]?.kerningMask
val maskR = glyphProps[thisChar]?.kerningMask val maskR = glyphProps[thisChar]?.kerningMask
return if (glyphProps[prevChar]?.hasKernData == true && glyphProps[thisChar]?.hasKernData == true) { return if (glyphProps[prevChar]?.hasKernData == true && glyphProps[thisChar]?.hasKernData == true) {
val contraction = if (glyphProps[prevChar]?.isKernYtype == true || glyphProps[thisChar]?.isKernYtype == true) -1 else -2
kerningRules.forEachIndexed { index, it -> kerningRules.forEachIndexed { index, it ->
if (it.first.matches(maskL!!) && it.second.matches(maskR!!)) { if (it.first.matches(maskL!!) && it.second.matches(maskR!!)) {
println("Kerning rule match #${index+1}: ${prevChar.toChar()}${thisChar.toChar()}, Rule:${it.first} ${it.second}; Contraction: ${-contraction}") val contraction = if (glyphProps[prevChar]?.isKernYtype == true || glyphProps[thisChar]?.isKernYtype == true) it.yy else it.bb
return contraction println("Kerning rule match #${index+1}: ${prevChar.toChar()}${thisChar.toChar()}, Rule:${it.first} ${it.second}; Contraction: $contraction")
return -contraction
} }
} }
return 0 return 0
@@ -1951,6 +1952,8 @@ print(','.join(a))
override fun toString() = "C:${careBits.toString(2).padStart(16,'0')}-R:${ruleBits.toString(2).padStart(16,'0')}" override fun toString() = "C:${careBits.toString(2).padStart(16,'0')}-R:${ruleBits.toString(2).padStart(16,'0')}"
} }
private data class Kern(val first: RuleMask, val second: RuleMask, val bb: Int = 2, val yy: Int = 1)
/** /**
* Legend: _ dont care * Legend: _ dont care
* @ must have a bit set * @ must have a bit set
@@ -1967,15 +1970,17 @@ print(','.join(a))
* J·K * J·K
*/ */
private val kerningRules = arrayOf( private val kerningRules = arrayOf(
RuleMask("_@_`___`__") to RuleMask("`_________"), Kern(RuleMask("_@_`___`__"),RuleMask("`_________")),
RuleMask("_@_@___`__") to RuleMask("`___`_@___"), Kern(RuleMask("_@_@___`__"),RuleMask("`___`_@___")),
RuleMask("___`_`____") to RuleMask("`___@_`___"), Kern(RuleMask("_@_@___`__"),RuleMask("`___@_____"),1,1),
RuleMask("___`_`____") to RuleMask("`_@___`___"), Kern(RuleMask("___`_`____"),RuleMask("`___@_`___")),
Kern(RuleMask("___`_`____"),RuleMask("`_@___`___")),
RuleMask("_`________") to RuleMask("@_`___`___"), Kern(RuleMask("_`________"),RuleMask("@_`___`___")),
RuleMask("_`___`_@__") to RuleMask("@_@___`___"), Kern(RuleMask("_`___`_@__"),RuleMask("@_@___`___")),
RuleMask("_`___@_`__") to RuleMask("__`_`_____"), Kern(RuleMask("_`___@____"),RuleMask("@_@___`___"),1,1),
RuleMask("_`_@___`__") to RuleMask("__`_`_____"), Kern(RuleMask("_`___@_`__"),RuleMask("__`_`_____")),
Kern(RuleMask("_`_@___`__"),RuleMask("__`_`_____")),
) )
// End of the Keming Machine // End of the Keming Machine