public static String styleText(SimpleAttributeSet attributes, String text) {

		// StyleConstants.Foreground  color: #00FF00;
		// StyleConstants.FontFamily  font-family: "Tahoma";
		// StyleConstants.FontSize  font-size: 40px;
		// StyleConstants.Italic  font-style: italic;
		// StyleConstants.Bold  font-weight: bold;

		String family = attributes.getAttribute(StyleConstants.FontFamily).toString();
		String size = attributes.getAttribute(StyleConstants.FontSize).toString();
		String style = "plain";
		String weight = "plain";
		Boolean isItalic = (Boolean) attributes.getAttribute(StyleConstants.Italic);
		Boolean isBold = (Boolean) attributes.getAttribute(StyleConstants.Bold);
		if (Boolean.TRUE.equals(isItalic)) {
			style = "italic";
		}

		if (Boolean.TRUE.equals(isBold)) {
			weight = "bold";
		}

		// color is optional and defaults to the containing component's color
		String color = "";
		Object colorAttribute = attributes.getAttribute(StyleConstants.Foreground);
		if (colorAttribute instanceof Color fgColor) {
			String hexColor = HTMLUtilities.toHexString(fgColor);
			color = "color: %s;".formatted(hexColor);
		}

		String escaped = escapeHTML(text);

		//@formatter:off
		return """
	<SPAN STYLE=\"%s font-family: '%s'; font-size: %spx; font-style: %s; font-weight: %s;\">\
	%s\
	</SPAN>
			""".formatted(color, family, size, style, weight, escaped);
		//@formatter:on
	}
Escapes and wraps the given text in {@code SPAN} tag with font attributes specified in the
given attributes.  Specifically, these attributes are used:

<UL>
<LI>{@link StyleConstants#Foreground} - {@link Color} object</LI>
<LI>{@link StyleConstants#FontFamily} - font name</LI>
<LI>{@link StyleConstants#FontSize} - size in pixels</LI>
<LI>{@link StyleConstants#Italic} - true if italic</LI>
<LI>{@link StyleConstants#Bold} - true if bold</LI>
</UL>
<P>
See {@link GAttributes} for a convenient way to create the correct attributes for a font and
color.

@param attributes the attributes
@param text the content to style
@return the styled content
@see GAttributes
Ghidra/Framework/Gui/src/main/java/ghidra/util/HTMLUtilities.java