Giter Club home page Giter Club logo

angular-fontselect's Introduction

⚠️ This package is discontinued. Active maintenance is stopped and the package is as-is still available on npmjs.org. For details check out internal ticket CRE-1204.

Angular Font-Selector

Build Status Coverage Status

A font selection directive for AngularJS - Try it, it's beautiful.

Breaking Changes

0.13

0.12

  • jdFontselect.fonts has been renamed to jdFontselectFonts
  • jdFontlist.controller has been renamed to jdFontlistController

In order to enable usage of ngAnnotate.

Usage

install bower package:

bower install angular-fontselect --save

add scripts and styles to your project

<script type="bower_components/angular-fontselect/dist/libs/webfontloader.js"></script>
<script type="bower_components/angular-fontselect/dist/angular-fontselect.js"></script>
<link rel="stylesheet" type="text/css" href="bower_components/angular-fontselect/dist/angular-fontselect.css">

or use wiredep

set as dependency in your module

angular.module('myModule', ['jdFontselect']);

use the directive in your views

<h1>Now select a font:</h1>
<jd-fontselect />

Api Keys

You can provide your production API Keys by setting them as a constant in your application. Get one from the Google Developers Console.

angular.module('myApp', ['jdFontselect']).constant('jdFontselectConfig', {
  googleApiKey: '__yourKeyHere__'
});

Directive Attributes

Current State

<jd-fontselect state="myStateObject" />

The State object is meant to be read only and can be used for initiation with a certain state.

// $scope.myStateObject
{
  sort: {               // Sort the list by a given font attribute
    attr: 'name',       // Can be: 'name', 'popularity', 'lastModified'
    direction: true
  },
  providers: {          // Filter the list by Font provider
    google: true,
    websafe: true
  },
  category: undefined,  // Filter. Can be: undefined (all), 'sansserif',
                        //   'serif', 'handwriting', 'display', 'other'
  font: {               // The current font object
    subsets: [ ... ],   // List of supported subsets
    variants: [ ... ],  // List of available Variants
    name: '',           // Name of the font (As displayed in the list)
    popularity: 0,      // Popularity of the font
    key: '',            // Lower-cased alpha only version of the name
    lastModified: 0,    // Timestamp
    stack: '',			// For example '"Open Sans", sans-serif'
    category: ''        // 'sansserif', 'serif', 'handwriting', 'display', 'other'
  },
  search: '',            // Current search string
  subsets: {            // Filter: Object of subsets supported by google
    latin: true
    // [ ... ]
  }
}

Current Stack

<jd-fontselect stack="myFontStack" />

The Font stack can be used in CSS like this

<h1 style="font-family: {{myFontStack}};">Look at this font</h1>

You can change the current font in the selection by giving $scope.myFontStack a value (for example Helvetica, Verdana, sans-serif)

Current Font Name

<jd-fontselect name="myFontName" />

Read-Only. $scope.myFontName now contains the current font name

Translate

<jd-fontselect text="myTranslationObject" />
<jd-fontselect rawText="{ toggleOpenLabel: 'Mach uff!', ... }" />

The text attribute contains a translation object, the rawtext object contains a string, evaluating into a translation object.

// $scope.myTranslationObject
{
  toggleOpenLabel: 'open',
  toggleCloseLabel: 'close',
  searchToggleLabel: 'Search',
  search: 'Search by Fontname',
  toggleSearchLabel: 'Choose Font',
  providerLabel: 'Providers',
  subsetLabel: 'Subsets',
  styleLabel: 'Categories',
  settingsLabel: 'Settings',
  noResultsLabel: 'No Fonts found.',
  pageLabel: 'Page: ',
  fontFabel: 'Fonts: ',
  closeButton: 'Close',
  allFontsListHeadline: 'All Fonts',
  curatedFontsListHeadline: 'Curated Fonts',
  page: {
    prev: '▲',
    next: '▼'
  },
  provider: {
    websafe: 'Websafe Fonts',
    google: 'Google Fonts'
  },
  category: {
    serif: 'Serif',
    sansserif: 'Sans Serif',
    display: 'Display',
    handwriting: 'Handwriting',
    other: 'Other'
  },
  subset: {
    cyrillic: 'Cyrillic',
    'cyrillic-ext': 'Cyrillic Extended',
    greek: 'Greek',
    'greek-ext': 'Greek Extended',
    latin: 'Latin',
    'latin-ext': 'Latin Extended',
    vietnamese: 'Vietnamese',
    devanagari: 'Devanagari',
    khmer: 'Khmer'
  },
  sort: {
    popularity: 'Popularity',
    name: 'Alphabet',
    lastModified: 'Latest'
  },
  sortdir: {
    desc: '▼',
    asc: '▲'
  }
}

On Initiation

<jd-fontselect on-init="myInitiation($scope, $element)" />

This calls $scope.myInitiation with the font selection scope and element once the selection is initiated.

Curated Fonts

In order to show a list of curated fonts on top the list with all fonts configure the jdfsCuratedFontsProvider with an array of ${font.provider}.${font.key}-strings.

angular.module('myApp', ['jdFontselect'])
  .config(function (jdfsCuratedFontsProvider) {
    jdfsCuratedFontsProvider.setCuratedFontKeys(['websafe.timesnewroman', 'google.alef']);
  });

see demo

Contributing

The CONTRIBUTE.md contains a lot of notes and tips to kickstart your development environment.

LICENSE

The MIT License

Copyright (c) 2015 Jimdo GmbH http://jimdo.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

