Skip to main content

[JAVA2D] Discovering physical fonts

1 reply [Last post]
Anonymous

Resending this without the signature. The mailing list Subject
manipulation breaks the signature, and (some?) MS mail agents then won't
display the message.

I'm looking at issues involved in embedding font files in PDF. Java2D
is doing an increasingly impressive job of providing font facilities,
most recently kerning and ligatures, to developers with a minimum of
fuss. However, in situations like font embedding, the developer needs
access to the physical font. Is it possible to discover the physical
file within J2D?

Peter
--
Peter B. West
Folio
---
[This E-mail has been scanned for viruses but it is your responsibility
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Chris Nokleberg

On Fri, Jan 20, 2006 at 05:38:14PM +0000, Peter B. West wrote:
> I'm looking at issues involved in embedding font files in PDF. Java2D
> is doing an increasingly impressive job of providing font facilities,
> most recently kerning and ligatures, to developers with a minimum of
> fuss. However, in situations like font embedding, the developer needs
> access to the physical font. Is it possible to discover the physical
> file within J2D?

I need this as well, for the same reason. Anyone who is creating PDFs
will need this. There isn't any way to do this using the public Java
APIs, so currently I resort to a scan of hard-coded system-dependent
directories, with an option for the user to add/remove paths to the
search list. It is pretty ugly.

I'm sure the path to the physical font file is stored somewhere, so you
might be able to find it using some reflection on private fields in
sun.* classes, if you can depend on a particular JVM (I can't).

FYI, for parsing TTF/OTF font tables you should be able to find some
code in iText, Batik, and http://java.freehep.org/vectorgraphics/

On Fri, Jan 20, 2006 at 09:22:16AM -0800, Phil Race wrote:
> There is an RFE to address this.
> 4752644 : RFE: Getting a java.awt.Font's FilePath
>
> you can look it up on bugs.sun.com and read the state which can be
> summarised as TBD .. we do have some concerns about noting the
> embedding flags of a font.

Honestly I cannot see how giving the path to a non-embeddable font could
be an issue. Obviously it is up to the developer to obey the embeddable
flag, if one exists. If the issue is that it is not possible to
determine embeddability without parsing the font file, which might
inadvertently cause developers to embed restricted fonts, another method
like Font.isEmbeddingForbidden() could be added. In any case, very few
fonts in use today have the embedding flag set (many do not even have
the OTF table which contains the flag), so this issue seems like a red
herring.

Chris

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".