Coder Social home page Coder Social logo

bichoco-font-faces's People

Contributors

7studio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bichoco-font-faces's Issues

Add some useful files

I think these files below are unavoidable in a repository nowadays:

  • bower.json
  • .gitignore
  • .editorconfig

Now, I don't know if it's important to add also the .travis.yml file or not.

Your feedbacks are welcome.

Support SVG Font

Currently, the BICHOCO Font Faces module does not support the SVG Font but it is not a bug it is rather a will.

In fact, in order to use an SVG font in the @font-face rule, its path needs an extra info (e.g.: url('../fonts/asap/bold.svg#idFontName) format('svg')).
This extra info is embodied by a hash after the file name which relates to the value of id attribute on the <font> element in your SVG file (e.g.: <font id="AsapBold" horiz-adv-x="1095">).
The reason for this is that multiple fonts can be embedded in a SVG document and therefore an unique identifier is required.

Finaly, even if there is only one font declared in the document, if we don't include this hash, the required SVG Font will not work.

The problem is simple: without generating our font files, we cannot define this hash as we would like. Unfortunately the SVG ID is not necessarily (in fact, never) the same than the font name or file name with the common font generators.
Here is an example with the webfont generator of Font Squirrel and the Asap font:

  • Asap Italic -> asap-italic.svg -> <font id="asapitalic" ... >
  • Asap Bold -> asap-bold.svg -> <font id="asapbold" ... >
  • Asap Bold Italic -> asap-bolditalic.svg -> <font id="asapbold_italic" ... >

I found two solutions to use SVG font format with the module:

1. Rewrite ID in SVG file

Pros:

  • Nothing has to be changed in @include directives
  • This value is arbitrarily chosen by the generator so it can be rewritten for the module (like file names)

Cons:

  • Sass is not a programing language. The hash could be difficult to build with the arguments, depending on the applied convention (e.g.: <FamilyName><Weight><Style>)
  • Not really easy to test and debug
  • Modifying the content of the file is not really a good idea (you could change the encoding or something else)

2. Be able to pass a list as the $family-name parameter in the font-face mixin

// Built @font-face rule
// @mixin: font-face
// @arg {string|list} $family-name The font-family descriptor value and optionally an SVG ID to use
// ...

// Basic usage
@include font-face('Asap', 'asap', normal, 700);

// With SVG font format support
@include font-face(('Asap', '#asapbold'), 'asap', normal, 700);

Pros:

  • Don't handle the SVG document except to take the value of id attribute on the <font> element
  • Easy to set up with Sass

Cons:

  • Cannot be implemented on font-faces mixin in an understandable way. IMHO, it is too complex and would not make sense if the SVG ID was attached to variants/styles

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.