Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make FontFace's Glyphs Method Public #329

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/pdftext/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"time"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
"github.com/tdewolff/minify/v2"
)

Expand Down
4 changes: 2 additions & 2 deletions examples/amsterdam-centre/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/paulmach/osm"
"github.com/paulmach/osm/osmapi"
"github.com/paulmach/osm/osmgeojson"
"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/co2-mauna-loa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"os"
"strconv"

"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers"
)

var fontFamily *canvas.FontFamily
Expand Down
4 changes: 2 additions & 2 deletions examples/fyne/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"github.com/tdewolff/canvas"
canvasFyne "github.com/tdewolff/canvas/renderers/fyne"
"github.com/Seanld/canvas"
canvasFyne "github.com/Seanld/canvas/renderers/fyne"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/go-chart/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"time"

"github.com/golang/freetype/truetype"
"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers"
"github.com/wcharczuk/go-chart/v2"
"github.com/wcharczuk/go-chart/v2/drawing"
)
Expand Down
4 changes: 2 additions & 2 deletions examples/gonum-plot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"log"

"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
Expand Down
4 changes: 2 additions & 2 deletions examples/html-canvas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package main
import (
"syscall/js"

"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers/htmlcanvas"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers/htmlcanvas"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/opengl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/go-gl/gl/v3.3-core/gl"
"github.com/go-gl/glfw/v3.3/glfw"
"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers/opengl"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers/opengl"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/tex/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"os"

"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers/tex"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers/tex"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/text-document/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"time"

"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers/pdf"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers/pdf"
)

var fontLatin *canvas.FontFamily
Expand Down
14 changes: 8 additions & 6 deletions font.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"reflect"
"sync"

"github.com/tdewolff/canvas/text"
"github.com/Seanld/canvas/text"
"github.com/tdewolff/font"
)

Expand Down Expand Up @@ -693,11 +693,14 @@ func (face *FontFace) LineHeight() float64 {
return metrics.Ascent + metrics.Descent
}

func (face *FontFace) Glyphs(s string) []text.Glyph {
ppem := face.PPEM(DefaultResolution)
return face.Font.shaper.Shape(s, ppem, face.Direction, face.Script, face.Language, face.Font.features, face.Font.variations)
}

// TextWidth returns the width of a given string in millimeters.
func (face *FontFace) TextWidth(s string) float64 {
ppem := face.PPEM(DefaultResolution)
glyphs := face.Font.shaper.Shape(s, ppem, face.Direction, face.Script, face.Language, face.Font.features, face.Font.variations)
return face.textWidth(glyphs)
return face.textWidth(face.Glyphs(s))
}

func (face *FontFace) textWidth(glyphs []text.Glyph) float64 {
Expand Down Expand Up @@ -740,8 +743,7 @@ func (face *FontFace) Decorate(width float64) *Path {
// ToPath converts a string to its glyph paths.
func (face *FontFace) ToPath(s string) (*Path, float64, error) {
ppem := face.PPEM(DefaultResolution)
glyphs := face.Font.shaper.Shape(s, ppem, face.Direction, face.Script, face.Language, face.Font.features, face.Font.variations)
return face.toPath(glyphs, ppem)
return face.toPath(face.Glyphs(s), ppem)
}

func (face *FontFace) toPath(glyphs []text.Glyph, ppem uint16) (*Path, float64, error) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/tdewolff/canvas
module github.com/Seanld/canvas

go 1.22.0

Expand Down
2 changes: 1 addition & 1 deletion preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"
"runtime"

"github.com/tdewolff/canvas/text"
"github.com/Seanld/canvas/text"
)

func loadFont(name string, style FontStyle) ([]byte, error) {
Expand Down
4 changes: 2 additions & 2 deletions renderers/fyne/fyne.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package fyne
import (
"fyne.io/fyne/v2"
fyneCanvas "fyne.io/fyne/v2/canvas"
"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers/rasterizer"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers/rasterizer"
)

type Fyne struct {
Expand Down
2 changes: 1 addition & 1 deletion renderers/gochart.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"math"

"github.com/golang/freetype/truetype"
"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
"github.com/tdewolff/font"
"github.com/wcharczuk/go-chart/v2"
"github.com/wcharczuk/go-chart/v2/drawing"
Expand Down
2 changes: 1 addition & 1 deletion renderers/gonumplot.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"image/color"
"math"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
canvasFont "github.com/tdewolff/font"
"golang.org/x/image/font"
gonumFont "gonum.org/v1/plot/font"
Expand Down
2 changes: 1 addition & 1 deletion renderers/htmlcanvas/htmlcanvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"math"
"syscall/js"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
)

// HTMLCanvas is an HTMLCanvas renderer.
Expand Down
4 changes: 2 additions & 2 deletions renderers/opengl/opengl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strings"

"github.com/go-gl/gl/v3.3-core/gl"
"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers/rasterizer"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers/rasterizer"
)

// OpenGL is an open graphics library renderer.
Expand Down
2 changes: 1 addition & 1 deletion renderers/pdf/pdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"math"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
)

