API java : GlyphMetrics


java.awt.font
Class GlyphMetrics

java.lang.Object
  extended by java.awt.font.GlyphMetrics

public final class GlyphMetrics
extends Object

The GlyphMetrics class represents infomation for a single glyph. A glyph is the visual representation of one or more characters. Many different glyphs can be used to represent a single character or combination of characters. GlyphMetrics instances are produced by Font and are applicable to a specific glyph in a particular Font.

Glyphs are either STANDARD, LIGATURE, COMBINING, or COMPONENT.

  • STANDARD glyphs are commonly used to represent single characters.
  • LIGATURE glyphs are used to represent sequences of characters.
  • COMPONENT glyphs in a GlyphVector do not correspond to a particular character in a text model. Instead, COMPONENT glyphs are added for typographical reasons, such as Arabic justification.
  • COMBINING glyphs embellish STANDARD or LIGATURE glyphs, such as accent marks. Carets do not appear before COMBINING glyphs.

Other metrics available through GlyphMetrics are the components of the advance, the visual bounds, and the left and right side bearings.

Glyphs for a rotated font, or obtained from a GlyphVector which has applied a rotation to the glyph, can have advances that contain both X and Y components. Usually the advance only has one component.

The advance of a glyph is the distance from the glyph's origin to the origin of the next glyph along the baseline, which is either vertical or horizontal. Note that, in a GlyphVector, the distance from a glyph to its following glyph might not be the glyph's advance, because of kerning or other positioning adjustments.

The bounds is the smallest rectangle that completely contains the outline of the glyph. The bounds rectangle is relative to the glyph's origin. The left-side bearing is the distance from the glyph origin to the left of its bounds rectangle. If the left-side bearing is negative, part of the glyph is drawn to the left of its origin. The right-side bearing is the distance from the right side of the bounds rectangle to the next glyph origin (the origin plus the advance). If negative, part of the glyph is drawn to the right of the next glyph's origin. Note that the bounds does not necessarily enclose all the pixels affected when rendering the glyph, because of rasterization and pixel adjustment effects.

Although instances of GlyphMetrics can be directly constructed, they are almost always obtained from a GlyphVector. Once constructed, GlyphMetrics objects are immutable.

Example:

Querying a Font for glyph information

  1. Font font = ...;
  2. int glyphIndex = ...;
  3. GlyphMetrics metrics = GlyphVector.getGlyphMetrics(glyphIndex);
  4. int isStandard = metrics.isStandard();
  5. float glyphAdvance = metrics.getAdvance();

See Also:
Font, GlyphVector

Field Summary
static byte COMBINING
          Indicates a glyph that represents a combining character, such as an umlaut.
static byte COMPONENT
          Indicates a glyph with no corresponding character in the backing store.
static byte LIGATURE
          Indicates a glyph that represents multiple characters as a ligature, for example 'fi' or 'ffi'.
static byte STANDARD
          Indicates a glyph that represents a single standard character.
static byte WHITESPACE
          Indicates a glyph with no visual representation.
 
Constructor Summary
GlyphMetrics(boolean horizontal, float advanceX, float advanceY, Rectangle2D bounds, byte glyphType)
          Constructs a GlyphMetrics object.
GlyphMetrics(float advance, Rectangle2D bounds, byte glyphType)
          Constructs a GlyphMetrics object.
 
Method Summary
 float getAdvance()
          Returns the advance of the glyph along the baseline (either horizontal or vertical).
 float getAdvanceX()
          Returns the x-component of the advance of the glyph.
 float getAdvanceY()
          Returns the y-component of the advance of the glyph.
 Rectangle2D getBounds2D()
          Returns the bounds of the glyph.
 float getLSB()
          Returns the left (top) side bearing of the glyph.
 float getRSB()
          Returns the right (bottom) side bearing of the glyph.
 int getType()
          Returns the raw glyph type code.
 boolean isCombining()
          Returns true if this is a combining glyph.
 boolean isComponent()
          Returns true if this is a component glyph.
 boolean isLigature()
          Returns true if this is a ligature glyph.
 boolean isStandard()
          Returns true if this is a standard glyph.
 boolean isWhitespace()
          Returns true if this is a whitespace glyph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD

