diff --git a/text/v2/gotext.go b/text/v2/gotext.go index 1eb82dbd7..331996dc1 100644 --- a/text/v2/gotext.go +++ b/text/v2/gotext.go @@ -202,11 +202,6 @@ func (g *GoTextFace) Metrics() Metrics { return m } -// UnsafeInternal implements Face. -func (g *GoTextFace) UnsafeInternal() any { - return g.Source.f -} - func (g *GoTextFace) ensureVariationsString() string { if g.variationsString != "" { return g.variationsString diff --git a/text/v2/gotextfacesource.go b/text/v2/gotextfacesource.go index 8210d3460..59c428c26 100644 --- a/text/v2/gotextfacesource.go +++ b/text/v2/gotextfacesource.go @@ -157,6 +157,13 @@ func (g *GoTextFaceSource) Metadata() Metadata { return g.metadata } +// UnsafeInternal returns its font.Face. +// +// This is unsafe since this might make internal cache states out of sync. +func (g *GoTextFaceSource) UnsafeInternal() font.Face { + return g.f +} + func (g *GoTextFaceSource) shape(text string, face *GoTextFace) (shaping.Output, []glyph) { g.copyCheck() diff --git a/text/v2/std.go b/text/v2/std.go index b687255b3..0921a18b6 100644 --- a/text/v2/std.go +++ b/text/v2/std.go @@ -74,8 +74,10 @@ func (s *StdFace) Metrics() Metrics { } } -// UnsafeInternal implements Face. -func (s *StdFace) UnsafeInternal() any { +// UnsafeInternal returns its internal font.Face. +// +// This is unsafe since this might make internal cache states out of sync. +func (s *StdFace) UnsafeInternal() font.Face { s.copyCheck() return s.f.f } diff --git a/text/v2/text.go b/text/v2/text.go index d7aa4c754..d0bee7cbd 100644 --- a/text/v2/text.go +++ b/text/v2/text.go @@ -32,11 +32,6 @@ type Face interface { // Metrics returns the metrics for this Face. Metrics() Metrics - // UnsafeInternal returns the internal object for this face. - // The returned value is either a semi-standard font.Face or go-text's font.Face. - // This is unsafe since this might make internal cache states out of sync. - UnsafeInternal() any - advance(text string) float64 appendGlyphsForLine(glyphs []Glyph, line string, indexOffset int, originX, originY float64) []Glyph