如何调整JavaFX中的字母间距 [英] How to adjust letter-spacing in JavaFX

查看:407
本文介绍了如何调整JavaFX中的字母间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JavaFX2时,如何调整文本对象的字符间距?

When using JavaFX2, how can i adjust the letter-spacing between characters of a Text object?

欢迎使用代码或css中的示例。

Examples either in code or css are welcome.

推荐答案

我想知道这是否可能指向正确的方向。我找到了 此处 ...

I wonder if this might point you in the right direction. I found the information here...

这篇文章特别谈到字母间距...

This article talks specifically about letter spacing...

package addingfontinstyle;

import javafx.scene.effect.DropShadow;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.effect.light.DistantLight;
import javafx.scene.effect.light.SpotLight;
import javafx.scene.effect.Lighting;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextOrigin;
import javafx.stage.Stage;

Stage {
    title: "Text In Style"
    width: 450
    height: 500
    scene: Scene {
        content: [
            Text {
                effect: DropShadow {
                    offsetX: -10
                    offsetY: -10
                }
                font: Font {
                    name: "Arial"
                    letterSpacing: 0.20
                    size: 50
                }
                fill: Color.YELLOWGREEN
                stroke: Color.GREEN,
                strokeWidth: 3
                x: 15,
                y: 80
                content: "Hello World"
            },

            Text {
                effect: Lighting {
                    light: DistantLight {
                        azimuth: -135
                        elevation: 30
                    }
                    surfaceScale: 5
                }
                x: 10
                y: 200
                content: "Hello World"
                fill: Color.RED
                font: Font {
                    name: "Arial Bold"
                    letterSpacing: 0.20
                    size: 50
                }
            },
            Text {
                effect: Lighting {
                    light: SpotLight {
                        x: 0
                        y: 100
                        z: 50
                        pointsAtX: 400
                        pointsAtY: 0
                        pointsAtZ: 0
                        specularExponent: 2
                    }
                    surfaceScale: 5
                }
                textOrigin: TextOrigin.TOP
                x: 10
                y: 300
                content: "Hello World"
                fill: Color.RED
                font: Font {
                    name: "Arial Bold"
                    letterSpacing: 0.20
                    size: 50
                }
            },
            Text {
                effect: GaussianBlur {
                }
                x: 10
                y: 400
                content: "Hello World"
                fill: Color.GREEN
                font: Font {
                    name: "Arial Bold"
                    letterSpacing: 0.20
                    size: 50
                }
            }
        ]
    }
}

这篇关于如何调整JavaFX中的字母间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