Giter Club home page Giter Club logo

htmlbitmapfonts's Introduction

Starling extension for using bitmap fonts with simplified html tags for styling texts

sorry all asdoc and comments are in french, i will change it soon


HTMLTextField

HTMLTextField is a Starling TextField for using with simplified html notation (just for styling: no links, no images...).

ACCEPTED TAGS:

  • bold : <b></b>;
  • italic : <i></i>;
  • size : <size="10"></size> or <s="10"></s>;
  • colors : don't forget '0x' or '#' !
  • solid :
    <color="0xFF0000"></color> or
    <c="0xFF0000"></c>;
  • gradient up / down :
    <color="0xFF0000,0xFFFFFF"></color> or
    <c="0xFF00000xFFFFFF"></c>;
  • gradient up-left/up-right/down-left/down-right :
    <color="0xFF0000,0xFFFFFF,0x000000,0x0000FF"></color> or
    <c="0xFF0000,0xFFFFFF,0x000000,0x0000FF"></c>

HTMLTextField uses HTMLBitmapFonts instead of the tradtional BitmapFont.


To add a font for use with HTMLtextField you must add them to HTMLTextField with the static method HTMLTextField.registerBitmapFont this fonction accept as xml value the same XML as traditional BitmapFont.

They can be generated with tools like :

Personnaly i use AssetManager for loading fonts and i just modified it like this:
in loadQueue -> processXML :

// if I parse fontHTML -> load the font for HTMLTextFields
else if( rootNode == "fontHTML" )
{
	name 		= [email protected]();
	fileName 	= getName([email protected]());
	isBold 		= xml.info.@bold == 1;
	isItalic 	= xml.info.@italic == 1;
	
	log("Adding html bitmap font '" + name + "'" + " _bold: " + isBold + " _italic: " + isItalic );
	
	fontTexture = getTexture( fileName );
	HTMLTextField.registerBitmapFont( fontTexture, xml, xml.info.@size, isBold, isItalic, name.toLowerCase() );
	removeTexture( fileName, false );
	
	mLoadedHTMLFonts.push( name.toLowerCase() );
}

  • Only one font name can be used in the HTMLTextField, it can only change size, bold, italic, and color
  • All font styles must be on the same atlas as the textField is drawed on a QuadBatch
  • No scales are applied on the texts, when adapting the font size it just search within the available sizes
  • HTMLBitmapFont has a static property globalScale (default 1), you can set it to the scale applied on the starling viewport. It will search the best font size to adapt the desired font size without scaling them.

htmlbitmapfonts's People

Contributors

binouze avatar

Watchers

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