GithubHelp home page GithubHelp logo

underscoretype / fontsampler-js Goto Github PK

View Code? Open in Web Editor NEW
49.0 49.0 7.0 4.87 MB

A configurable standalone webfont type tester for displaying and manipulating sample text in the browser.

Home Page: https://underscoretype.github.io/fontsampler-js/

License: MIT License

JavaScript 88.14% SCSS 11.86%

fontsampler-js's People

Contributors

dependabot[bot] avatar kontur 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  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

fontsampler-js's Issues

Some UI options don't work?

Hello there, I have been implementing this library with relative ease and joy but I have hit a roadblock.

This is my options config for the fontsampler:

{
      order: [["fontfamily", "language", "fontsize", "alignment", "opentype"], "tester"],
      ui: {
        tester: {
          editable: false,
          label: false,
        },

        language: {
          choices: ["enGB|English", "deDe|Deutsch", "nlNL|Dutch"],
          init: "enGb",
          label: false,
        },

        opentype: {
          choices: ["liga|Ligatures", "frac|Fractions"],
          init: ["liga"],
          label: "Opentype features",
        },
      },
      lazyload: true,
    }

The order, language ui choices and lazyload work however any options for the tester or the label field on any feature doesn't do anything...

@kontur Am I using the wrong data structure or I am missing something? Thanks a lot!

Refactor variations block

Currently variations (axis sliders) are nested within one "variations" block — it would be way more intuitive if each defined axis were it's own block, available to the ui parameter and sorting, and emit events with that axis tag as key, instead of setting variations as object for all axes.

Avoid downloadable fonts via inspectors

Whichever font is previewed is loaded in such a way that it can easily be downloaded via Chrome Inspect and other similar tools.
Is this the intended behavior? Is there a way to avoid this?

Obviously, running a commercial font site where the fonts are downloadable with a few simple clicks is unacceptable.

Implement font fallback

Allow passing in even a fallback font name that gets attached to the css font-family of loaded fonts, so for example custom .notdef glyphs can be implemented by always using that fallback font.

E.g. the same that can now be "strapped on" after the effect with events, but instead as part of the fonts object as a fallbackFontName or similar:

fs.root.addEventListener("fontsampler.events.fontrendered", setFallback);
function setFallback(e) {
	var tester = e.target.querySelector("[data-fsjs='tester']");
	if (tester) {
		tester.style.fontFamily = tester.style.fontFamily + ", 'fallback'";
	}
}

Preview all styles at once instead of dropdown

Let's say there are 54 styles (3 widths, 9 weights with italics). The viewer will be annoyed to check the weights from the dropdown menu. Instead, all the styles can be shown at once, the user can just scroll to check how the text looks by keeping the text area separate from the sampler.

image

Extend API

Methods for:

  • toggling lazyload behaviour
  • destroying instances
  • more robust value setting (particularly variable fonts)

would be nice.

Download Button

Would be really nice to have an optional free download button built into the grid.

"No options defined for block variation"

I'm trying to get a variable axis, I've followed the example from
https://underscoretype.github.io/fontsampler-js/variable.html

I've added the axes and instances to the font var
name: "VariableFontName",
files: ["VariableFontFile.woff2"],
  axes: ["wght"],
  instances: [
  "wght 500, | VariableFontName Regular",]

I've added a variation element
order: ["tester", ["fontsize", "variation", "fontfamily"]],

and I've tried to define that element
variation: {
axes: [{
tag: "wght",
init: 400,
min: 250,
max: 900,
step: 10,
label: "Weight"
}]
},

but I'm still getting the error. Am I missing something? I couldn't find any more documentation on variable font support.

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.