예제 #1
0
  public static void main(String[] args) {

    Font font = new Font("Helvetica", Font.BOLD, 24);

    FontFactory ff = new FontFactory(Alphabet.getDefaultAlphabet(), font);
    AssemblyLine line = ff.getAssemblyLine();

    Paint redYellowPaint = new GradientPaint(0, 0, Color.RED, 15, 15, Color.YELLOW, true);
    Paint greenWhitePaint = new GradientPaint(0, 0, Color.BLACK, 15, 0, Color.GREEN, true);

    line.addStage(new Clear());
    line.addStage(new DrawCharacter(Color.WHITE, false));

    // ff.addRenderer();
    // ff.addRenderer(new DrawCharacterOutline(Color.GREEN));

    line.addStage(new BinaryDilation(Color.WHITE, 3));
    // line.addStage(new BinaryErosion(Color.WHITE,3));
    // ff.addRenderer(new Convolution(Kernel.createGaussianKernel(3, 1.5), true));

    // line.addStage(new DrawCharacter(Color.WHITE, false));

    line.addStage(new PixelReplacer(redYellowPaint, Color.WHITE));
    line.addStage(new DrawCharacter(Color.CYAN, false));

    line.addStage(new PixelReplacer(greenWhitePaint, Color.CYAN));
    // ff.addRenderer(new Convolution(Kernel.createGaussianKernel(3, 1.4), true));

    // ff.addRenderer(new BinaryDilation(Color.RED, 3));
    // ff.addRenderer(new AWTFontRenderer());
    // line.addStage(new DrawCharacter(Color.BLACK, true));

    ff.createFont();
  }
예제 #2
0
 public ScreenText(final String fontName, final int style, final int size) {
   super();
   this.m_textRenderer = null;
   final Font font = FontFactory.createFont(fontName, style, size);
   if (font != null) {
     if (font instanceof BMFTexturedFont) {
       ((BMFTexturedFont) font).setMonospaced();
     }
     this.m_textRenderer = TexturedFontRendererFactory.createTextRenderer(font);
   }
   this.m_textRenderer.setColor(0.8f, 0.8f, 0.8f, 1.0f);
 }
  /** @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);
  }
  /**
   * 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;
  }