google system local font picker - Free Download Select/Preview Google/System/Custom Fonts With Fontpicker Plugin

Free Download Select/Preview Google/System/Custom Fonts With Fontpicker Plugin

Posted on

This time I will share jQuery Plugin and tutorial about Select/Preview Google/System/Custom Fonts With Fontpicker Plugin, hope it will help you in programming stack.

google system local font picker - Free Download Select/Preview Google/System/Custom Fonts With Fontpicker Plugin
File Size: 176 KB
Views Total: 2443
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Fontpicker.js the successor of the Fontselect plugin that converts an input field into a full-featured font picker for Google Web Fonts and System/Custom Local fonts.

More Features:

  • Provides a convenient popup interface to select fonts.
  • Live preview after selected.
  • Lazy load fonts to improve performance.
  • Allows to set favorite colors.
  • Easy to filter through fonts with a search box or tags (serif, sans serif, display, etc).
  • Supports font weight and font style.
  • Keyboard interactions. Keys 1-9 select a font weight in an active item. Key i toggles italics in an active item.
  • Auto remembers the last picked fonts.
  • Multiple languages: English, German, Dutch.
  • Useful API methods and event handlers.

How to use it:

1. Load the stylesheet jquery.fontpicker.css and JavaScript jquery.fontpicker.js in the HTML file.

1 <link href="/path/to/dist/jquery.fontpicker.min.css" rel="stylesheet" />
2 <script src="/path/to/cdn/jquery.slim.min.js"></script>
3 <script src="/path/to/dist/jquery.fontpicker.js"></script>

2. Create a normal input field for the font picker.

1 <input id="myFontPicker" type="text">

3. Just call the function fontpicker on the input field and the plugin will take care of the rest.

1 $('#myFontPicker').fontpicker();

4. Apply the selected font family to a given element using the change event.

01 function applyFont(element, fontSpec) {
02  
03   // Split font into family and weight/style
04   var tmp = fontSpec.split(':'),
05     family = tmp[0],
06     variant = tmp[1] || '400',
07     weight = parseInt(variant,10),
08     italic = /i$/.test(variant);
09  
10   // Set selected font on paragraphs
11   var css = {
12     fontFamily: "'" + family + "'",
13     fontWeight: weight,
14     fontStyle: italic ? 'italic' : 'normal'
15   };
16  
17   $(element).css(css);
18    
19 }
1 $('#myFontPicker').fontpicker()
2 .on('change', function() {
3   applyFont('#yourElement', this.value);
4 });

5. Determine whether or not to show show font variants. Default: true.

1 $('#myFontPicker').fontpicker({
2   variants: false
3 });

6. Customize the system fonts you’d like to use. Setting the option to false will disable system fonts.

01 $('#myFontPicker').fontpicker({
02   localFonts: {// Default: web safe fonts
03     "Arial": {
04       "category": "sans-serif",
05       "variants": "400,400i,600,600i"
06     },
07     "Courier New": {
08       "category": "monospace",
09       "variants": "400,400i,600,600i"
10     },
11     "Georgia": {
12       "category": "serif",
13       "variants": "400,400i,600,600i"
14     },
15     "Tahoma": {
16       "category": "sans-serif",
17       "variants": "400,400i,600,600i"
18     },
19     "Times New Roman": {
20       "category": "serif",
21       "variants": "400,400i,600,600i"
22     },
23     "Trebuchet MS": {
24       "category": "sans-serif",
25       "variants": "400,400i,600,600i"
26     },
27     "Verdana": {
28       "category": "sans-serif",
29       "variants": "400,400i,600,600i",
30     }
31   }
32 });

7. Add your own custom fonts to the font picker. Specify the path to the font folder containing .woff files.

1 $('#myFontPicker').fontpicker({
2   localFontsUrl: '/fonts/'
3 });

8. Determine the parent container where the font picker popup is attached to. Default: ‘body’.

1 $('#myFontPicker').fontpicker({
2   parentElement: '#customContainer'
3 });

9. Determine whether or not to enable font lazy load. Default: true.

1 $('#myFontPicker').fontpicker({
2   lazyLoad: true
3 });

10. Determine how many recently picked fonts to remember (shown in ‘Favorite fonts’ section). Default: 3.

1 $('#myFontPicker').fontpicker({
2   nrRecents: 5
3 });

11. Execuet a callback when a font is selected.

1 $('#myFontPicker').fontpicker({
2   onSelect: function(e) {
3     fontType: fontType,
4     fontFamily: fontFamily,
5     fontStyle: italic ? 'italic' : 'normal',
6     fontWeight: weight,
7     fontSpec: value
8   }
9 });

12. Determine whether to show the clear button.

1 $('#myFontPicker').fontpicker({
2   showClear: true
3 });

13. API methods.