How to display symbolic fonts

J

juergen

Hi,
I want to write an application displaying musical symbols. I am using a
ttf-Font: fughetta.ttf (http://www.efn.org/~bch/fullpackage.html).
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.
I used the Font.createFont() command.
But the symbols don't show. Neither are they displayed by other Java
programs (Opcion).
Ideas??
Thanks a lot, Juergen
 
O

Oliver Wong

juergen said:
Hi,
I want to write an application displaying musical symbols. I am using a
ttf-Font: fughetta.ttf (http://www.efn.org/~bch/fullpackage.html).
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.
I used the Font.createFont() command.
But the symbols don't show. Neither are they displayed by other Java
programs (Opcion).
Ideas??
Thanks a lot, Juergen

Rather than expect the end user to always copy the font to the
appropriate directory and editing their font.dir file, consider using the
createFont() method to dynamically load a font at runtime:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Font.html#createFont(int,
java.io.File)

Additionally, rather than using a special font that maps musical symbols
to other characters, consider using the Unicode characters specifically
designed for this purpose:

Western Musical Symbols: http://www.unicode.org/charts/PDF/U1D100.pdf
Byzantine Musical Symbols: http://www.unicode.org/charts/PDF/U1D000.pdf
Ancient Greek Musical Symbols: http://www.unicode.org/charts/PDF/U1D200.pdf

- Oliver
 
K

Knute Johnson

Oliver said:
Rather than expect the end user to always copy the font to the
appropriate directory and editing their font.dir file, consider using
the createFont() method to dynamically load a font at runtime:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Font.html#createFont(int,
java.io.File)

Additionally, rather than using a special font that maps musical
symbols to other characters, consider using the Unicode characters
specifically designed for this purpose:

Western Musical Symbols: http://www.unicode.org/charts/PDF/U1D100.pdf
Byzantine Musical Symbols: http://www.unicode.org/charts/PDF/U1D000.pdf
Ancient Greek Musical Symbols: http://www.unicode.org/charts/PDF/U1D200.pdf

- Oliver

Oliver:

How do you represent a unicode value greater than 16 bits in a string?

"\u1D100" doesn't work.

Thanks,
 
T

Thomas Fritsch

Knute Johnson said:
Oliver Wong wrote: [...]
Additionally, rather than using a special font that maps musical
symbols to other characters, consider using the Unicode characters
specifically designed for this purpose:

Western Musical Symbols: http://www.unicode.org/charts/PDF/U1D100.pdf
Byzantine Musical Symbols: http://www.unicode.org/charts/PDF/U1D000.pdf
Ancient Greek Musical Symbols:
http://www.unicode.org/charts/PDF/U1D200.pdf

Oliver:

How do you represent a unicode value greater than 16 bits in a string?

"\u1D100" doesn't work.

new String(new int[] { 0x1D100 }, 0, 1)

Since Java 1.5 the String and Character class have some methods for dealing
with int-codepoints instead of just chars.
See also the API doc of String and Character (especially the methods with
"codePoint" in their name).
 
K

Knute Johnson

Thomas said:
Knute Johnson said:
Oliver Wong wrote: [...]
Additionally, rather than using a special font that maps musical
symbols to other characters, consider using the Unicode characters
specifically designed for this purpose:

Western Musical Symbols: http://www.unicode.org/charts/PDF/U1D100.pdf
Byzantine Musical Symbols: http://www.unicode.org/charts/PDF/U1D000.pdf
Ancient Greek Musical Symbols:
http://www.unicode.org/charts/PDF/U1D200.pdf
Oliver:

How do you represent a unicode value greater than 16 bits in a string?

"\u1D100" doesn't work.

new String(new int[] { 0x1D100 }, 0, 1)

Since Java 1.5 the String and Character class have some methods for dealing
with int-codepoints instead of just chars.
See also the API doc of String and Character (especially the methods with
"codePoint" in their name).

Thomas and John:

Thanks for the pointers. I've tried making Strings or char[] but still
cannot get them to display the supplemental characters. Is there an
issue with the font that I choose? Can you give me another hint?

Thanks,
 
J

juergen

Oliver:
Thank your for your two ideas, but I need further help.
Rather than expect the end user to always copy the font to the
appropriate directory and editing their font.dir file, consider using the
createFont() method to dynamically load a font at runtime:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Font.html#createFont(int,
java.io.File)

I am using the createFont method, but the Symbols are displayed as
little
boxes.
Additionally, rather than using a special font that maps musical symbols
to other characters, consider using the Unicode characters specifically
designed for this purpose:

Western Musical Symbols: http://www.unicode.org/charts/PDF/U1D100.pdf
Byzantine Musical Symbols: http://www.unicode.org/charts/PDF/U1D000.pdf
Ancient Greek Musical Symbols: http://www.unicode.org/charts/PDF/U1D200.pdf

Thank you, this seems to be a very valuable approach.
I looked for a font that would support those characters.
When looking at this website:
http://www.alanwood.net/unicode/fontsbyrange.html#u1d100

Byzantine Musical Symbols U+1D000 - U+1D0FF (118784-119039)

Windows: Code2001
Musical Symbols U+1D100 - U+1D1FF (119040-119295)

