All Projects → inorganik → strokeText.js

inorganik / strokeText.js

Licence: MIT license
Simple, pixel-perfect text stroking for the web.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to strokeText.js

Wiggles-iOS
Beautiful Puppy adoption app built to Demonstrate the SwiftUI and MVVM Architecture
Stars: ✭ 174 (+480%)
Mutual labels:  ui-design
alfred-string-operations
Perform string operations to clipboard content
Stars: ✭ 70 (+133.33%)
Mutual labels:  text
cs paint
Vulkan rendering library for graphics and text
Stars: ✭ 79 (+163.33%)
Mutual labels:  text
ansiart2utf8
Processes legacy BBS-style ANSI art (ACiDDraw, PabloDraw, etc.) to UTF-8. Escape codes and line endings are processed for terminal friendliness.
Stars: ✭ 32 (+6.67%)
Mutual labels:  text
content inspector
Fast inspection of binary buffers to guess/determine the type of content
Stars: ✭ 28 (-6.67%)
Mutual labels:  text
passport
A Kotlin-based Android view validation library with a simple DSL.
Stars: ✭ 31 (+3.33%)
Mutual labels:  text
material-chip-view
Material Chip view. Can be used as tags for categories, contacts or creating text clouds
Stars: ✭ 1,300 (+4233.33%)
Mutual labels:  text
awesome-flutter-ui
10+ flutter(android, ios) UI design examples ⚡ - login, books, profile, food order, movie streaming, walkthrough, widgets
Stars: ✭ 848 (+2726.67%)
Mutual labels:  ui-design
Travia
Travia is an app for Travellers. It provides features like choosing destination, booking tickets and organizing whole trip.
Stars: ✭ 13 (-56.67%)
Mutual labels:  ui-design
CheckableTextView
A simple and flexible Checked TextView or Checkable TextView
Stars: ✭ 108 (+260%)
Mutual labels:  text
hive-desktop
🐝 A small LAN chat app
Stars: ✭ 69 (+130%)
Mutual labels:  ui-design
awesome-neumorphism
A curated list of awesome Neumorphism resources.
Stars: ✭ 15 (-50%)
Mutual labels:  ui-design
STTextView
📝 STTextView is a light-weight library that adds a placeholder to the UITextView.
Stars: ✭ 36 (+20%)
Mutual labels:  text
Material-Design-Android
My stash for all things material, animations, typography, iconography, transitions, Animated VD, Color Palette API, UI design, and more.
Stars: ✭ 38 (+26.67%)
Mutual labels:  ui-design
Weather-Forecast
Weather Forecast is a simple app that shows you a weather. It comes with your standard features like your daily and hourly forecast along with access to additional information
Stars: ✭ 59 (+96.67%)
Mutual labels:  ui-design
heredoc
Package heredoc provides the here-document with keeping indent.
Stars: ✭ 89 (+196.67%)
Mutual labels:  text
react-edit-text
Simple 'click to edit' editable text component for React
Stars: ✭ 28 (-6.67%)
Mutual labels:  text
search-all-tabs
search all opened tabs in a browser popup and see the matching previews using Xapain or Lunrjs engines.
Stars: ✭ 48 (+60%)
Mutual labels:  text
focus-snail
Leaves a trail from the previously focused element.
Stars: ✭ 23 (-23.33%)
Mutual labels:  ui-design
bruno
An enterprise-class package of Flutter components for mobile applications. ( Bruno 是基于一整套设计体系的 Flutter 组件库。)
Stars: ✭ 1,802 (+5906.67%)
Mutual labels:  ui-design

strokeText.js

Simple, pixel-perfect text stroking for the web. StrokeText.js adds strokes or "outlines" to live text. Doing this with CSS is scantly and poorly supported, so javascript to the rescue!

  • Strokes do not overlap your text like they do with -webkit-text-stroke
  • Supports nearly all browsers except IE8 and below
  • Selectable text
  • Dependency-free

Live demo

strokeText.js uses the canvas API to draw stroked text in a container with your text element positioned absolutely on top of it, allowing your text element to remain intact and selectable.

Usage

Install via npm with the package name stroketext.js or simply include strokeText.min.js in your project.

For each text element that you desire to stroke, create an instance, which accepts an ID string or reference to your text element:

var strokeText = new StrokeText('targetId');

Then call stroke(), which takes 2 args:

  • stroke width
  • stroke color
strokeText.stroke(3, 'white'); 

You can also call reset() to remove the stroke.

strokeText.reset();

Calling stroke() calls reset() before it does anything, so you can use stroke() to update the stroke at any time after initialization.

Options

You can optionally pass options (totally optional) to the initializer:

// defaults shown
var options = {
	lineCap: 'round', // ['round', 'butt', 'square']
	lineJoin: 'round', // ['bevel', 'round', 'miter']
	miterLimit: 10, // control spikeyness
	lineDashArray: [0, 0], // for dashed lines: [line, gap]
	debug: false, // examine measurements and properties used
	disableForFirefox: false // some fonts don't stroke well in firefox, bc they are rendered at varying baselines
}
var strokeText = new StrokeText('targetId', options);

Making strokeText.js responsive

Respond to viewport change events:

var resizeTimeout;
function handleViewportChange() {
	// timeout to debounce
	clearTimeout(resizeTimeout);
	resizeTimeout = setTimeout(function() {
		// reset and re-init so strokeText.js can re-evaluate container size
		strokeText.reset(); 
		strokeText = new StrokeText('targetId');
		strokeText.stroke(3, 'white'); 
	}, 100);
}
window.onresize = handleViewportChange;
window.onorientationchange = handleViewportChange;

Angular

Here's an example of how to use strokeText.js in an Angular directive, and react to text changes: https://stackblitz.com/edit/stroketext-angular

jQuery

A jQuery plugin is included, but can't be installed via npm. It's dependent upon strokeText.js.

Known issues

  • In Firefox, some fonts (usually @font-face fonts) don't stroke well because they are rendered at a varying baseline. If this is your case, use the disableForFirefox option.
  • Does not support text-decoration, e.g. strike-through or underline.
  • Very thick strokes on certain fonts can leave cutouts on circle shapes like periods or dotted characters.
  • Emojis don't get stroked 😬 due to the limitations of canvas.

TODO

  • Better Firefox support. Due to a very old Firefox bug, canvas renders baselines of some fonts differently than html text. The issue is easily witnessed on the demo in Firefox. Some fonts have the stroke lined up perfectly, but for others it is too high, to a varying degree.

Contributing

  • Do your work on strokeText.js, please follow existing formatting conventions
  • In terminal, cd to the strokeText.js directory
  • Run npm i
  • Run npm run build to create the minified strokeText module in the dist folder

Fiddle: https://jsfiddle.net/cburoure/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].