Skip to content

DOC: Add thumbnail for ftface_props gallery example#31321

Open
AMAN194701 wants to merge 1 commit intomatplotlib:mainfrom
AMAN194701:add-ftface-props-thumbnail
Open

DOC: Add thumbnail for ftface_props gallery example#31321
AMAN194701 wants to merge 1 commit intomatplotlib:mainfrom
AMAN194701:add-ftface-props-thumbnail

Conversation

@AMAN194701
Copy link
Contributor

Problem :
The ftface_props example does not generate a gallery thumbnail as it produces no visual output.

Cause :
The example only prints font properties to stdout and does not call plt.savefig() or plt.show(), so Sphinx Gallery cannot auto-generate a thumbnail.

Fix :
Added a custom SVG thumbnail using sphinx_gallery_thumbnail_path. The thumbnail illustrates key font metrics (ascender, cap height, baseline, descender) using the letters "Ag" with annotated reference lines.

Closes #17479

AI Disclosure

I used AI assistance to help generate and iterate on the SVG thumbnail design.

@github-actions github-actions bot added the Documentation: examples files in galleries/examples label Mar 18, 2026
@story645
Copy link
Member

story645 commented Mar 18, 2026

I used AI assistance to help generate and iterate on the SVG thumbnail design.

Slightly concerned about this from a licensing point of view. @QuLogic does this seem generic enough? I think the image is descriptive.

ETA: Also thanks the disclosure - it'd be a lot more of a problem if we didn't know AI was used and there was a licensing problem (I don't think that's the case here, but the knowledge helps a lot in the discussion.)

@AMAN194701
Copy link
Contributor Author

@story645
Copy link
Member

I'd also add this (or an even more detailed pic) to the example - I really like the markup of attributes, it explains what they are really well.

@jklymak
Copy link
Member

jklymak commented Mar 18, 2026

It would be even nicer if it agreed with the font displayed. I doubt there are too many fonts where the ascender is so much taller than the height.

@AMAN194701 AMAN194701 force-pushed the add-ftface-props-thumbnail branch from 2f8d1e8 to 3255921 Compare March 18, 2026 09:07
@AMAN194701
Copy link
Contributor Author

Thanks for the feedback @jklymak and @story645!
I have Updated the thumbnail.
Here's how it looks:
Screenshot 2026-03-18 at 14 59 04
And here's the gallery page from the CI build: https://output.circle-artifacts.com/output/job/d10adc19-42c2-41f9-b97f-a5964b4df1a1/artifacts/0/doc/build/html/gallery/misc/index.html
Let me know if anything else needs to be changed!

@story645
Copy link
Member

Baseline and cap height aren't listed in the font properties - can the labels match the listed properties? And also can you add a box? (I wonder if this might be easier to make in Matplotlib using the font in the example and the coordinate system in font properties)

@AMAN194701
Copy link
Contributor Author

Thank you @story645 for the feedback !
I’ll update the labels to match the listed font properties and add a box. I’ll also try generating it using Matplotlib as suggested.

@QuLogic
Copy link
Member

QuLogic commented Mar 18, 2026

Maybe it would make sense to change this example to generate that figure as well... But some care might have to be taken to handle fonts that don't have whatever sample characters we end up using.

The image doesn't quite make sense though as I doubt the cap height is going to be the same as the x height, and it certainly isn't for the default DejaVu Sans.

@AMAN194701
Copy link
Contributor Author

Thanks ! @QuLogic I ran the example locally and I can see what you mean — Ascender is 1901 and Bbox ymax is 2187, so cap height and x height are clearly not equal for DejaVu Sans, and my static thumbnail was incorrectly showing them as the same.
I also noticed the example currently produces no matplotlib figure at all — it only prints to terminal. Would it make sense to convert this example to actually generate a visual diagram using font.bbox, font.ascender, font.descender, font.underline_position and font.underline_thickness to show these metrics visually? That would make the thumbnail naturally come from the example itself rather than needing a static image.

@QuLogic
Copy link
Member

QuLogic commented Mar 20, 2026

Yes, that's what I suggest.

@AMAN194701 AMAN194701 force-pushed the add-ftface-props-thumbnail branch 2 times, most recently from a45dfc8 to f9343ba Compare March 21, 2026 05:32
The example only printed to stdout with no visual output, so Sphinx
Gallery could not auto-generate a thumbnail. Added a matplotlib figure
that visualises the font metrics (ascender, descender, bbox, underline
position/thickness) normalised to units_per_EM using the same font
loaded in the example.

Closes matplotlib#17479
@AMAN194701 AMAN194701 force-pushed the add-ftface-props-thumbnail branch from f9343ba to b734475 Compare March 21, 2026 06:01
@AMAN194701
Copy link
Contributor Author

Thanks @story645 and @QuLogic for the feedback! I have Updated the example to actually generate a matplotlib figure using font.bbox, font.ascender, font.descender, font.underline_position and font.underline_thickness , all normalised to units_per_EM. The thumbnail is now auto-generated by Sphinx Gallery from the figure itself, no static image needed anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation: examples files in galleries/examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add thumbnails for tutorials/gallery where missing

4 participants