PreFigure label fonts

12 views
Skip to first unread message

Andrew Scholer

unread,
Sep 24, 2025, 4:50:18 PM (3 days ago) Sep 24
to prete...@googlegroups.com
A few questions related to fonts for labels in PreFrigure diagrams:

1) The text elements written for labels include `font-family="sans"`, which ironically seems to cause the text to be rendered in a serif font (at least on any system that lacks a font named "sans"). Is the intent of the code that produces that attribute to set the family to "sans-serif"?

2) I am exploring using PreFigure for rendering some memory diagrams for CS. For those I would love to specify a monospace font (ideally, one that matches the font family used for code on a PreTeXt page). Has there been any thought about allowing a few choices for label font family? (I'm not advocating for people specifying Papyrus in their diagrams, but serif/sans/mono all feel like they have a place in rendering a diagram that fits the surrounding context.)  

Andrew Scholer
Computer Science Instructor / Program Chair
Chemeketa Community College
Office hour info: https://computerscience.chemeketa.edu/people/andrew-scholer/

David Austin

unread,
Sep 24, 2025, 5:21:00 PM (3 days ago) Sep 24
to prete...@googlegroups.com
Yes, there has definitely been some thought, and even a small amount of action, on this issue so it shouldn't be too much work to implement.  What about an attribute on a label, such as font="...", with a limited range of accepted values that are passed directly into the SVG?  What would you like to see?

David



--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/CACm44N_XYUHt4Y590hWzzkzr-ROGGD5FnQ06DDbGwunfz95%2B7g%40mail.gmail.com.

Andrew Scholer

unread,
Sep 24, 2025, 7:57:27 PM (2 days ago) Sep 24
to prete...@googlegroups.com
I think serif/sans-serif/monospace are the three essentials. I would also like to be able to define a diagram level default instead of tagging each label separately. (But still be able to override the default on any particular label.)


It might be nice if there were some classes ("prefig--mono", "prefig--serif",....) applied in addition to the @font-family that PreTeXt could use to set more specific font stacks. For example, <label font="sans-serif"> would turn into <text class="refig--sans-serif" font-family="sans-serif"> and then PreTeXt could define that class to use a specific stack like: "Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif"

But, CSS from the page only works on the SVG when it is embedded in the page and not the @src of an image. Only annotated images get that treatment currently.


Andrew

David Austin

unread,
Sep 25, 2025, 7:02:03 AM (2 days ago) Sep 25
to prete...@googlegroups.com
I think serif/sans-serif/monospace are the three essentials.

OK, I can do this pretty easily, but may not be able to get to it until the weekend.
 
I would also like to be able to define a diagram level default instead of tagging each label separately. (But still be able to override the default on any particular label.)

This can currently be accomplished with a prefigure publication file or using the #prefigure-preamble element inside #docinfo in a pretext document (see Chapter 4: Managing a PreFigure project).  I've thought that it might be nice to have this feature available at the level of an individual diagram, however, and can add that as well.

I can certainly include class attributes to the SVG text elements, but then we'd need some coordination with pretext, which I'm happy to do.  Maybe we can discuss Monday at drop-in.

David
 

Andrew Scholer

unread,
Sep 25, 2025, 11:13:09 AM (2 days ago) Sep 25
to prete...@googlegroups.com
Great!

Doing it at the publication file sounds good enough. Personally I wouldn't conceptualize each diagram for a book as being a self sufficient entity that will render independently exactly as it would when built in the context of the overall project.

I should be at the drop-in Monday, will hope to talk more then.

Andrew


David Austin

unread,
Sep 25, 2025, 3:38:44 PM (2 days ago) Sep 25
to prete...@googlegroups.com
Hi Andrew,

Grading seemed less appealing than development work so I added @font and @font-size attributes to the #label element in PreFigure.  An example is given in this Paragraph (the descriptions of those two attributes are given in the list directly above).  Notice also that I added a #templates element, which is like a local version of #prefigure-preamble, so that you can define default behaviors that apply to the current diagram.  I just released a new version of prefig so you'll need to update.

Just let me know how this works for you or if you'd like something different.

Thanks,
David



Andrew Scholer

unread,
Sep 25, 2025, 7:03:00 PM (2 days ago) Sep 25
to prete...@googlegroups.com
Awesome! Thank you for adding that.

Andrew

Reply all
Reply to author
Forward
0 new messages