Skip to content
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

Support SF Symbols in the same way as emojize #46

Closed
jmjordan opened this issue Dec 5, 2020 · 21 comments
Closed

Support SF Symbols in the same way as emojize #46

jmjordan opened this issue Dec 5, 2020 · 21 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jmjordan
Copy link
Contributor

jmjordan commented Dec 5, 2020

I really like the look of SF Symbols compared to emoji. I would like to add them to my plugin the same way you do using the emojize feature. It's possible to paste the SF Symbol into your output script, but this only works if you have the SF Symbols app installed and not all editors can display them.

Proposal:
Add support for SF Symbols using a similar mechanism to emojize=true

Possible solution:
Add an SF symbol to plugin output by using its system name as a token, eg. :square.and.arrow.up:.
App would replace occurrences of these tokens with an SF Symbol if symbolize=true

@melonamin
Copy link
Contributor

We already have it in a form of sfimage=... Have you tried that?

@jmjordan
Copy link
Contributor Author

jmjordan commented Dec 5, 2020

Yes, that works great, but it only works for adding symbols to the beginning of a line. I'd like to be able to use them throughout a line of text as well.

@melonamin melonamin self-assigned this Dec 5, 2020
@melonamin melonamin added the enhancement New feature or request label Dec 5, 2020
@melonamin melonamin added this to the 1.1.0 milestone Dec 5, 2020
melonamin added a commit that referenced this issue Dec 6, 2020
@melonamin
Copy link
Contributor

Quick take, this:

#!/bin/bash
echo "Test Symbols :sun.min.fill: :sun.max.fill: :cloud.snow.fill: :eyedropper:"
echo "---"
echo "Test Symbols :sun.min.fill: :sun.max.fill: :cloud.snow.fill:"

Becomes this:
CleanShot 2020-12-06 at 15 25 14@2x

Kind of working:

  • :sun.max.fill: :cloud.snow.fill: are colored probably because they support coloring.
  • :sun.min.fill: :eyedropper: should adopt text color, but for some reason are black in the menu bar and invisible in the menu

@jmjordan
Copy link
Contributor Author

jmjordan commented Dec 6, 2020

I was able to make the icons white by embedding them into a NSTextAttachmentCell but that breaks the layout. I'm worried its going to require implementing a custom NSTextAttachmentCellProtocol.

extension NSTextAttachment {
    static func centeredImage(with image: NSImage, and
                                            font: NSFont) -> NSTextAttachment {
        let imageAttachment = NSTextAttachment()
        imageAttachment.bounds = CGRect(x: 0, y: (font.capHeight - image.size.height).rounded() / 2, width: image.size.width, height: image.size.height)
//        imageAttachment.image = image
        let cell = NSTextAttachmentCell(imageCell: image)
        imageAttachment.attachmentCell = cell
        return imageAttachment
    }
}

Screen Shot 2020-12-06 at 1 16 29 PM

melonamin added a commit that referenced this issue Dec 8, 2020
@melonamin
Copy link
Contributor

I have no idea what I'm doing, but this seems to be working 🤔

#!/bin/bash
echo "Test :sun.max: :cloud.fill: :gamecontroller.fill: :bookmark: :sun.dust:"
echo "---"
echo "Test :bookmark:"
echo "Test :sun.max:"

Screen Shot 2020-12-07 at 10 05 48 PM

@jmjordan
Copy link
Contributor Author

jmjordan commented Dec 8, 2020

That looks great!

@jasonsnell
Copy link

I'm using this in the new beta and it works, but I've noticed a color mismatch. I'm using Big Sur and of course it dynamically chooses menu bar text color (black or white) based on the contents of the wallpaper. I'm in a mode where all the text is white, but the SFsymbol, which appeared white when using the old method, now displays as black with this method. (The text I've added after the SFsymbol is white!)

More broadly--and forgive me if this is being addressed elsewhere, I didn't see it--I feel like there needs to be a way to deal with Big Sur dynamically changing the text in the menu bar. In Catalina I could just detect the existence of Dark Mode and adjust text colors appropriately, but I don't seem to be able to do that in Big Sur?

Screen Shot 2020-12-11 at 9 50 56 AM

@jasonsnell
Copy link

Actually I have to add another data point! :smoke: was black but :wind: shows as white. WHAT. Anyway, something weird there.

@jasonsnell
Copy link

Another issue. there is a namespace collision between emoji code and SFsymbol code, so :house: renders as an emoji house. Should there be some other way to name SFSymbols so they don't collide with emojis?

@melonamin
Copy link
Contributor

melonamin commented Dec 11, 2020

Actually I have to add another data point! :smoke: was black but :wind: shows as white. WHAT. Anyway, something weird there.

This was fixed after I published the beta, I referred to it in this thread ☝️ I will push another build this weekend, stay tuned.

Screen Shot 2020-12-11 at 2 01 00 PM

Should there be some other way to name SFSymbols so they don't collide with emojis?

Let me think about that, meanwhile you can disable emoji rendering, this should give you SF Symbol.

@jmjordan
Copy link
Contributor Author

We could use a different syntax for SFSymbols to avoid collisions. <house> or {house} perhaps?

@melonamin
Copy link
Contributor

I don't know, for some reason I like that we offer a uniform syntax for these two. Should we support having emoji and SF Symbols in one line at the same time? It looks quite weird.

@jmjordan
Copy link
Contributor Author

That's fair. I don't see why anyone would want to use both SFSymbols and emoji on the same line. If they wanted to they could always use the actual emoji instead of the decoded syntax.

@jasonsnell
Copy link

I don't know, for some reason I like that we offer a uniform syntax for these two.

Okay, but if I do :house: I need to explicitly set the mode to emoji for that line because it's got an emoji counterpart... that seems not great? I'm not really talking about mixing so much as searching for relevant sfsymbols only to find that some of them collide with emojis... not great. Is there a way to force one or the other, or is it just "emojis win, use |symbolize=true if you don't like this"...

@jasonsnell
Copy link

If they wanted to they could always use the actual emoji instead of the decoded syntax.

This is actually what I've done with emojis up to now. Worked fine.

@melonamin
Copy link
Contributor

melonamin commented Dec 15, 2020

Ok, this is how it works now:

#!/bin/bash
echo "Test :smoke: :wind: :house:  | emojize=false"

Screen Shot 2020-12-14 at 8 52 59 PM

Emoji wins, but you can explicitly disable it. We can switch to "SF Symbols wins" mode, if you think it is a more sensible default. Either way you can control which one will be used.

Am I missing something?

@jmjordan
Copy link
Contributor Author

I guess I was thinking that if you enabled symbolize it would automatically disable emojize.

@melonamin
Copy link
Contributor

I guess I was thinking that if you enabled symbolize it would automatically disable emojize.

Sorry, I think I just confused everyone:

  • emoji enabled by default
  • SF Symbols disabled by default
  • enabling SF Symbol doesn't disable emoji

@jasonsnell
Copy link

jasonsnell commented Dec 15, 2020

I'm definitely confused, but as long as there's a way to turn on symbols and turn off emojis so that collisions it'll work.

Still might be easier to just keep them both on with separate reference methods, though. So I could do :house: and :symbol:house: for example.

@jasonsnell
Copy link

The real issue is I'm not 100% sure why we need emoji shortcuts since files will accept emojis as characters? Shortcuts are nice but they're a convenience since you can just drop in the emoji, whereas there's no other way to reference SFSymbols. I guess that would be my argument for giving SFSymbols priority, but the important thing is to just make a decision. 😉

@melonamin
Copy link
Contributor

New behavior: SF Symbols have priority, emoji will work only if SF Symbols explicitly disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants