GithubHelp home page GithubHelp logo

isabella232 / html-text Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pixijs/html-text

0.0 0.0 0.0 323 KB

Multi-Style Text Rendering Plugin for PixiJS

Home Page: https://www.npmjs.com/package/@pixi/text-html

JavaScript 100.00%

html-text's Introduction

PixiJS HTMLText

Node.js CI

An alternative to PIXI.Text that works with PixiJS v5 (both WebGL and Canvas), however, it has some advantages:

  • Supports HTML tags for styling such as <strong>, or <em>, as well as <span style="">
  • Better support for emojis and other HTML layout features, better compatibility with CSS line-height and letter-spacing.

Disadvantages:

  • Unlike PIXI.Text, HTMLText rendering will vary slightly between platforms and browsers. HTMLText uses SVG/DOM to render text and not Context2D's fillText like PIXI.Text.
  • Performance and memory usage is on-par with PIXI.Text (that is to say, slow and heavy)
  • Only works with browsers that support <foreignObject>, i.e., no Internet Explorer support.
  • Only supports web-safe fonts for the fontFamily attribute.

Install

npm install @pixi/text-html
yarn add @pixi/text-html

Usage

import { HTMLText } from '@pixi/text-html';
import { TextStyle } from '@pixi/text';

// Can use the TextStyle class found in @pixi/text
const style = new TextStyle({ fontSize: 20 });

// Make a new HTMLText object
const text = new HTMLText("Hello World", style);

Styles

Not all styles and values are compatible between PIXI.Text, mainly because Text is rendered using a DOM element instead of Context2D's fillText API.

Supported

  • fill
  • fontFamily (web-safe fonts only)
  • fontSize
  • fontWeight
  • fontStyle
  • fontVariant
  • letterSpacing
  • align (also supports "justify")
  • padding
  • breakWords
  • lineHeight
  • wordWrap
  • wordWrapWidth
  • strokeThickness
  • dropShadow
  • dropShadowAngle
  • dropShadowDistance
  • dropShadowBlur
  • dropShadowColor
  • trim
  • stroke
  • strokeThickness

Values may differ slightly from PIXI.Text rendering.Appearance may differ slightly between different browsers.

Unsupported

  • fillGradientStops
  • fillGradientType
  • miterLimit
  • textBaseline
  • whiteSpace

Example

https://pixijs.io/html-text/demo/

Documentation

https://pixijs.io/html-text/docs/

html-text's People

Contributors

bigtimebuddy avatar

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.