DOC: Add thumbnail for ftface_props gallery example#31321
DOC: Add thumbnail for ftface_props gallery example#31321AMAN194701 wants to merge 1 commit intomatplotlib:mainfrom
Conversation
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.) |
|
Thumbnail is rendering correctly in the CI-built gallery: |
|
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. |
|
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. |
2f8d1e8 to
3255921
Compare
|
Thanks for the feedback @jklymak and @story645! |
|
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) |
|
Thank you @story645 for the feedback ! |
|
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. |
|
Thanks ! @QuLogic I ran the example locally and I can see what you mean — |
|
Yes, that's what I suggest. |
a45dfc8 to
f9343ba
Compare
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
f9343ba to
b734475
Compare
|
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. |


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.