You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There will be differences between the various bounds for text, depending on whether we are using the actual string, or generic measurements for the font. This applies to textAscent(), textDescent(), textWidth() and textBounds(), and also for rendering text in user-specified bounding boxes. It is likely that we will want to support both measurements. An option for textAscent/textDescent is to return different measurement depending on whether the user passes in a specific string or not. A different option, which works better for textWidth/textBounds, would be to include a 2nd set of functions in the API, something like fontWidth() and fontBounds(), which return the more generic measurements.
Support non-pixel font metrics (em, etc). Conversion between units is not straightforward - the best way to do this is to use one or more hidden DOM elements. Once we have these we may want to use them for other properties and text measurement for the sake of consistency.
Should textBounds (and fontBounds()) take rectMode into account ? yes
Variable-fonts: appears there is no cross-browser way to support these on the canvas (correct me if I'm wrong)
New functions: p5.textBounds, p5.fontBounds, p5.fontWidth, p5.textToPoints, p5.textProp, p5.textProps
All subproperties of the ‘font’ property are first reset to their initial values, including those listed above plus ‘font-size-adjust’, ‘font-kerning’, all subproperties of ‘font-variant’, and ‘font-feature-settings’, but not ‘font-synthesis’. Then, those properties that are given explicit values in the ‘font’ shorthand are set to those values. For a definition of allowed and initial values, see the previously defined properties. For reasons of backwards compatibility, it is not possible to set ‘font-size-adjust’ to anything other than its initial value using the ‘font’ shorthand property; instead, use the individual property.
Other options considered (for historical purposes)
Extract minimal opentype.js or typr.js, maintain split rendering, update the current API according to tickets
Use some other 3rd party option for glyph paths (see below)
dhowe
changed the title
Possible paths for typography (as part of p5-2.0)
Possible paths for typography (as part of p5.js 2.0)
Sep 16, 2024
dhowe
changed the title
Possible paths for typography (as part of p5.js 2.0)
Possible paths for typography module revamp (as part of p5.js 2.0)
Sep 16, 2024
Typography module revamp for p5.js 2.0
see pr #7356
width
}
px
Issues
textAscent()
,textDescent()
,textWidth()
andtextBounds()
, and also for rendering text in user-specified bounding boxes. It is likely that we will want to support both measurements. An option fortextAscent
/textDescent
is to return different measurement depending on whether the user passes in a specific string or not. A different option, which works better fortextWidth
/textBounds
, would be to include a 2nd set of functions in the API, something likefontWidth()
andfontBounds()
, which return the more generic measurements.textBounds
(andfontBounds()
) take rectMode into account ? yesNotes on the css font property spec###
The ‘font’ property is, except as described below, a shorthand property for setting ‘font-style’, ‘font-variant’, ‘font-weight’, ‘font-stretch’, ‘font-size’, ‘line-height’, ‘font-family’ at the same place in the stylesheet. Values for the ‘font-variant’ property may also be included but only those supported in CSS 2.1 -> [normal | small-caps]
All subproperties of the ‘font’ property are first reset to their initial values, including those listed above plus ‘font-size-adjust’, ‘font-kerning’, all subproperties of ‘font-variant’, and ‘font-feature-settings’, but not ‘font-synthesis’. Then, those properties that are given explicit values in the ‘font’ shorthand are set to those values. For a definition of allowed and initial values, see the previously defined properties. For reasons of backwards compatibility, it is not possible to set ‘font-size-adjust’ to anything other than its initial value using the ‘font’ shorthand property; instead, use the individual property.
Other options considered (for historical purposes)
Some of the tradeoffs here, and more info here
List of external font-parsing libs:
The text was updated successfully, but these errors were encountered: