Giter Club home page Giter Club logo

hlglyphme's Introduction

GlyphMe

haxelib git hlglyphme https://github.com/rayloi777/hlglyphme.git

Very half-assed TTF support for heaps using stb_truetype. I have never written any c/c++ code, bindings or font/text related code, so I don't really know what I'm doing. If you search for "HELP" in the project, you'll find some spots where I'd need help in particular. Other than that, this works for me and as I'm busy with my own project I won't be improving this too much. Feel free to fork this or whatever and make it better. Right now it only renders glyphs and uses heaps to do the actual text layout stuff. There is no text shaping, ligatures or anything fancy. Also even though stb_truetype supports some otf files most of the ones I have tried did not work correctly.

I don't know if the build.bat will work for you but the binding is just one source file so you will be able to figure it out! :)

sample image

Basic Usage:

using glyphme.GlyphMe;

class Sample extends hxd.App {

	override function init() {
		hxd.Res.initLocal();

		// directly creating a Font instance with pixel height 64 to be used in standard heaps components
		final font = hxd.Res.NotoSans_Regular.toTrueTypeFont(64);

		// optional: adding fallbacks for unsupported glyphs 
		font.addFallbacks(hxd.Res.SourceSansPro_Regular.toTrueTypeFontFile().getInfos());
		font.addFallbacks("C:/Windows/Fonts/malgunsl.ttf".loadTrueTypeFontFile().getInfos()); // standard windows korean font

		// creating standard heaps text
		final text = new h2d.Text(font, s2d);
		text.textAlign = Center;
		text.text = "Hello TTF!\n 안녕하세요 TTF!";
		text.x = s2d.width / 2;
		text.y = s2d.height / 2;
        
		// generating an atlas which will contain all glyphs in the text 
		// because dynamic glyph generation is not supported yet. 
		font.generateAtlas({atlasSize: 256}, [text.text]);
	}

	static function main() {
		new Sample();
	}
}

Security Warning

Directly from stb_truetype:

NO SECURITY GUARANTEE -- DO NOT USE THIS ON UNTRUSTED FONT FILES
This library does no range checking of the offsets found in the file,
meaning an attacker can use it to read arbitrary memory.

hlglyphme's People

Contributors

rayloi777 avatar

Watchers

 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.