Giter Club home page Giter Club logo

svg-font-loader's Introduction

svg-font-loader - Custom Font Loader for svg-edit

About

This is a custom font loader written for the amazing svg-edit project. It allows you to use completely custom fonts by loading them with the Google Font Loader.

For more details, see the original blog post

Installation

  • Create a folder called "font-selector" in the root of your svg-edit installation.

  • Copy all the files from this github into that folder

  • Add the following JavaScript snippet into svg-editor.html after all other JavaScript files in the head section:

      <!-- Font Loader Start -->
        <link rel="stylesheet" href="font-selector/font-selector.css" type="text/css"/>
        <script type="text/javascript" src="http://www.google.com/jsapi"></script>
        <script type="text/javascript">
        google.load("webfont", "1");
        </script>
        <script type="text/javascript" src="font-selector/font-selector.js"></script>
        <script>
        $(function(){
          Smm.init('tool_font_family');
        });
        </script>
      <!-- Font Loader End -->
    

    That's it! Now you can add custom generated fonts!

Adding Fonts

There are three steps to adding custom fonts to the font-loader

1. Generate the font files and CSS

Font Squirrel has a very neat tool for creating browser compatible font files with the CSS files included. http://www.fontsquirrel.com/fontface/generator

2. Create a font preview image

To make it so that svg-edit doesn't have to download every font at load time (some fonts are 100k+) it uses preview images in the drop down font selector. To take advantage of this performance boost you need to create an image showing what the font looks like for the selector. Create this image in your favorite editor and upload it to /fonts/font-images

3. Upload and configure

Upload the CSS for your new font to /fonts and upload all font files to /fonts/font-files. Edit your font CSS file so that all the URLs are pointing to the font-files directory. Edit font-selector.js and add your font name with the corresponding font css file and preview image file to the Smm.fonts variable. Follow the examples provided.

Now you have added a completely custom font to your svg-edit!

License

This code is released under the Apache License 2.0, the same license for svg-edit.

More Information

  • See my blog post on this project for more details.

  • Read about svg-edit, a javascript based image editor (It's amazing-- trust me).

svg-font-loader's People

Contributors

clintberry avatar raphaelbastide avatar

Watchers

sky avatar

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.