Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
docs(icon): add more information about icon ligatures.
Browse files Browse the repository at this point in the history
Fixes #7172  Closes #7785
  • Loading branch information
devversion authored and ThomasBurleson committed Mar 30, 2016
1 parent c68869e commit 76310b1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/components/icon/js/iconDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,15 @@ angular
*
* When using Material Font Icons with ligatures:
* <hljs lang="html">
* <!-- For Material Design Icons -->
* <!-- The class '.material-icons' is auto-added if a style has NOT been specified -->
* <!--
* For Material Design Icons
* The class '.material-icons' is auto-added if a style has NOT been specified
* since `material-icons` is the default fontset. So your markup:
* -->
* <md-icon> face </md-icon>
* <!-- becomes this at runtime: -->
* <md-icon md-font-set="material-icons"> face </md-icon>
* <!-- If the fontset does not support ligature names, then we need to use the ligature unicode.-->
* <md-icon> &#xE87C; </md-icon>
* <!-- The class '.material-icons' must be manually added if other styles are also specified-->
* <md-icon class="material-icons md-light md-48"> face </md-icon>
Expand All @@ -157,12 +162,12 @@ angular
* <hljs lang="js">
* // Specify a font-icon style alias
* angular.config(function($mdIconProvider) {
* $mdIconProvider.fontSet('fa', 'fontawesome');
* $mdIconProvider.fontSet('md', 'material-icons');
* });
* </hljs>
*
* <hljs lang="html">
* <md-icon md-font-set="fa">email</md-icon>
* <md-icon md-font-set="md">favorite</md-icon>
* </hljs>
*
*/
Expand Down
42 changes: 40 additions & 2 deletions src/components/icon/js/iconService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,30 @@
* the `$mdIcon` service searches its registry for the associated source URL;
* that URL is used to on-demand load and parse the SVG dynamically.
*
* **Notice:** Most font-icons libraries do not support ligatures (for example `fontawesome`).<br/>
* In such cases you are not able to use the icon's ligature name - Like so:
*
* <hljs lang="html">
* <md-icon md-font-set="fa">fa-bell</md-icon>
* </hljs>
*
* You should instead use the given unicode, instead of the ligature name.
*
* <p ng-hide="true"> ##// Notice we can't use a hljs element here, because the characters will be escaped.</p>
* ```html
* <md-icon md-font-set="fa">&#xf0f3</md-icon>
* ```
*
* All unicode ligatures are prefixed with the `&#x` string.
*
* @usage
* <hljs lang="js">
* app.config(function($mdIconProvider) {
*
* // Configure URLs for icons specified by [set:]id.
*
* $mdIconProvider
* .defaultFontSet( 'fontawesome' )
* .defaultFontSet( 'fa' ) // This sets our default fontset className.
* .defaultIconSet('my/app/icons.svg') // Register a default set of SVG icons
* .iconSet('social', 'my/app/social.svg') // Register a named icon set of SVGs
* .icon('android', 'my/app/android.svg') // Register a specific icon (by name)
Expand Down Expand Up @@ -178,7 +194,29 @@
* @usage
* <hljs lang="js">
* app.config(function($mdIconProvider) {
* $mdIconProvider.defaultFontSet( 'fontawesome' );
* $mdIconProvider.defaultFontSet( 'fa' );
* });
* </hljs>
*
*/

/**
* @ngdoc method
* @name $mdIconProvider#fontSet
*
* @description
* When using a font set for `<md-icon>` you must specify the correct font classname in the `md-font-set`
* attribute. If the fonset className is really long, your markup may become cluttered... an easy
* solution is to define an `alias` for your fontset:
*
* @param {string} alias of the specified fontset.
* @param {string} className of the fontset.
*
* @usage
* <hljs lang="js">
* app.config(function($mdIconProvider) {
* // In this case, we set an alias for the `material-icons` fontset.
* $mdIconProvider.fontSet('md', 'material-icons');
* });
* </hljs>
*
Expand Down

0 comments on commit 76310b1

Please sign in to comment.