type Options struct {
Expand Down
2 changes: 1 addition & 1 deletion renderers/pdf/pdf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
"github.com/tdewolff/test"
)

Expand Down
2 changes: 1 addition & 1 deletion renderers/pdf/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"math"
"strings"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
"github.com/tdewolff/minify/v2"
)

Expand Down
4 changes: 2 additions & 2 deletions renderers/pdf/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"time"
"unicode/utf16"

"github.com/tdewolff/canvas"
canvasText "github.com/tdewolff/canvas/text"
"github.com/Seanld/canvas"
canvasText "github.com/Seanld/canvas/text"
canvasFont "github.com/tdewolff/font"
"golang.org/x/text/encoding/charmap"
)
Expand Down
2 changes: 1 addition & 1 deletion renderers/ps/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"time"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
"github.com/tdewolff/minify/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion renderers/ps/ps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"testing"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
)

func TestPS(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion renderers/rasterizer/rasterizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"image"
"math"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
"golang.org/x/image/draw"
"golang.org/x/image/math/f64"
"golang.org/x/image/vector"
Expand Down
2 changes: 1 addition & 1 deletion renderers/rasterizer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"image"
"image/color"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
"golang.org/x/image/draw"
)

Expand Down
12 changes: 6 additions & 6 deletions renderers/renderers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"path/filepath"
"strings"

"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers/pdf"
"github.com/tdewolff/canvas/renderers/ps"
"github.com/tdewolff/canvas/renderers/rasterizer"
"github.com/tdewolff/canvas/renderers/svg"
"github.com/tdewolff/canvas/renderers/tex"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers/pdf"
"github.com/Seanld/canvas/renderers/ps"
"github.com/Seanld/canvas/renderers/rasterizer"
"github.com/Seanld/canvas/renderers/svg"
"github.com/Seanld/canvas/renderers/tex"
"golang.org/x/image/bmp"
"golang.org/x/image/tiff"
)
Expand Down
4 changes: 2 additions & 2 deletions renderers/renderers_formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/Kagami/go-avif"
webp "github.com/kolesa-team/go-webp/encoder"
"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers/rasterizer"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers/rasterizer"
)

func WebP(opts ...interface{}) canvas.Writer {
Expand Down
2 changes: 1 addition & 1 deletion renderers/renderers_noformats.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package renderers
import (
"fmt"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
)

// WebP returns a Webp writer that uses libwebp and accepts the following options: canvas.Resolution, canvas.Colorspace, github.com/kolesa-team/go-webp/encoder.*Options
Expand Down
4 changes: 2 additions & 2 deletions renderers/svg/svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"math"
"strings"

"github.com/tdewolff/canvas"
canvasText "github.com/tdewolff/canvas/text"
"github.com/Seanld/canvas"
canvasText "github.com/Seanld/canvas/text"
"github.com/tdewolff/font"
)

Expand Down
2 changes: 1 addition & 1 deletion renderers/svg/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"math"
"strings"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
"github.com/tdewolff/minify/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion renderers/tex/tex.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"
"math"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
)

// TeX is a TeX/PGF renderer. Be aware that TeX/PGF does not support transparency of colors.
Expand Down
2 changes: 1 addition & 1 deletion renderers/tex/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"math"
"strings"

"github.com/tdewolff/canvas"
"github.com/Seanld/canvas"
"github.com/tdewolff/minify/v2"
)

Expand Down
4 changes: 2 additions & 2 deletions resources/boolean/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers"
)

var font *canvas.FontFamily
Expand Down
4 changes: 2 additions & 2 deletions resources/docs/boolean/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers"
)

var font *canvas.FontFamily
Expand Down
4 changes: 2 additions & 2 deletions resources/docs/colors/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"math"
"sort"

"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/renderers"
"github.com/Seanld/canvas"
"github.com/Seanld/canvas/renderers"
)

func hue(col color.RGBA) float64 {
Expand Down
Loading
Loading