Fast path shaping non-joining chars

This commit is contained in:
bloeys
2022-07-11 11:29:12 +04:00
parent 851387d6d8
commit 38dafbfd65
2 changed files with 8 additions and 18 deletions

View File

@ -270,6 +270,7 @@ func (gr *GlyphRend) GetTextRuns(t string, textRunsBuf *[]TextRun) {
}
}
//GlyphFromRunes does shaping where it selects the proper rune based (e.g. end Alef) on the surrounding runes
func GlyphFromRunes(glyphTable map[rune]FontAtlasGlyph, curr, prev, next rune) FontAtlasGlyph {
//PERF: Map access times are absolute garbage to the point that ~85%+ of the runtime of this func
@ -287,11 +288,13 @@ func GlyphFromRunes(glyphTable map[rune]FontAtlasGlyph, curr, prev, next rune) F
//Isolated case
if !prevIsValid && !nextIsValid {
g := glyphTable[curr]
return g
return glyphTable[curr]
}
ri := RuneInfos[curr]
if ri.JoinType == JoiningType_None || ri.JoinType == JoiningType_Transparent {
return glyphTable[curr]
}
prevJoinType := RuneInfos[prev].JoinType
joinWithRight := prevIsValid &&
@ -351,19 +354,6 @@ func GlyphFromRunes(glyphTable map[rune]FontAtlasGlyph, curr, prev, next rune) F
break
}
}
case PosCtx_isolated:
// equivRunes := RuneInfos[curr].EquivalentRunes
// for i := 0; i < len(equivRunes); i++ {
// otherRune := equivRunes[i]
// otherRuneInfo := RuneInfos[otherRune]
// if otherRuneInfo.DecompTag == DecompTag_isolated {
// curr = otherRune
// break
// }
// }
}
return glyphTable[curr]

View File

@ -95,8 +95,8 @@ func (p *program) Init() {
fmt.Printf("DPI: %f, font size: %d\n", dpi, p.FontSize)
w, h := p.win.SDLWin.GetSize()
p.GlyphRend, err = glyphs.NewGlyphRend("./res/fonts/tajawal-regular-var.ttf", &truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY, Hinting: hinting}, w, h)
// p.GlyphRend, err = glyphs.NewGlyphRend("./res/fonts/alm-fixed.ttf", &truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY, Hinting: hinting}, w, h)
// p.GlyphRend, err = glyphs.NewGlyphRend("./res/fonts/tajawal-regular-var.ttf", &truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY, Hinting: hinting}, w, h)
p.GlyphRend, err = glyphs.NewGlyphRend("./res/fonts/alm-fixed.ttf", &truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY, Hinting: hinting}, w, h)
if err != nil {
panic("Failed to create atlas from font file. Err: " + err.Error())
}
@ -194,7 +194,7 @@ func (p *program) Update() {
var isDrawingBounds = false
var drawManyLines = false
var textToShow = "Hello there يا friend. اسميعمر wow!"
var textToShow = "Hello there, friend!"
var xOff float32 = 0
var yOff float32 = 0