mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 14:38:19 +00:00
Fast path shaping non-joining chars
This commit is contained in:
@ -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 {
|
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
|
//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
|
//Isolated case
|
||||||
if !prevIsValid && !nextIsValid {
|
if !prevIsValid && !nextIsValid {
|
||||||
g := glyphTable[curr]
|
return glyphTable[curr]
|
||||||
return g
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ri := RuneInfos[curr]
|
ri := RuneInfos[curr]
|
||||||
|
if ri.JoinType == JoiningType_None || ri.JoinType == JoiningType_Transparent {
|
||||||
|
return glyphTable[curr]
|
||||||
|
}
|
||||||
|
|
||||||
prevJoinType := RuneInfos[prev].JoinType
|
prevJoinType := RuneInfos[prev].JoinType
|
||||||
joinWithRight := prevIsValid &&
|
joinWithRight := prevIsValid &&
|
||||||
@ -351,19 +354,6 @@ func GlyphFromRunes(glyphTable map[rune]FontAtlasGlyph, curr, prev, next rune) F
|
|||||||
break
|
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]
|
return glyphTable[curr]
|
||||||
|
|||||||
6
main.go
6
main.go
@ -95,8 +95,8 @@ func (p *program) Init() {
|
|||||||
fmt.Printf("DPI: %f, font size: %d\n", dpi, p.FontSize)
|
fmt.Printf("DPI: %f, font size: %d\n", dpi, p.FontSize)
|
||||||
|
|
||||||
w, h := p.win.SDLWin.GetSize()
|
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/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/alm-fixed.ttf", &truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY, Hinting: hinting}, w, h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Failed to create atlas from font file. Err: " + err.Error())
|
panic("Failed to create atlas from font file. Err: " + err.Error())
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ func (p *program) Update() {
|
|||||||
|
|
||||||
var isDrawingBounds = false
|
var isDrawingBounds = false
|
||||||
var drawManyLines = false
|
var drawManyLines = false
|
||||||
var textToShow = "Hello there يا friend. اسميعمر wow!"
|
var textToShow = "Hello there, friend!"
|
||||||
|
|
||||||
var xOff float32 = 0
|
var xOff float32 = 0
|
||||||
var yOff float32 = 0
|
var yOff float32 = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user