java.awt.font

Class FontRenderContext


  • public class FontRenderContext
    extends Object
    The FontRenderContext class is a container for the information needed to correctly measure text. The measurement of text can vary because of rules that map outlines to pixels, and rendering hints provided by an application.

    One such piece of information is a transform that scales typographical points to pixels. (A point is defined to be exactly 1/72 of an inch, which is slightly different than the traditional mechanical measurement of a point.) A character that is rendered at 12pt on a 600dpi device might have a different size than the same character rendered at 12pt on a 72dpi device because of such factors as rounding to pixel boundaries and hints that the font designer may have specified.

    Anti-aliasing and Fractional-metrics specified by an application can also affect the size of a character because of rounding to pixel boundaries.

    Typically, instances of FontRenderContext are obtained from a Graphics2D object. A FontRenderContext which is directly constructed will most likely not represent any actual graphics device, and may lead to unexpected or incorrect results.

    See Also:
    RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.KEY_FRACTIONALMETRICS, Graphics2D.getFontRenderContext(), LineMetrics
    • Constructor Detail

      • FontRenderContext

        protected FontRenderContext()
        Constructs a new FontRenderContext object.
      • FontRenderContext

        public FontRenderContext(AffineTransform tx,
                         boolean isAntiAliased,
                         boolean usesFractionalMetrics)
        Constructs a FontRenderContext object from an optional AffineTransform and two boolean values that determine if the newly constructed object has anti-aliasing or fractional metrics. In each case the boolean values true and false correspond to the rendering hint values ON and OFF respectively.

        To specify other hint values, use the constructor which specifies the rendering hint values as parameters : FontRenderContext(AffineTransform, Object, Object).

        Parameters:
        tx - the transform which is used to scale typographical points to pixels in this FontRenderContext. If null, an identity transform is used.
        isAntiAliased - determines if the newly constructed object has anti-aliasing.
        usesFractionalMetrics - determines if the newly constructed object has fractional metrics.
      • FontRenderContext

        public FontRenderContext(AffineTransform tx,
                         Object aaHint,
                         Object fmHint)
        Constructs a FontRenderContext object from an optional AffineTransform and two Object values that determine if the newly constructed object has anti-aliasing or fractional metrics.
        Parameters:
        tx - the transform which is used to scale typographical points to pixels in this FontRenderContext. If null, an identity tranform is used.
        aaHint - - one of the text antialiasing rendering hint values defined in java.awt.RenderingHints. Any other value will throw IllegalArgumentException. VALUE_TEXT_ANTIALIAS_DEFAULT may be specified, in which case the mode used is implementation dependent.
        fmHint - - one of the text fractional rendering hint values defined in java.awt.RenderingHints. VALUE_FRACTIONALMETRICS_DEFAULT may be specified, in which case the mode used is implementation dependent. Any other value will throw IllegalArgumentException
        Throws:
        IllegalArgumentException - if the hints are not one of the legal values.
        Since:
        1.6
    • Method Detail

      • isTransformed

        public boolean isTransformed()
        Indicates whether or not this FontRenderContext object measures text in a transformed render context.
        Returns:
        true if this FontRenderContext object has a non-identity AffineTransform attribute. false otherwise.
        Since:
        1.6
        See Also:
        getTransform()
      • getTransformType

        public int getTransformType()
        Returns the integer type of the affine transform for this FontRenderContext as specified by AffineTransform.getType()
        Returns:
        the type of the transform.
        Since:
        1.6
        See Also:
        AffineTransform
      • getTransform

        public AffineTransform getTransform()
        Gets the transform that is used to scale typographical points to pixels in this FontRenderContext.
        Returns:
        the AffineTransform of this FontRenderContext.
        See Also:
        AffineTransform
      • getAntiAliasingHint

        public Object getAntiAliasingHint()
        Return the text anti-aliasing rendering mode hint used in this FontRenderContext. This will be one of the text antialiasing rendering hint values defined in java.awt.RenderingHints.
        Returns:
        text anti-aliasing rendering mode hint used in this FontRenderContext.
        Since:
        1.6
      • getFractionalMetricsHint

        public Object getFractionalMetricsHint()
        Return the text fractional metrics rendering mode hint used in this FontRenderContext. This will be one of the text fractional metrics rendering hint values defined in java.awt.RenderingHints.
        Returns:
        the text fractional metrics rendering mode hint used in this FontRenderContext.
        Since:
        1.6
      • equals

        public boolean equals(Object obj)
        Return true if obj is an instance of FontRenderContext and has the same transform, antialiasing, and fractional metrics values as this.
        Overrides:
        equals in class Object
        Parameters:
        obj - the object to test for equality
        Returns:
        true if the specified object is equal to this FontRenderContext; false otherwise.
        See Also:
        Object.hashCode(), HashMap
      • equals

        public boolean equals(FontRenderContext rhs)
        Return true if rhs has the same transform, antialiasing, and fractional metrics values as this.
        Parameters:
        rhs - the FontRenderContext to test for equality
        Returns:
        true if rhs is equal to this FontRenderContext; false otherwise.
        Since:
        1.4

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/awt/font/fontrendercontext.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut