Giter VIP home page Giter VIP logo

sfsymbols's Introduction

MAINTAINER WANTED

I don't have time (nor interest) in maintaining this project for much longer. If you're interested in taking it over, please contact me.


sfsymbols

sfsymbols is a quick-and-dirty command-line tool to export the shapes inside the SF Symbols font.

Install

Command line

cd sfsymbols
swift build -c release
ln -s ${PWD}/.build/release/sfsymbols /usr/local/bin/sfsymbols

Xcode

Open the Package.swift and build the project, then run the resulting sfsymbols tool from the command line.

Usage

Output all icons to a folder called symbols in png format

sfsymbols --output symbols --format png

Output all icons with heart in the symbol name in svg format to the current directory

sfsymbols --symbol-name heart.*

There are several options you may specify:

  • --symbol-name: A pattern to limit which symbols are exported. Example: *.fill or *cloud*.

  • --font-file: An path to a specific SF Symbols ttf file. If you leave out this argument, then sfsymbols will attempt to locate an installed copy of SF Symbols.app on your machine and use the font packaged inside there.

  • --font-weight: A specific font-weight to use for exporting symbols. Valid values are:

    • ultralight
    • thin
    • light
    • regular
    • medium
    • semibold
    • bold
    • heavy
    • black

    If you leave out this argument, then regular will be used. Also, depending on the specified --font-file, not all copies of the SF Symbols font may contain all weights.

  • --font-size: The size (in points) to use when exporting symbols. If you leave this argument out, then the default size of 44 will be used.

  • --symbol-size: The size of the shape to use. Valid values are small, medium, and large. The default value is large.

  • --output: The folder where exported shapes should be created. Defaults to the current working directory.

  • --format: The format in which you'd like shapes exported. Valid values are:

    • ios-swift: UIBezierPath-based code in Swift
    • ios-objc: UIBezierPath-based code in Objective-C
    • macos-swift: NSBezierPath-based code in Swift
    • macos-objc: NSBezierPath-based code in Objective-C
    • svg: SVG files
    • png: PNG images
    • pdf: PDF images
    • iconset: An SFSymbols.xcassets bundle of 1x, 2x, and 3x template PNGs
    • iconset-pdf: An SFSymbols.xcassets bundle of vector template PDFs

    The default value is svg.

Disclaimer

This is posted mainly as a proof-of-concept. Use it at your own risk.

It is your responsibility to make sure you are following the terms and conditions of using Apple's symbols. For more information, see https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/.

sfsymbols's People

Contributors

davedelong avatar fappelman avatar henryallsuch avatar joeblau avatar kireev4art avatar knezzy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sfsymbols's Issues

Namespace generated Swift paths

Hello!

It'd be helpful if the Swift generator put each path as a named property of a parent class. Then it'd be a ready-to-go file to put in a project. Something like this:

class SymbolPath: UIBezierPath {
    // Override point for generated paths
}
class Symbols {
    static let someSymbolName: SymbolPath = {
        // Dump corresponding path here (the entirety of one of the swift files you're generating now) and return
    }
}

Thank you!

Look for the SF fonts

The installer installs a whole bunch of SF fonts in /Library/Fonts. Inspection with Glyphs.app shows that those fonts also contain the symbols.

Using these would be a better way to find the glyphs, as the SF fonts also support all of the various weights and display modes.

No files are output

After building and symlinking to /usr/local/bin, running

sfsymbols --output symbols --format png

creates the symbols directory, but no files are written inside it.

I've got the SF Symbols app version 1.0 (13) installed, which I just downloaded today. Specifying the font path explicitly doesn't change anything.

Running 10.14.6 and Swift 5.1 (Xcode 11).

Convert to Swift

The initial thought of using Objective-C was that I'd need to dig in to private functions in order to accomplish stuff, and private APIs are easier to use from Objective-C than from Swift.

That has turned out to not be the case, so there's no requirement for this to be in Objective-C.

it seems like the iconset should be imageset

otherwise the icon won't work properly, the image has 3 sizes (1x, 2x, 3x) apparently should be for image not appicon, in iconset will ask you to assign other sizes, that for the app icon I guess.

I modified the code by changing the dir name from *.iconset to *.imageset, which works fine for me, maybe you should change that.

Account for non-mirrorable attributes

Part of the CSV defining the glyphs is a column that says whether the shape can be mirrored for RTL languages.

When generating SVG, shapes can have a direction attribute. For mirrorable shapes, this should be omitted. For non-mirrorable shapes, this should be direction="ltr".

Add open source license

Could you please add a license? Would love to use this at my workplace, but we can't unless it has a license.

Add iconset generator

Hello! It'd be neat if there were a new generator that took the generated UIBezierPath objects and rendered them into PNGs, preferably put into iconsets. Thanks!

Specify path to font file

It'd be nice to manually specify a path to the SFSymbols ttf file, instead of always attempting to find the app.

sfsymbols.ArgumentParserError error 5.

% sfsymbols
The operation couldn’t be completed. (sfsymbols.ArgumentParserError error 5.)

System: MacOS Big Sur/11
Device: Macbook Air 2018
Version: Latest

Only seems to export Regular weight

I can't seem to get sfsymbols to export using any weights other than regular. When I specifiy, e.g., thin, I still get a Regular glyph (which is still better than no glyph, of course!).

Specify stroke width

This is awesome since the SF Symbols app makes it hard to export.
I'd love to be able to specify the font weight or stroke width.

Thanks for your great little tool!

Allow export as squares

Hey Dave, this is a great tool! I'd love an enhancement for exporting as squares, as currently it provides a button that's sized in a way that the image has to be re-sized after export to be used in an element like a UIButton or UIImageView.

For example square.and.arrow.up.on.square exports as a 59x85 asset, which when placed in a square button looks awful.

My proposed solution would be to provide an option to export as squares, so the 59x85 asset would become 85x85, with the 59x85 content portion centered in the asset.

Thanks a lot!

Provide optional padding parameter

Filing this as a follow up to #9 as asked.

On top of exporting as squares, another option which would be useful in congruence would be to add optional padding, because an asset exported to fit to the full size of the image may not look great without padding.

Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.