kas-gui / kas-text

Rich text processing
Apache License 2.0
58 stars 2 forks source link

Using kas-text outside of kas-gui #43

Closed samyak-jain closed 3 years ago

samyak-jain commented 3 years ago

I was wondering if it's possible to use kas-text outside of kas-gui? There don't seem to be any examples in this repository that are specifically using only kas-text.

Also, is it possible to do the following

dhardy commented 3 years ago

I was wondering if it's possible to use kas-text outside of kas-gui?

As you can see, kas-text is built with KAS in mind, but with some allowances for a more generic API, and avoiding any direct dependencies on KAS (e.g. using its own Vec2 type). There's some scope for change here, though also lock-in to some decisions (the design assumes state-retention for each text object, unlike, say glyph_brush).

An independent example could for example print out glyph positions, but IMO that's not very useful without some mechanism for verifying the result. Attaching a renderer just for an example is too much (probably).

Select a specific font

Font selection definitely needs some improvement. Yes, I think it is possible to use a specific font via e.g. FamilyName::Title("Arial"). This is an area that needs improvement IMO; feel free to make a new issue or PR about it.

Rasterize a glyph?

This is deliberately out of scope. There are already multiple libraries with some support for rasterisation; font-kit as mentioned, glyph_brush / ab_glyph, fontdue.

samyak-jain commented 3 years ago

Makes sense. Thanks for clarifying.

dhardy commented 3 years ago

50 adds glyph raster support along with a key type that may be used in a HashMap for glyph caching. This still leaves significant work to an external library: setting up a texture atlas and some system for painting glyphs (see how KAS does this).