Re: Fractional Metrics
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 philip.r...@oracle.com To: Jeff Martin j...@reportmill.com, openjfx-dev@openjdk.java.net Mailing openjfx-dev@openjdk.java.net Date: 04/03/2014 10:40 PM Subject:Re: Fractional Metrics Sent by:openjfx-dev openjfx-dev-boun...@openjdk.java.net 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.
Re: Fractional Metrics
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, ngalarn...@abinitio.com 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 philip.r...@oracle.com To: Jeff Martin j...@reportmill.com, openjfx-dev@openjdk.java.net Mailing openjfx-dev@openjdk.java.net Date: 04/03/2014 10:40 PM Subject:Re: Fractional Metrics Sent by:openjfx-dev openjfx-dev-boun...@openjdk.java.net 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.
Re: Fractional Metrics
On 4/4/2014 6:41 AM, ngalarn...@abinitio.com 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? No it does not mean that. The way to do this is to get the bounds of a Text node containing the string. -phil. Neil From: Phil Race philip.r...@oracle.com To: Jeff Martin j...@reportmill.com, openjfx-dev@openjdk.java.net Mailing openjfx-dev@openjdk.java.net Date: 04/03/2014 10:40 PM Subject: Re: Fractional Metrics Sent by: openjfx-dev openjfx-dev-boun...@openjdk.java.net 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. /
Re: Fractional Metrics
If you don't mind using internal APIs then: TextLayoutFactory factory = Toolkit.getToolkit().getTextLayoutFactory(); TextLayout layout = factory.createLayout(); layout.setContent(BlaBla, Font.getDefault().impl_getNativeFont()); BaseBounds b = layout.getBounds(); I find it strange the canvas does not have an API to calculate the boudsn of a string. Tom On 04.04.14 18:48, Phil Race wrote: On 4/4/2014 6:41 AM, ngalarn...@abinitio.com 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? No it does not mean that. The way to do this is to get the bounds of a Text node containing the string. -phil. Neil From: Phil Race philip.r...@oracle.com To: Jeff Martin j...@reportmill.com, openjfx-dev@openjdk.java.net Mailing openjfx-dev@openjdk.java.net Date: 04/03/2014 10:40 PM Subject: Re: Fractional Metrics Sent by: openjfx-dev openjfx-dev-boun...@openjdk.java.net 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. /
Fractional Metrics
Is there a way to turn off FractionalMetrics in Canvas.fillText() or Text? Also, does text rendering perform kerning, and if so, can I disable that? What I really need is to know the x position (or advance) of each character in a rendered string. jeff
Re: Fractional Metrics
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