-
-
Notifications
You must be signed in to change notification settings - Fork 605
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
Introduce icon module #2613
base: main
Are you sure you want to change the base?
Introduce icon module #2613
Conversation
I like the API of @falkoschindler I took a look into the json coming from https://fonts.google.com/metadata/icons?incomplete=1&key=material_symbols to find examples where "Material Icons" family was not supported. At least for some of these, there is another icon definition with the same name which provides this family: {
"name": "accessibility",
"version": 251,
"popularity": 1889,
"codepoint": 59470,
"unsupported_families": [
"Material Icons",
"Material Icons Outlined",
"Material Icons Round",
"Material Icons Sharp",
"Material Icons Two Tone"
],
"categories": [
"Common actions"
],
"tags": [
"accessibility",
"accessible",
"body",
"handicap",
"help",
"human",
"people",
"person"
],
"sizes_px": [
20,
24,
40,
48
]
},
{
"name": "accessibility",
"version": 13,
"popularity": 26564,
"codepoint": 59470,
"unsupported_families": [
"Material Symbols Outlined",
"Material Symbols Rounded",
"Material Symbols Sharp"
],
"categories": [
"action"
],
"tags": [
"accessibility",
"accessible",
"body",
"handicap",
"help",
"human",
"people",
"person"
],
"sizes_px": [
24
]
}, |
And if there is really not a filled version we could fallback to the outlined one. |
And one other thought: Why have you chosen to go back to lowercase for the sub-type and not use I would like the syntax |
Me too.
Yes, I know. This makes it a bit tricky to build the icon list, because they provide multiple icons with the same name, each with "unsupported families". So you have to combine them yourself to find the "supported families" yourself. Anyway, there are icons with "Symbols" only, or with "Round", "Sharp" and "Outlined" but no "Filled" icons, and so on. Basically every combination is possible.
I'm sceptical about silently falling back to another family. If you plan to use one family only, it's hard to even notice that you didn't get what you wanted.
Good question. Actually, I also like I wonder if we should introduce |
Ah. Let's combine the two. Let's make |
ChatGPT just told me that Material Symbols is a super-set of Material Icons. Also Outlined and Rounded variants are part of the old "Material Icons". Material Symbols are designed to be highly customizable, including Weight, Grade, Optical Size which makes the separate sets obsolete. See https://developers.google.com/fonts/docs/material_symbols. I think it would be ok if |
Interesting idea... Just for reference, here's a quick script counting the different family combinations: import json
from collections import Counter
import httpx
FAMILIES = {
'Material Icons',
'Material Icons Outlined',
'Material Icons Round',
'Material Icons Sharp',
'Material Symbols Outlined',
'Material Symbols Rounded',
'Material Symbols Sharp',
}
response = httpx.get('https://fonts.google.com/metadata/icons?incomplete=1&key=material_symbols')
icons: dict[str, list[str]] = {}
for icon in json.loads(response.text[4:])['icons']:
if icon['name'] not in icons:
icons[icon['name']] = []
icons[icon['name']].extend(FAMILIES.difference(icon['unsupported_families']))
counter: Counter[frozenset] = Counter()
for name, families in icons.items():
counter.update([frozenset(families)])
for family, count in sorted(counter.items()):
print(f'{set(family)}: {count}')
So there are some icons without a symbol. |
I think we can just ignore the icon names missing from the Material Symbols:
The probes I took looked like the icons are still available but just not through the (strange) name. |
@rodja I don't quite get what you're saying. 🤔 |
I mean we should only provide Material Symbols through the |
This PR is an alternative, simplified implementation of PR #2537. It introduces an
icon
module and allows to use icons constants like this:Actually I planned to create an API like this:
But because many icons are not available as "filled icons" (the default), the result of
icon.SUCH_AN_ICON
would be undefined. So I went back to the simply approach using a plain list of string constants.Open tasks:
n_
?