mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-03-07 11:51:50 +09:00
kerning for the pairs such as Pr,Fu,Fo,etc
This commit is contained in:
BIN
demo.PNG
BIN
demo.PNG
Binary file not shown.
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 142 KiB |
@@ -5,11 +5,11 @@
|
||||
|
||||
### Legends
|
||||
#
|
||||
# ͞ A·B < unset for lowheight miniscules, as in e
|
||||
# A·B < unset for lowheight miniscules, as in e
|
||||
# |·| < 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
|
||||
# ͟ G·H
|
||||
# G·H
|
||||
# ――― < baseline
|
||||
# |·|
|
||||
# J·K
|
||||
@@ -61,12 +61,14 @@
|
||||
# ` 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͟
|
||||
- _@_`___`__ — `_________ # Γ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Ꟶ,ΓꟵ
|
||||
-----------------------------------------------------
|
||||
- _`________ — @_`___`___ # 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
|
||||
|
||||
|
||||
@@ -1359,12 +1359,13 @@ class TerrarumSansBitmap(
|
||||
val maskL = glyphProps[prevChar]?.kerningMask
|
||||
val maskR = glyphProps[thisChar]?.kerningMask
|
||||
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 ->
|
||||
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
|
||||
@@ -1951,6 +1952,8 @@ print(','.join(a))
|
||||
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
|
||||
* @ must have a bit set
|
||||
@@ -1967,15 +1970,17 @@ print(','.join(a))
|
||||
* J·K
|
||||
*/
|
||||
private val kerningRules = arrayOf(
|
||||
RuleMask("_@_`___`__") to RuleMask("`_________"),
|
||||
RuleMask("_@_@___`__") to RuleMask("`___`_@___"),
|
||||
RuleMask("___`_`____") to RuleMask("`___@_`___"),
|
||||
RuleMask("___`_`____") to RuleMask("`_@___`___"),
|
||||
Kern(RuleMask("_@_`___`__"),RuleMask("`_________")),
|
||||
Kern(RuleMask("_@_@___`__"),RuleMask("`___`_@___")),
|
||||
Kern(RuleMask("_@_@___`__"),RuleMask("`___@_____"),1,1),
|
||||
Kern(RuleMask("___`_`____"),RuleMask("`___@_`___")),
|
||||
Kern(RuleMask("___`_`____"),RuleMask("`_@___`___")),
|
||||
|
||||
RuleMask("_`________") to RuleMask("@_`___`___"),
|
||||
RuleMask("_`___`_@__") to RuleMask("@_@___`___"),
|
||||
RuleMask("_`___@_`__") to RuleMask("__`_`_____"),
|
||||
RuleMask("_`_@___`__") to RuleMask("__`_`_____"),
|
||||
Kern(RuleMask("_`________"),RuleMask("@_`___`___")),
|
||||
Kern(RuleMask("_`___`_@__"),RuleMask("@_@___`___")),
|
||||
Kern(RuleMask("_`___@____"),RuleMask("@_@___`___"),1,1),
|
||||
Kern(RuleMask("_`___@_`__"),RuleMask("__`_`_____")),
|
||||
Kern(RuleMask("_`_@___`__"),RuleMask("__`_`_____")),
|
||||
)
|
||||
|
||||
// End of the Keming Machine
|
||||
|
||||
Reference in New Issue
Block a user