Windows: Code2001
Ancient Greek Musical Notation U+1D200 - U+1D24F
(119296-119375)

Windows: ALPHABETUM Unicode, Cardo, New Athena Unicode

There is none font listed for linux.
What can I do?
Thank you, Juergen
 
O

Oliver Wong

juergen said:
Oliver:
Thank your for your two ideas, but I need further help.


I am using the createFont method, but the Symbols are displayed as
little
boxes.

This is an indication, I think, that the font you're using doesn't have
the visual glyphs to represent the characters you're trying to display.
Thank you, this seems to be a very valuable approach.
I looked for a font that would support those characters.
When looking at this website:
http://www.alanwood.net/unicode/fontsbyrange.html#u1d100

Byzantine Musical Symbols U+1D000 - U+1D0FF (118784-119039)

Windows: Code2001
Musical Symbols U+1D100 - U+1D1FF (119040-119295)

Windows: Code2001
Ancient Greek Musical Notation U+1D200 - U+1D24F
(119296-119375)

Windows: ALPHABETUM Unicode, Cardo, New Athena Unicode

There is none font listed for linux.
What can I do?

I didn't know there was an issue between Windows fonts vs Linux fonts.
AFAIK, as long as it's in the TTF format, Java can read it.

- Oliver
 
O

Oliver Wong

Knute Johnson said:
Thomas said:
Knute Johnson said:
Oliver Wong wrote: [...]
Additionally, rather than using a special font that maps musical
symbols to other characters, consider using the Unicode characters
specifically designed for this purpose:

Western Musical Symbols: http://www.unicode.org/charts/PDF/U1D100.pdf
Byzantine Musical Symbols: http://www.unicode.org/charts/PDF/U1D000.pdf
Ancient Greek Musical Symbols:
http://www.unicode.org/charts/PDF/U1D200.pdf
Oliver:

How do you represent a unicode value greater than 16 bits in a string?

"\u1D100" doesn't work.

new String(new int[] { 0x1D100 }, 0, 1)

Since Java 1.5 the String and Character class have some methods for
dealing with int-codepoints instead of just chars.
See also the API doc of String and Character (especially the methods with
"codePoint" in their name).

Thomas and John:

Thanks for the pointers. I've tried making Strings or char[] but still
cannot get them to display the supplemental characters. Is there an issue
with the font that I choose? Can you give me another hint?

Font files are basically a collection of glyphs (drawings, if you
prefer) that the OS can use to paint on screen or on a printer to visually
represent the String data that you wish to display. The vast majority of
fonts I've seen do NOT have glyphs for every possible Unicode character.

http://www.alanwood.net/unicode/fonts.html is a handy reference to find
out which fonts have glyphs for what characters, and also allows you to test
your system to see if it can display certain characters.

- Oliver
 
T

Thomas Weidenfeller

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
 
K

Knute Johnson

Oliver said:
Knute Johnson said:
Thomas said:
Oliver Wong wrote:
[...]
Additionally, rather than using a special font that maps musical
symbols to other characters, consider using the Unicode characters
specifically designed for this purpose:

Western Musical Symbols: http://www.unicode.org/charts/PDF/U1D100.pdf
Byzantine Musical Symbols:
http://www.unicode.org/charts/PDF/U1D000.pdf
Ancient Greek Musical Symbols:
http://www.unicode.org/charts/PDF/U1D200.pdf
Oliver:

How do you represent a unicode value greater than 16 bits in a string?

"\u1D100" doesn't work.

new String(new int[] { 0x1D100 }, 0, 1)

Since Java 1.5 the String and Character class have some methods for
dealing with int-codepoints instead of just chars.
See also the API doc of String and Character (especially the methods
with "codePoint" in their name).

Thomas and John:

Thanks for the pointers. I've tried making Strings or char[] but
still cannot get them to display the supplemental characters. Is
there an issue with the font that I choose? Can you give me another
hint?

Font files are basically a collection of glyphs (drawings, if you
prefer) that the OS can use to paint on screen or on a printer to
visually represent the String data that you wish to display. The vast
majority of fonts I've seen do NOT have glyphs for every possible
Unicode character.

http://www.alanwood.net/unicode/fonts.html is a handy reference to
find out which fonts have glyphs for what characters, and also allows
you to test your system to see if it can display certain characters.

- Oliver

Oliver:

Thanks very much for the Alan Wood web site. There is a lot of
interesting info there. I used the CODE2001 font to display the musical
note characters and it works fine.
 
J

juergen

Thomas:
Thank you for your valuable explanation.
I found a tool that could display my font PROPERLY.

http://www.brawer.ch/software/fonts/
fonts-July29.tar.gz
fonttest.jar
java -jar /var/java/fonttest.jar fughetta.ttf

There is a menu option called View -> Show Glyph.
So, in a table all glyphs are shown.
The symbols still have names like "ampersand", "percent", ...
I was investigating the soure file of this tool which took me several
hours and was trying to code like this (instead of drawString())

String str="&&";
glyphVec= font.createGlyphVector(frc,str);
path=new GeneralPath(glyphVec.getOutline());
g2.translate(x, y);
g2.setColor(Color.BLACK);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.fill(path);
g2.translate(-x, -y);

Still without success.
Certainly the problems is in the font.createGlyphVector() - call.

Juergen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top