-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Strange request about Retina
style and SublimeText on Linux
#641
Comments
To recap at a high level:
This only happens with Pango on Linux. Windows and Mac handle the naming fine, as far as I know. The APIs just work better. My tweets explained that the issue is a combination of poor font selection (specifically with Pango) on Linux, combined with a non-standard weight name. My suggestion was for @kgizdov to modify the font to have a family name of "Fira Code Retina" and a weight class of Normal/Regular/Book. Renaming the font for the entire project would be a whole different level, and I don't suppose to know all of the knock-on effects of that. The only way for us to solve this, without special-casing, would be to change our font selection logic on Linux to iteratively try different prefixes of the "font_face" as family name when enumerating the families on the system. This is a fair bit of change and work, and isn't super-high priority relative to other things right now. The downside being that users on Linux who want to use "Fira Code Retina" right now are basically out of luck. Anyway, I just figured I'd chime in with details on where this was coming from and what about Sublime Text and font selection was motivating @kgizdov's request. |
Would renaming Retina to Book and keeping font weight at 350 work? |
I believe so. Let me make a tweak to the font and confirm it works before having you go down that path. |
@wbond wondering if you had time to check this? |
I didn't, but thank you for the reminder. I should hopefully be able to do that soon. |
@wbond ? |
@tonsky I can confirm the pull request to resolve the issue. Renaming |
I just noticed Book is 350 (lighter than Regular) while Retina is a bit heavier than Regular. I also noticed IBM Plex Mono uses Text weight for something between Regular and Medium. Would that work too? I really don’t want to make Book weight that is heavier than Regular. |
@tonsky Well, I guess it could work. As far as I understand originally, it was a problem of name parsing. So if |
@tonsky updated the PR |
It’s not that the number matters, it’s the fact that Retina is heavier than Regular and Book by convention is something lighter than Regular that troubles me. I don’t want to break that convention. It’s like making Light weight super-bold. That would be confusing |
@tonsky ok, then is there another standard name we could use in this case? Something that will be picked up and not confuse the parser? |
That’s my question to @wbond. Will Fira Code Text work in Linux? (instead of Book)? |
Well, I'm gonna have to test it. I think @wbond has given up on this. |
Hey, sorry, I tend to get lots of notifications on GitHub and sometimes they slip through. When this issue was first open my fifth child was less than a month old, and sometime I just lost track of the issue. In terms of how Sublime Text deals with the funkiness, our current approach requires stripping the font weight from the name to try and use the pango API to get the correct font. However, that doesn't always works, so we fall back to looking for the family name with a named weight. I think the issue here is that we haven't run into a weight named "Retina" before. Apparently neither "Text". This is the current list of weights we explicitly handle:
The first is the literal string we look for in the name, and the second value is the normalized weight we use internally in some of our code. For everything to work properly, we need an approximate weight to map a weight name to, but the most important part is recognizing that a word is a "weight name". I can certainly add some more names to our standard mapping. We handle some of the most common, and have a pretty good coverage of CSS weight names, however seeing https://bigelowandholmes.typepad.com/bigelow-holmes/2015/07/on-font-weight.html there are definitely some we should add such as "Text", "Lite", "Dark", etc. The only downside to this is that these will only work properly in future releases of Sublime Text, as opposed to what is out there now. |
@wbond it would be great if you could expand the mapping. That would help more broadly with other fonts and users and I'm sure everyone would welcome it. In the case for |
Ultra means the heaviest possible, so that probably wouldn't be a good option. |
So no matter what I do with Fira Code, after normalization we will only have the following options: THIN Which means we have nothing to resolve to if we want something between Normal and Medium. Seems like an unfortunate omission. @wbond how about you add TEXT weight and resolve both BTW congrats on the fifth child! And thanks for getting back to this issue so quickly! |
@tonsky Sorry, no, those internal mappings have to do with with mapping to a numeric value and you don't need to worry that there are only a limited distinct number. As I mentioned before, pango has a funky API. It defaults to trying to search using aspects of the font - family name, weight (numeric), etc. When someone sets their font to be "Imaginary Mono Medium", we still need a "bold" version for when a color scheme specifies bold. So we have to strip the Medium weight off to get the family name and then request a weight of the family with bold weight. We can (properly) match any font that uses a weight in the "big" list, even if the numeric values are atypical (such as with Operator Mono). I've got an internal merge request to add a number of other weight values that will work with future versions of Sublime Text and Sublime Merge. These include:
I spent some time looking for other names that are used for weights and couldn't find anything, so I think after this change our algorithm should be fairly complete. So as a result, yes, using the name "Text" for the weight I think is reasonable. Some places consider that slightly lighter than "Normal" or "Regular", more like "Book". One option would be "Thick", though it may imply connotations of possibly being heavier than "Medium" to some users. |
I have not found any fonts with Thick but Bigelow and Holmes article suggests it’s exactly between Normal and Medium, so that works too |
Great discussion everyone! I learned quite a bit from it so many thanks for that :) Haven't really ventured very far into Typography so enjoying learning more about it. Fira Code is by far my favorite font for coding and sublime text my favorite place to write that code. Much appreciate everyone getting involved and moving things forward 👍 ❤️ PS. @wbond how do you survive 5 kids? As lovely as they are my two daughters nearly ruined us in their first two years. Like I love them to death but there is simply no way we are having another one. 🤣 |
@wbond how about adding retina to SublimeText? |
Retina is more of a description of a pixel density, whereas all of the other weights (other than book, which has a long history in typography) are words to describe weight or thickness. Because of that, I'm not sure it makes sense to add Retina. For instance, should we add custom weight names for any font that wants to be different? |
@wbond this all depends. As far as I can tell, there are other fonts which also use the "weight" Retina. Let's be honest, there are a lot of idiotic things (which are logically wrong) in IT, because major corporations came up with them. This is not necessarily an excuse, but can be used as one should you not find one yourself. What about Book? You mentioned Book, which did not really represent a weight either but had a long tradition? Who says Retina won't either? |
@tessus Could you point to those fonts? I'm not keen on adding Retina (or Pupil 🙂) as weight names since they seem like an evolutionary dead end, and I'd really not be special-casing things in the Sublime Text code base for individual fonts. I should note that the additional weight names I mentioned at #641 (comment) have been shipping in the latest dev build of Sublime Text for a coupe of months. |
Unfortunately not. I don't have any concrete examples, but I think to remember that I came across fonts that used
Haha. Well, there are still drivers that use crt in their names and not to talk about harddisk drivers that use rotational speed and so on, even though these drivers are mostly used on SSDs these days, .... But I get what you are saying. |
@wbond I've tested the latest dev builds that are published online, but I cannot reproduce the support for these new font weights. I'm guessing you had some private builds in mind. @tonsky I've made a new pull request where I've taken the discussion above and instead of trying to rename things I introduce two new font weights - Book and Thick - Book is a Retina duplicate, Thick is the one discussed above. I've also included the resulting fonts. With this new PR #1038 I've managed to use At least, however, I think the PR will future-proof the font somewhat with two separate options. |
I never noticed this was a Linux specific thing. I am on mac after all... |
Hi,
As the title says, this is a bit of a strange request. Let me start by referencing why I write this. This forum post and this whole tweet discussion (tweet continued with more details)
The issue comes down to an inability to select the
Fira Code
withRetina
style inside SublimeText. From the discussion with the dev, I think the problem has to do with a misuse of Pango API, where the font weight is used to select the style variant. I could be wrong as SublimeText is closed source and there's no way to verify that.However, I have been ensured that making a
Fira Code Retina
font face with weightBook
would work. Or at least a fontFira Code
with weightBook
. This is because SublimeText do not provide a way to specify custom font style, but instead, as I understand, try a bunch of predefined ones.So I wonder if it would be possible to have that sort of thing provided upstream - basically the
Retina
variant but as aFira Code
with weightBook
. I could edit the font myself, but really don't wanna mess things up on the user side and also have to do this sort of thing on every update.Is this sort of thing at all reasonable?
Thanks!
EDIT: It seems like it's not an API misuse, but an API deficiency in Pango, where string font styles are converted to numbered weights.
The text was updated successfully, but these errors were encountered: