import '../../assert/js/assert.js';
import '../../globals.js';
// Copyright 2016-2024, University of Colorado Boulder
/**
 * MathSymbolFont is the font used for math symbols (e.g. 'x', 'y') in PhET sims.
 * See https://github.com/phetsims/scenery/issues/545
 *
 * @author Chris Malley (PixelZoom, Inc.)
 */
import DerivedStringProperty from '../../axon/js/DerivedStringProperty.js';
import optionize from '../../phet-core/js/optionize.js';
import StringUtils from '../../phetcommon/js/util/StringUtils.js';
import { Font } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import sceneryPhet from './sceneryPhet.js';
const DEFAULT_STYLE = 'italic';
class MathSymbolFont extends Font {
    constructor(providedOptions) {
        // convenience constructor: new MathSymbolFont( {number|string} size )
        if (typeof providedOptions === 'number' || typeof providedOptions === 'string') {
            providedOptions = {
                size: providedOptions
            };
        }
        const options = optionize()({
            family: MathSymbolFont.FAMILY,
            style: DEFAULT_STYLE
        }, providedOptions);
        super(options);
    }
    /**
     * 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
     */
    static getRichTextMarkup(text, style = DEFAULT_STYLE) {
        assert && assert(Font.isFontStyle(style), `invalid style: ${style}`);
        return StringUtils.fillIn('<span style=\'font-family: {{family}};font-style: {{style}}\'>{{text}}</span>', {
            family: MathSymbolFont.FAMILY,
            style: style,
            text: text
        });
    }
    /**
     * Wraps a dynamic string in RichText markup that will display the string in the same font as MathSymbolFont.
     */
    static createDerivedProperty(symbolStringProperty, providedOptions) {
        const options = providedOptions || {};
        return new DerivedStringProperty([symbolStringProperty], symbolString => MathSymbolFont.getRichTextMarkup(symbolString, options.style || DEFAULT_STYLE), {
            tandem: options.tandem || Tandem.OPT_OUT
        });
    }
}
MathSymbolFont.FAMILY = '"Times New Roman", Times, serif';
export default MathSymbolFont;
sceneryPhet.register('MathSymbolFont', MathSymbolFont);
//# sourceMappingURL=MathSymbolFont.js.map