-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Update action status badge layout #34018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I do not think it is a proper approach to embed font widths at the moment. You can see that font-family="Geneva,DejaVu Sans,sans-serif"
there are more fonts and the render might use none of them if there is a fallback.
Some more thoughts:
|
I looked at the implementation of shields.io and they are using the same approach to get the font width.
The label of the badge is the workflow name, non-ascii letters could be used there. But true, I also think this isn't the case so often. For this cases a fallback width could be used.
GitHub and shields.io are both using DejaVu Sans, Verdana and Geneva as fonts, so using them as preferred fonts is relatively safe. |
If non-ascii letters would be used, what would happen if there are CJK characters? |
With the fallback implemented, reducing the amount of font/glyph width is a good idea. |
Hmm yes, if we could only store the widths for characters before 0x80 or 0xFF, it would be better. |
Done with 0xFF (+ renamed font width to glyph width) |
Tested with different texts and fonts, seem good. The last questions:
|
Oh you also solved this. I did a fix that only changes the devtests (subrequests for each svg).
My intention with the build script was to have a transparent source how the widths are calculated. But yea I also don't think that they'll ever change |
I made a change in ffc8c1d to use "sync.OnceValue". Maybe we could either:
|
Comments sounds good |
* giteaofficial/main: [skip ci] Updated translations via Crowdin Add toggleClass function in dom.ts (go-gitea#34063) Add a config option to block "expensive" pages for anonymous users (go-gitea#34024) add additional ReplaceAll in pathsep to cater for different pathsep (go-gitea#34061) [skip ci] Updated translations via Crowdin enable staticcheck QFxxxx rules (go-gitea#34064) update to golangci-lint v2 (go-gitea#34054) Add descriptions for private repo public access settings and improve the UI (go-gitea#34057) Add anonymous access support for private/unlisted repositories (go-gitea#34051) Hide activity contributors, recent commits and code frequrency left tabs if there is no code permission (go-gitea#34053) Update action status badge layout (go-gitea#34018) Add anonymous access support for private repositories (backend) (go-gitea#33257) Simplify emoji rendering (go-gitea#34048) Adjust the layout of the toolbar on the Issues/Projects page (go-gitea#33667) Fix bug on downloading job logs (go-gitea#34041) Fix git client accessing renamed repo (go-gitea#34034) Decouple Batch from git.Repository to simplify usage without requiring the creation of a Repository struct. (go-gitea#34001) fix org repo creation being limited by user limits (go-gitea#34030) Fix the issue with error message logging for the `check-attr` command on Windows OS. (go-gitea#34035) Try to fix check-attr bug (go-gitea#34029)
The current action status badge are looking different from most other badges renders, which is especially noticeable when using them along with other badges. This PR updates the action badges to match the commonly used badges from other providers.
Old (first 3 are gitea badges, the others are from shields.io):

New:

A tricky part is the calculation of the text width, which is required to set the correct width of the label and message part of the badge. The used font is
DejaVu Sans
, which isn't monospaced, so different badge texts with the same letter count may be rendered with different lengths in the browser.To get the correct width, dynamic text width calculations must be done server side. All widths of printable characters from 0x00 to 0xFF are "prerendered". The comments in
badge_glyph_width.go
describe how the width generation was done.I've added a build script that downloads the font, renders the width of each supported character (at font size 11) and generates a table/map with all widths that is then used to get the approximate text width. This results in a rather big codegen file, as the font has ~5500 supported characters.