Example_embedFonts shows how one can embed (or not) fonts inside a PDF plot.
()
| 20 | // Example_embedFonts shows how one can embed (or not) fonts inside |
| 21 | // a PDF plot. |
| 22 | func Example_embedFonts() { |
| 23 | p := plot.New() |
| 24 | |
| 25 | pts := plotter.XYs{{X: 0, Y: 0}, {X: 0, Y: 1}, {X: 1, Y: 0}, {X: 1, Y: 1}} |
| 26 | line, err := plotter.NewLine(pts) |
| 27 | if err != nil { |
| 28 | log.Fatalf("could not create line: %v", err) |
| 29 | } |
| 30 | p.Add(line) |
| 31 | p.X.Label.Text = "X axis" |
| 32 | p.Y.Label.Text = "Y axis" |
| 33 | |
| 34 | c := vgpdf.New(100, 100) |
| 35 | |
| 36 | // enable/disable embedding fonts |
| 37 | c.EmbedFonts(true) |
| 38 | p.Draw(draw.New(c)) |
| 39 | |
| 40 | f, err := os.Create("testdata/enable-embedded-fonts.pdf") |
| 41 | if err != nil { |
| 42 | log.Fatal(err) |
| 43 | } |
| 44 | defer f.Close() |
| 45 | |
| 46 | _, err = c.WriteTo(f) |
| 47 | if err != nil { |
| 48 | log.Fatalf("could not write canvas: %v", err) |
| 49 | } |
| 50 | |
| 51 | err = f.Close() |
| 52 | if err != nil { |
| 53 | log.Fatalf("could not save canvas: %v", err) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // Example_multipage shows how one can create a PDF with multiple pages. |
| 58 | func Example_multipage() { |