angular-fontselect's People

Contributors

christian-meyer-jimdo avatar herrbertling avatar joscha avatar karstenbuckstegge avatar morrisjobke avatar olemchls avatar partyschaum avatar seichner avatar xiphe 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

Watchers

 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

angular-fontselect's Issues

Broken with angular >=1.3.0

Tried several versions of angular (1.3.0 - 1.3.14), and with all of them I got an error when connecting to google devs (after providing my googleApiKey).

Details:

screenshot 2015-03-11 23 49 32

Relevant info at the end of the "json" dump

screenshot 2015-03-11 23 52 36

Pastebin with full dump: http://pastebin.com/kUVWE6QE
PS: that one was generated when working with angular version 1.3.8 / notice the error was replicated with several other 1.3.X versions

Add Subsets to font URL

Currently, the subset selection is only a filter for the font-list, we need to add them to the jd-fontselection-current-href directive

Depends on #7, since we need a global list of all the used subsets in the fontsService

Update gh-pages

I just updated the libraries and noticed the content and styles here are a bit outdated.
Would be great if you update this.

Some font load just their name letters

Hello!

There is a really weird problem here!

After implementing the library a strange thing start happening.
Some fonts doesn't load well. In some cases this fonts just load the letters in their name. In the screenshoot below you can see an example

schermata 2017-01-19 alle 20 32 41

Looking the console this is the file loaded:
http://fonts.googleapis.com/css?family=Fjalla+One:regular&text=Fjalla%20One
with this content:
@font-face { font-family: 'Fjalla One'; font-style: normal; font-weight: 400; src: local('Fjalla One'), local('FjallaOne-Regular'), url(http://fonts.gstatic.com/l/font?kit=ZRI0JPgrEnSFSbERuWus_Zuu-THSsfPN_lAN0B DN6tU&skey=81738d23c31d6227&v=v4) format('woff2'); }

This is the file returned: font (3).woff2.zip

If i convert this woff2 in ttf (to see it on my mac) i just see the letters of the name.

Thanks!

Less Opinionated

"Beautiful" is very subjective. This would be SO much more valuable if it was less opinionated visually.

If Text Options are not set, the default doesn't apply

I used

text="
{
button: 'Choose a Font',
search: 'Search by Fontname',
page: {
prev: '◄',
next: '►'
},
category: {
serif: 'Serifen',
sansserif: 'Serifenlos',
display: 'Display',
handwriting: 'Handschrift'
}
}
"

but this will make all other strings that are not set dissapear, seems like it won"t fall back to the defaults

Keyboard Support

ESC: Close the selection
Up/Down: Navigate through list
Left/Right: Paginate (In search is not focussed)
Enter: Use the current Font

Specific fonts from list?

What if i want to keep specfic fonts, not all fonts for example only helvetica, what should i do?

Add or document a way to customise the interface

Hi,
thanks for your great tool,

i would like to "simplify" it like removing the ability to select providers, or having just the font list without any other clutter.
is there a way to do it ? via config keys like { categoryVisible: false } or by overwriting the template?

thanks for the help

Scrolling is laaggy

as the scrolling in the fontselection is triggered via javascript, it feels not really smooth. Let's improve that someday

Switch pagination to infinite scrolling

I mean, automatic loading/appending of the next page to the bottom of the list, when we reached the end of the page.

Problem is:
ng-repeater has major performance issues with big lists. So we should remove items on the top of the list when they move out of the viewport.

cannot auto update fonts via angular binding

As it does not include ng-model so cannot implement ng-change. Is there any other way to auto update the font in preview as soon as it is changed without submitting the form ?

Add a cancel button

If we would save the currently used font once the selection window is opened, we can reset to it once we click on a cancel button or hit escape.

Make draggable

Sometimes the element, we edit is hidden by the selection.

$scope.current.sort can be undefined

Sometimes the error

TypeError: Cannot read property 'attr' of undefined
    at Scope.$scope.getFilteredFonts (js/bower_components/angular-fontselect/dist/angular-fontselect.js:1961:46)
    at js/bower_components/angular/angular.js:10288:21
    at OPERATORS.| (js/bower_components/angular/angular.js:9616:74)
    at extend.constant (js/bower_components/angular/angular.js:10046:14)
    at OPERATORS.| (js/bower_components/angular/angular.js:9616:74)
    at extend.constant (js/bower_components/angular/angular.js:10046:14)
    at Object.$watchCollectionWatch (js/bower_components/angular/angular.js:11726:22)
    at Scope.$digest (js/bower_components/angular/angular.js:11890:40)
    at Scope.$apply (js/bower_components/angular/angular.js:12151:24)
    at HTMLAnchorElement.<anonymous> (js/bower_components/angular/angular.js:18085:21) 

gets thrown.
This happens, because $scope.current.sort can be undefined in directive.fontlist.js

Open/Close mechanics

  • Change the open button into the search field on open
  • Focus the search on open
  • Optional close when clicked anywhere outside

Fonts get loaded multiple times

When using more than one font selection input (as it is in the sandbox), opening one selection and then switching to another one adds all Google webfonts again. They are then displayed twice within the selection. Doing it again adds the amount of fonts again, showing them thrice and so on… Not replicable with the websafe fonts. Probably another (unnecessary) API call or something like that?

IE Support? Browsers showing font not as expected.

I notice that the font picker does not work with IE11 and below. Google fonts also seems to be only calling .woff files. Is this a fault of this plugin not supporting IE or Google Webfonts API not supporting it anymore?

Thanks!

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.