Swing JLabel Schriftzeichen Abstand Leerzeichen

phouli89

Mitglied
Ich habe folgendes Problem bei JLabels, ich habe einen Grafischen Editor Programmiert (Template Editor), alles was wichtig ist, ist die Tatsache das die Schriftarten nachher über PHP ausgegeben werden.
Das Problem besteht darin, dass die Schriftzeichen unterschiedliche Abstände haben, genauer gesagt konnte ich gerade feststellen, das ein leerzeichen in PHP kleiner ist, als ein Leerzeichen in Java.
(4 Pixel bei Schriftgröße 48 px oder 36 pt)
Die Schriftgröße in Jave ist ein Pixel angegeben, auf dem Webserver wird die Schriftgröße in Point dargestellt, liegt es vieleicht daran? Hat jemand eine Lösung, kann man die Fonts in Java auch auf Point umstellen.

Momentan:
Schriftgröße 48px = 36 / 0,75
Schriftgröße 36pt = 48 * 0,75

Vielen Dank
 
Hi,

Kann es sein, dass Java sich nach dem aktuellen Layout des Betriebssystems richtet ?

Rendert PHP denn Zeichen so wie Java Runtime ?

Ansonsten Class Font

Font
public Font(String name,
int style,
int size)
Creates a new Font from the specified name, style and point size.

The font name can be a font face name or a font family name. It is used together with the style
to find an appropriate font face. When a font family name is specified, the style argument is
used to select the most appropriate face from the family. When a font face name is specified,
the face's style and the style argument are merged to locate the best matching font from the
same family. For example if face name "Arial Bold" is specified with style Font.ITALIC, the
font system looks for a face in the "Arial" family that is bold and italic, and may associate
the font instance with the physical font face "Arial Bold Italic". The style argument is merged
with the specified face's style, not added or subtracted. This means, specifying a bold face and
a bold style does not double-embolden the font, and specifying a bold face and a plain style does
not lighten the font.

If no face for the requested style can be found, the font system may apply algorithmic styling to
achieve the desired style. For example, if ITALIC is requested, but no italic face is available,
glyphs from the plain face may be algorithmically obliqued (slanted).

Font name lookup is case insensitive, using the case folding rules of the US locale.

If the name parameter represents something other than a logical font, i.e. is interpreted as a
physical font face or family, and this cannot be mapped by the implementation to a physical
font or a compatible alternative, then the font system will map the Font instance to "Dialog",
such that for example, the family as reported by getFamily will be "Dialog".


Parameters:

name - the font name. This can be a font face name or a font family name, and may represent
either a logical font or a physical font found in this GraphicsEnvironment.
The family names for logical fonts are: Dialog, DialogInput, Monospaced, Serif, or
SansSerif. Pre-defined String constants exist for all of these names, eg @see #DIALOG.
If name is null, the logical font name of the new Font as returned by getName()is set
to the name "Default".

style - the style constant for the Font The style argument is an integer bitmask that may be PLAIN,
or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC).
If the style argument does not conform to one of the expected integer bitmasks then the
style is set to PLAIN.

size - the point size of the Font

Since:
JDK1.0

See Also:
GraphicsEnvironment.getAllFonts(), GraphicsEnvironment.getAvailableFontFamilyNames()
 
Also an den Fonts direkt kann/darf ich nichts ändern, ich werde jetzt mal das Look & Feel setzen (im moment auf standard) und dann vergleiche ich mal Linux und Windoof, vieleicht klappts ja schon mit dem Look & Fell, sonst werde ich deinen rat mit dem überschreiben der Fontklasse probieren. Vielen Dank
 
Also das Rendern unter Java ist Abhängig vom Look&Feel oder ggf. vom Betriebssystem, unter Linux siehts schon iwwder anders aus, ich muss einen Weg finden die Fontclasse so zu überschreiben dass sie es gleich wie in PHP rendert. Mich wundert nur dass es da zu solchen Problemem kommt da in Java sowie auf dem Webserver direkt die TTF dateien verwendet werden.
 

Neue Themen


Zurück
Oben