juergen said:
I want to write an application displaying musical symbols. I am using a
ttf-Font: fughetta.ttf (
http://www.efn.org/~bch/fullpackage.html).
Fonts are an endless source of fun ...
Programming with C in linux works, using
gdk_font_load(-altsys-fughetta-medium-r-normal-*-*-320-*-*-p-*-*-symbol)
With Java, I put the ttf font in the jre/lib/fonts directory and edited
the font.dir file.
Not the fontconfig?
I used the Font.createFont() command.
But the symbols don't show. Neither are they displayed by other Java
programs (Opcion).
Ideas??
For reasons probably only the Sun programmers do understand, a JVM does
different things with different types of fonts.
If you use createFont() to access a physical font in a file, you better
have a TTF font which contains a Unicode cmap. A TTF file contains one
or more such cmaps, which are responsible for mapping an encoding (e.g.
Unicode) to the actual glyph data. I have never witnessed that
createFont() from a file deals with other cmap mappings than Unicode -
it could by e.g. mapping Unicode to another encoding, but I have not
seen it happen.
On the other hand, Sun JVMs contain a mechanism to map different font
encodings in physical font files to Unicode, when these physical files
are mapped to the standard logical fonts. There the VM is able to map
all kinds of font encodings to Unicode to assemble a logical font.
That mapping is done in the fontconfig properties files. There the
encodings are called character subsets (an encoding in this file is
something else).
The first thing I would try is to obtain some decent font tool and to
inspect the font file to figure out which cmaps it contains, and where
(under which code points in which encoding) it has placed the desired
characters. Then
(a) If it contains a Unicode cmap, use createFont() with the file as
argument and try to get the glyphs
(b) If there is no Unicode cmap in the file, try to map the font to a
logical font in the fontconfig, and then access the logical font.
I have the suspicion that your file doesn't provide a Unicode cmap, and
that it probably provides a "cowboy" mapping, where some encoding which
in fact isn't supposed to contain music symbols is abused to squeeze
them into the file.
BTW, to check what Java can display, you can use demo/jfc/Font2DTest,
which comes with the JDK.
/Thomas