public static final byte STANDARD
Indicates a glyph that represents a single standard character.

See Also:
Constant Field Values

LIGATURE

public static final byte LIGATURE
Indicates a glyph that represents multiple characters as a ligature, for example 'fi' or 'ffi'. It is followed by filler glyphs for the remaining characters. Filler and combining glyphs can be intermixed to control positioning of accent marks on the logically preceeding ligature.

See Also:
Constant Field Values

COMBINING

public static final byte COMBINING
Indicates a glyph that represents a combining character, such as an umlaut. There is no caret position between this glyph and the preceeding glyph.

See Also:
Constant Field Values

COMPONENT

public static final byte COMPONENT
Indicates a glyph with no corresponding character in the backing store. The glyph is associated with the character represented by the logicaly preceeding non-component glyph. This is used for kashida justification or other visual modifications to existing glyphs. There is no caret position between this glyph and the preceeding glyph.

See Also:
Constant Field Values

WHITESPACE

public static final byte WHITESPACE
Indicates a glyph with no visual representation. It can be added to the other code values to indicate an invisible glyph.

See Also:
Constant Field Values
Constructor Detail

GlyphMetrics

public GlyphMetrics(float advance,
                    Rectangle2D bounds,
                    byte glyphType)
Constructs a GlyphMetrics object.

Parameters:
advance - the advance width of the glyph
bounds - the black box bounds of the glyph
glyphType - the type of the glyph

GlyphMetrics

public GlyphMetrics(boolean horizontal,
                    float advanceX,
                    float advanceY,
                    Rectangle2D bounds,
                    byte glyphType)
Constructs a GlyphMetrics object.

Parameters:
horizontal - if true, metrics are for a horizontal baseline, otherwise they are for a vertical baseline
advanceX - the X-component of the glyph's advance
advanceY - the Y-component of the glyph's advance
bounds - the visual bounds of the glyph
glyphType - the type of the glyph
Method Detail

getAdvance

public float getAdvance()
Returns the advance of the glyph along the baseline (either horizontal or vertical).

Returns:
the advance of the glyph

getAdvanceX

public float getAdvanceX()
Returns the x-component of the advance of the glyph.

Returns:
the x-component of the advance of the glyph

getAdvanceY

public float getAdvanceY()
Returns the y-component of the advance of the glyph.

Returns:
the y-component of the advance of the glyph

getBounds2D

public Rectangle2D getBounds2D()
Returns the bounds of the glyph. This is the bounding box of the glyph outline. Because of rasterization and pixel alignment effects, it does not necessarily enclose the pixels that are affected when rendering the glyph.

Returns:
a Rectangle2D that is the bounds of the glyph.

getLSB

public float getLSB()
Returns the left (top) side bearing of the glyph.

This is the distance from 0, 0 to the left (top) of the glyph bounds. If the bounds of the glyph is to the left of (above) the origin, the LSB is negative.

Returns:
the left side bearing of the glyph.

getRSB

public float getRSB()
Returns the right (bottom) side bearing of the glyph.

This is the distance from the right (bottom) of the glyph bounds to the advance. If the bounds of the glyph is to the right of (below) the advance, the RSB is negative.

Returns:
the right side bearing of the glyph.

getType

public int getType()
Returns the raw glyph type code.

Returns:
the raw glyph type code.

isStandard

public boolean isStandard()
Returns true if this is a standard glyph.

Returns:
true if this is a standard glyph; false otherwise.

isLigature

public boolean isLigature()
Returns true if this is a ligature glyph.

Returns:
true if this is a ligature glyph; false otherwise.

isCombining

public boolean isCombining()
Returns true if this is a combining glyph.

Returns:
true if this is a combining glyph; false otherwise.

isComponent

public boolean isComponent()
Returns true if this is a component glyph.

Returns:
true if this is a component glyph; false otherwise.

isWhitespace

public boolean isWhitespace()
Returns true if this is a whitespace glyph.

Returns:
true if this is a whitespace glyph; false otherwise.

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

8 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-681
Document créé le 20/07/06 23:00, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/awt/font/GlyphMetrics.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,71 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Le rire, comme les essuie-glaces, permet d'avancer même s'il n'arrête pas la pluie.

Gérard Jugnot
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 14:44, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)