phetsims / curve-fitting

"Curve Fitting" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
6 stars 3 forks source link

Use MathSymbolsFont.getRichTextMarkup #172

Open pixelzoom opened 2 years ago

pixelzoom commented 2 years ago

I see this kind of thing in curve-fitting and area-model-common, search for <i style='font-family:

// PointNode.js
const Y_PATTERN = `<i style='font-family:${CurveFittingConstants.EQUATION_SYMBOL_FONT.family}'>{{y}}</i>`;
...
        y: StringUtils.fillIn( Y_PATTERN, {
          y: ySymbolString
        } )

FYI, MathSymbolsFont provides support for this:

  /**
   * Converts a string to the markup needed to display that string with RichText, using the same family as MathSymbolFont.
   * @param text
   * @param [style] - see Font options.style
   */
  public static getRichTextMarkup( text: string, style = DEFAULT_STYLE ): string {

In the PointNode.js example above, Y_PATTERN is unecessary, and it becomes:

        y: MathSymbolsFont.getRichTextMarkup( ySymbolString )