bring in HarfbuzzShaper into code as a function so we can modify it.

This commit is contained in:
fiatjaf
2023-12-26 19:38:09 -03:00
parent 124dc390d4
commit 9be417fc7c
3 changed files with 151 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"hash/maphash"
"html"
"html/template"
"math/rand"
@@ -12,6 +13,7 @@ import (
"regexp"
"strings"
"time"
"unsafe"
"github.com/microcosm-cc/bluemonday"
"golang.org/x/exp/slices"
@@ -516,3 +518,18 @@ func maxIndex(slice []int) int {
}
return maxIndex
}
// clamp ensures val is in the inclusive range [low,high].
func clamp(val, low, high int) int {
if val < low {
return low
}
if val > high {
return high
}
return val
}
func pointerHasher[V any](_ maphash.Seed, k *V) uint64 {
return uint64(uintptr(unsafe.Pointer(k)))
}