/** @param font */
  @Override
  public void loadFont(Font font) {
    FontFactory fontFactory = getFontFactoryFromPipeline();
    String fullName = font.getName();
    if (!embeddedFontsLoaded && !fontFactory.isPlatformFont(fullName)) {
      loadEmbeddedFonts();
    }

    // find the native Prism Font object based on this JavaFX font. At the
    // conclusion of this method, be sure to set the name, family, and
    // style on the Font object via the setNativeFont method.

    // the Prism font we're trying to find
    PGFont prismFont = fontFactory.createFont(fullName, (float) font.getSize());

    // update the name variable to match what was actually loaded
    String name = prismFont.getName();
    String family = prismFont.getFamilyName();
    String style = prismFont.getStyleName();
    font.impl_setNativeFont(prismFont, name, family, style);
  }
 @Override
 public FontMetrics getFontMetrics(Font font) {
   if (font != null) {
     PGFont prismFont = (PGFont) font.impl_getNativeFont();
     Metrics metrics = PrismFontUtils.getFontMetrics(prismFont);
     // TODO: what's the difference between ascent and maxAscent?
     float maxAscent = -metrics.getAscent(); // metrics.getMaxAscent();
     float ascent = -metrics.getAscent();
     float xheight = metrics.getXHeight();
     float descent = metrics.getDescent();
     // TODO: what's the difference between descent and maxDescent?
     float maxDescent = metrics.getDescent(); // metrics.getMaxDescent();
     float leading = metrics.getLineGap();
     return FontMetrics.impl_createFontMetrics(
         maxAscent, ascent, xheight, descent, maxDescent, leading, font);
   } else {
     return null; // this should never happen
   }
 }
  /**
   * Searches for an appropriate font based on the font family name and weight and posture style.
   * This method is not guaranteed to return a specific font, but does its best to find one that
   * fits the specified requirements.
   *
   * <p>For SDK/runtime fonts, we will attempt to match properties to a SDK/runtime fonts. If a
   * specific SDK font is not found in the runtime JAR, the font loading will revert to FontFactory
   * default font, rather then finding closest matching available SDK font. This is how SDK font
   * loading was handled in the past.
   *
   * @param family The family of the font
   * @param weight The weight of the font
   * @param posture The posture or posture of the font
   * @param size The point size of the font. This can be a fractional value
   * @profile desktop
   */
  @Override
  public Font font(String family, FontWeight weight, FontPosture posture, float size) {

    FontFactory fontFactory = getFontFactoryFromPipeline();
    if (!embeddedFontsLoaded && !fontFactory.isPlatformFont(family)) {
      loadEmbeddedFonts();
    }

    // REMIND. Some day need to have better granularity.

    boolean bold = weight != null && weight.ordinal() >= FontWeight.BOLD.ordinal();
    boolean italic = posture == FontPosture.ITALIC;
    PGFont prismFont = fontFactory.createFont(family, bold, italic, size);

    // Create Font and set implementation
    Font fxFont =
        Font.impl_NativeFont(
            prismFont,
            prismFont.getName(),
            prismFont.getFamilyName(),
            prismFont.getStyleName(),
            size);
    return fxFont;
  }
 @Override
 public float computeStringWidth(String string, Font font) {
   PGFont prismFont = (PGFont) font.impl_getNativeFont();
   return (float) PrismFontUtils.computeStringWidth(prismFont, string);
 }
 @SuppressWarnings("deprecation")
 private Font createFont(PGFont font) {
   return Font.impl_NativeFont(
       font, font.getName(), font.getFamilyName(), font.getStyleName(), font.getSize());
 }