Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

plot: Changing the default font for plots is unintuitive and/or not possible

Aperta
#702 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
go

Direzione di ricerca

Inizia tracciando plot.DefaultFont e la gestione dei font attorno a vg.FontDirs e vg.MakeFont(), quindi esamina la mappatura dei caratteri tipografici del renderer SVG. Riproduci l’esempio Arial e segui i fallimenti attraverso il calcolo dell’estensione del font e l’output SVG. Il lavoro sarà completo quando un font predefinito configurato non causerà più un panic e i caratteri tipografici non supportati produrranno un risultato chiaro.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What are you trying to do?

Render a plot to SVG with a certain font as a default for title and axis

What did you do?
plot.DefaultFont = font.Font{Typeface: "Arial"}
p := plot.New()
err := plotutil.AddLinePoints(p, ...)
...
err = p.Save(4*vg.Inch, 4*vg.Inch, "plot.svg")
...
What did you expect to happen?

That all labels in the plot use the Arial font.

What actually happened?

Rending the plot panic'ed, because Font objects are used unchecked in places using Extent().

It is not clear at all, what fonts can even be used for plot.DefaultFont and that it needs to happen before calling plot.New(). Digging through the code reveals there was a built-in map, which is currently being removed.

It is possible to load a custom font such as Arial, by extending the vg.FontDirs global. In addition, the default font cache needs to be manually extended with a mapping for "Arial" to a font object loaded via vg.MakeFont().

However, this will still fail later in the SVG renderer, because it has a hard-coded mapping of typefaces to CSS style strings. This mapping cannot currently be extended. If a font is not part of this mapping, it will at least throw a proper error.

What version of Go and Gonum/plot are you using?

From go.sum, it looks like I am using v0.9.0.

Does this issue reproduce with the current master?

No idea.

Lingua principale
Go
Stelle
3k
Fork
202
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di gonum/plot

Tutte le issue di gonum/plot

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.