All Projects → manaflair → Text Layout

manaflair / Text Layout

Fast implementation of a browser-like text layout engine, for Node and browsers

Programming Languages

javascript
184084 projects - #8 most used programming language
cpp
1120 projects

Labels

Projects that are alternatives of or similar to Text Layout

Javascript Obfuscator
A powerful obfuscator for JavaScript and Node.js
Stars: ✭ 8,204 (+43078.95%)
Mutual labels:  browser
Cef4delphi
CEF4Delphi is an open source project to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC for Windows, Linux and MacOS.
Stars: ✭ 785 (+4031.58%)
Mutual labels:  browser
Hackbrowser
A hackable, cross-platform Chromium-based browser written in JS
Stars: ✭ 16 (-15.79%)
Mutual labels:  browser
Auth0.js
Auth0 headless browser sdk
Stars: ✭ 755 (+3873.68%)
Mutual labels:  browser
React Container Query
📦 Modular responsive component
Stars: ✭ 788 (+4047.37%)
Mutual labels:  browser
Triflejs
Headless automation for Internet Explorer
Stars: ✭ 815 (+4189.47%)
Mutual labels:  browser
Interactivegraph
InteractiveGraph provides a web-based interactive visualization and analysis framework for large graph data, which may come from a GSON file, or an online Neo4j graph database. InteractiveGraph also provides applications built on the framework: GraphNavigator, GraphExplorer and RelFinder.
Stars: ✭ 730 (+3742.11%)
Mutual labels:  browser
Is Online
Check if the internet connection is up
Stars: ✭ 894 (+4605.26%)
Mutual labels:  browser
Browser
Useragent analysis tool.浏览器分析判断工具 - 用户代理、操作系统信息
Stars: ✭ 789 (+4052.63%)
Mutual labels:  browser
Tridentsandbox
An In-Browser Scripting IDE for HTML5/Javascript
Stars: ✭ 5 (-73.68%)
Mutual labels:  browser
Beaker
An experimental peer-to-peer Web browser
Stars: ✭ 6,411 (+33642.11%)
Mutual labels:  browser
Cef2go
Go lang bindings for the Chromium Embedded Framework (CEF)
Stars: ✭ 780 (+4005.26%)
Mutual labels:  browser
Arbitrary Image Stylization Tfjs
Arbitrary style transfer using TensorFlow.js
Stars: ✭ 822 (+4226.32%)
Mutual labels:  browser
React Article Bucket
总结,积累,分享,传播JavaScript各模块核心知识点文章全集,欢迎star,issue(勿fork,内容可能随时修改)。webpack核心内容部分请查看专栏: https://github.com/liangklfangl/webpack-core-usage
Stars: ✭ 750 (+3847.37%)
Mutual labels:  browser
Gata
Bookmarks made better
Stars: ✭ 17 (-10.53%)
Mutual labels:  browser
Bigpicture.js
bigpicture.js is a Javascript library that allows infinite panning and infinite zooming in HTML pages.
Stars: ✭ 733 (+3757.89%)
Mutual labels:  browser
Exokit
Native VR/AR/XR engine for JavaScript 🦖
Stars: ✭ 809 (+4157.89%)
Mutual labels:  browser
Slack
🎉✨ Slack API client for Node and browsers.
Stars: ✭ 903 (+4652.63%)
Mutual labels:  browser
Karma Event Driver Ext
use webdriverio like api in browser with karma lol
Stars: ✭ 17 (-10.53%)
Mutual labels:  browser
Qutebrowser
A keyboard-driven, vim-like browser based on PyQt5.
Stars: ✭ 7,401 (+38852.63%)
Mutual labels:  browser

Text-Layout

Fast implementation of a browser-like text layout engine, for Node and browsers

Check out our other OSS projects!

Features

  • Soft-wraps any text to the given width
  • Automatically justifies the text to fit the specified width if requested
  • Can collapse text on demand (white-space: pre, but more configurable)
  • Keeps an internal state to map between the original and transformed text coordinates
  • Only updates the part of the text that has changed for better performances
  • Shipped as NPM package using WebAssembly (portable, even accross browsers)
  • Also available as a zero-dependencies C++ library

Currently not implemented:

  • Font width support (all characters are assumed monospaces)
  • Unicode support (all characters are assumed to be ASCII)

Installation

$> yarn add @manaflair/text-layout

Usage

const {TextLayout} = require(`@manaflair/text-layout/sync`);
const faker = require(`faker`);

const textLayout = new TextLayout();
textLayout.setConfiguration({columns: 80, justifyText: true});
textLayout.setSource(faker.lorem.paragraphs(10, `\n\n`));

console.log(textLayout.getTransformedSource());

Note that the library is also available through an asynchronous endpoint (used by default when requiring @manaflair/text-layout). You typically will want to use this endpoint if your code is expected to work within browsers, since they may disallow WebAssembly to be compiled in the main thread. Here's what the code looks like with the asynchronous initialization:

const tlPromise = require(`@manaflair/text-layout/async`);
const faker = require(`faker`);

tlPromise.then(({TextLayout}) => {
  const textLayout = new TextLayout();
  textLayout.setConfiguration({columns: 80, justifyText: true});
  textLayout.setSource(faker.lorem.paragraphs(10, `\n\n`));

  console.log(textLayout.getTransformedSource());
});

Tests

Testing the library

$> apt-get install catch
$> make tests DEBUG=1

Testing the JS module

$> yarn
$> node sources/run-tests.js

License (MIT)

Copyright © 2016 Maël Nison & Manaflair

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.

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].