From 7e465e47e20b358e0b01e0a7f8adc7b09d4c8d12 Mon Sep 17 00:00:00 2001 From: Per Hultqvist Date: Sun, 10 Nov 2024 16:17:45 +0100 Subject: [PATCH] New example (small change): text/codepoints_loading --- examples/text/codepoints_loading/main.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/examples/text/codepoints_loading/main.go b/examples/text/codepoints_loading/main.go index 8e78a4a..c55fc9c 100644 --- a/examples/text/codepoints_loading/main.go +++ b/examples/text/codepoints_loading/main.go @@ -14,6 +14,7 @@ package main import ( "fmt" + "slices" rl "github.com/gen2brain/raylib-go/raylib" ) @@ -35,7 +36,8 @@ func main() { allCodepoints := []rune(text) // Removed duplicate codepoints to generate smaller font atlas - codepoints := CodepointRemoveDuplicates(allCodepoints) + slices.Sort(allCodepoints) + codepoints := slices.Compact(allCodepoints) codepointsCount := len(codepoints) // Load font containing all the provided codepoint glyphs @@ -91,18 +93,3 @@ func main() { rl.UnloadFont(font) // Unload font rl.CloseWindow() // Close window and OpenGL context } - -// CodepointRemoveDuplicates removes codepoint duplicates if requested -func CodepointRemoveDuplicates[T comparable](sliceList []T) []T { - allKeys := make(map[T]bool) - var list []T - - for _, item := range sliceList { - if _, value := allKeys[item]; !value { - allKeys[item] = true - list = append(list, item) - } - } - - return list -}