I have a couple of solutions for this right now, but neither are optimal:
1.
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(),getDefaultConfiguration()
.createCompatibleImage(1,
1).createGraphics().getFontMetrics(font).stringWidth(string)
2. new
javafx.scene.text.Text().setFont(font).setText(string).prefWidth(-1) // Some
poetic license here
jeff
On Apr 4, 2014, at 8:41 AM, [email protected] wrote:
> I'm sorry if this is redundant, but does this mean there is no way to find
> out the size (length & height) of a String as it will appear on the
> screen?
>
> What about the size of a String as it will be printed?
>
>
> Neil
>
>
>
>
> From: Phil Race <[email protected]>
> To: Jeff Martin <[email protected]>, "[email protected]
> Mailing" <[email protected]>
> Date: 04/03/2014 10:40 PM
> Subject: Re: Fractional Metrics
> Sent by: "openjfx-dev" <[email protected]>
>
>
>
> On 4/3/14 6:13 PM, Jeff Martin wrote:
>> Is there a way to turn off FractionalMetrics in Canvas.fillText() or
> Text?
>
> No. At least not via any supported API.
>>
>> Also, does text rendering perform kerning, and if so, can I disable
> that?
>
> No.
>>
>> What I really need is to know the x position (or advance) of each
> character in a rendered string.
>
> It would need new API. And characters != glyphs. Counting char advances
> has been doomed for decades ...
>
> -phil.
>
>>
>> jeff
>
>
>
> NOTICE from Ab Initio: This email (including any attachments) may contain
> information that is subject to confidentiality obligations or is legally
> privileged, and sender does not waive confidentiality or privilege. If
> received in error, please notify the sender, delete this email, and make
> no further use, disclosure, or distribution.