Skip to content

Conversation

@dhowe
Copy link
Contributor

@dhowe dhowe commented Nov 3, 2024

PR for typography module 2.0

There are a number of new functions added to the p5 prototype:

  • textBounds: tight bounds, now supported for all fonts, not just those with paths as in v1
  • fontBounds: gives the (loose) bounds for the font, regardless of characters used
  • fontWidth: gives the (loose) width of a string of given length in the font, regardless of the characters
  • textProperty: allows set/get for one of about 20 font-related properties
  • textProperties: allows batch set/get for one or more of about 20 font-related properties
  • textToPoints: a correct version via typr.js (need to support for path sampling)
  • textToPaths: returns a more complex object to allow rendering of paths
  • textDirection: exposing this directly for wider access
  • textWeight: specifies weight via num (100-900) or keyword, requires support in font (useful with variable fonts)
  • fontAscent: gives the ascent for the font itself (the max of any glyph)
  • fontDescent: gives the descent for the font itself (the max of any glyph)

Also to be included in p5.Font:

  • textToContours
  • textToModel

Issues/Questions/Notes:

  • Need better examples in arabic and other RTL languages for testing
  • To pass a complete css-font-string directly, call textFont() with the string as first argument (which must include family and size, as per HTML5 spec for font shorthand)

@davepagurek davepagurek merged commit 584504d into processing:dev-2.0 Dec 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants