dj.Diagram theme: make the font configurable

Aberta Para iniciantes
#1,539 3 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
76/100
Tipo de issue
Funcionalidade
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python

Direção de pesquisa

Comece em src/datajoint/diagram.py localizando os dois locais atuais de Helvetica e inspecionando _DIAGRAM_THEMES após as reescritas recentes dos diagramas. Adicione a configuração de tema opt-in, preservando Helvetica por padrão, garanta que os dois locais a utilizem e verifique que os diagramas sem override mantenham o layout existente; atualize as orientações sobre fontes para mencionar o opt-in explícito e a ressalva sobre o layout.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Narrowed 2026-09-09. This issue originally carried two theme gaps. The second — reconciling the tier palette with the brand palette — was split into #1543 and shipped in 2.3.3 via #1544. Only the fontname half below remains open. See the closing note for what was decided on the palette.

Amended 2026-09-10. The motivation below originally stated the brand typefaces the wrong way round, and proposed the theme key without acknowledging that diagram themes deliberately do not carry fonts. Both are corrected in place.

Surfaced by putting a dj.Diagram figure through a brand review, where the generated diagram is published in a blog essay. In src/datajoint/diagram.py; it would improve every DataJoint diagram, which is why it belongs here rather than in a post-process downstream.

fontname is hardcoded

node.set_fontname("Helvetica")                      # ~line 1596
fontname="Helvetica",  # schema label in a sans font  ~line 1696

Two hardcoded sites, so a caller who wants a different typeface has no way to ask for it. Proposal: add fontname to _DIAGRAM_THEMES, defaulting to "Helvetica", and read it at both sites. Small and mechanical, and no behavior changes for anyone who does not set it.

Note the line numbers above predate the 2.3.3 diagram work (#1534, #1544, #1545), which rewrote much of this file — locate the two Helvetica sites rather than trusting them.

Why the default has to stay Helvetica

Graphviz sizes node boxes using the face it actually finds on the machine doing the rendering. A fontname the environment lacks does not fall back gracefully: it changes text metrics, and therefore node dimensions and layout. That is why the shipped themes change colors only, never fonts, and why this proposal is opt-in rather than a new default.

It also means the two mechanisms are not interchangeable:

  • Setting fontname affects layout. It is correct only where the caller controls the rendering environment and knows the face is installed.
  • Restyling the emitted SVG — applying a CSS font-family stack to an inlined SVG — is display-only and cannot disturb layout, provided the substitute is metrically close to Helvetica. For DataJoint-controlled surfaces publishing a figure, this remains the safer route, and it is what docs and published figures use today.

So this issue asks for a caller-controlled escape hatch, not a replacement for SVG restyling. If the theme key lands, the guidance that themes do not change fonts needs amending to say "except by explicit opt-in, with the layout caveat above."

Motivation

DataJoint brand typography assigns Roboto to titles and headings, Roboto Slab to body and paragraphs, and Source Code Pro to code. Diagram node and cluster labels are body-tier text rather than headings, so a brand-aligned caller would set Roboto Slab — not Roboto. Whether Roboto Slab is the right weight for a short label inside a shape is a separate question: the weight is specified against continuous prose, and a diagram label is neither prose nor a heading.

Stating this because the earlier text had the two faces reversed, and a fontname default chosen from it would have pointed at the wrong face.

Not proposed

Per-table icons appear in hand-designed versions of the same figure (a person for Subject, a test tube for Sample, and so on). They read well, but nothing in a schema derives them — they would need a hand-maintained table→icon map, which reintroduces exactly the drift that generating the figure exists to prevent. Better left to hand-made cover art.

Monospace labels. Table names are code identifiers, but diagram text is proportional by design: a docs diagram should look like the one the reader just generated locally. Source Code Pro does not belong in a diagram, whatever fontname allows.

Linguagem predominante
Python
Estrelas
197
Forks
98
Merge médio
6d 10h
PRs com merge (30d)
4

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de datajoint/datajoint-python

Todas as issues de datajoint/datajoint-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.