Example #1
0
func (s *Font) render32BitChar(
	ch rune, color uint32, x, y int, target gfx.Surface32Bit) {
	if !s.valid(ch) {
		return
	}

	g := s.glyphs[int(ch)-s.startChar]

	x += int(g.xOff)
	y += int(g.yOff)

	tPix := target.Pixels32()

	tRect := target.Bounds()

	for gy := 0; gy <= int(g.y1-g.y0); gy++ {
		tPos := x + (y+gy)*target.Pitch32()
		gPos := (gy+int(g.y0))*s.Pitch() + int(g.x0)

		for gx := 0; gx <= int(g.x1-g.x0); gx++ {
			if s.pixels[gPos+gx] >= 0x80 && image.Pt(x+gx, y+gy).In(tRect) {
				tPix[tPos+gx] = color
			}
		}
	}
}