Class FontMetrics
- All Implemented Interfaces:
Proxy
PangoFontMetrics
structure holds the overall metric information
for a font.
The information in a PangoFontMetrics
structure may be restricted
to a script. The fields of this structure are private to implementations
of a font backend. See the documentation of the corresponding getters
for documentation of their meaning.
For an overview of the most important metrics, see:
<picture> <source srcset="fontmetrics-dark.png" media="(prefers-color-scheme: dark)"> <img alt="Font metrics" src="fontmetrics-light.png"> </picture>
-
Constructor Summary
ConstructorDescriptionAllocate a new FontMetrics.FontMetrics
(int refCount, int ascent, int descent, int height, int approximateCharWidth, int approximateDigitWidth, int underlinePosition, int underlineThickness, int strikethroughPosition, int strikethroughThickness) Allocate a new FontMetrics with the fields set to the provided values.FontMetrics
(int refCount, int ascent, int descent, int height, int approximateCharWidth, int approximateDigitWidth, int underlinePosition, int underlineThickness, int strikethroughPosition, int strikethroughThickness, Arena arena) Allocate a new FontMetrics with the fields set to the provided values.FontMetrics
(Arena arena) Allocate a new FontMetrics.FontMetrics
(MemorySegment address) Create a FontMetrics proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the approximate character width for a font metrics structure.int
Gets the approximate digit width for a font metrics structure.int
Gets the ascent from a font metrics structure.int
Gets the descent from a font metrics structure.int
Gets the line height from a font metrics structure.static MemoryLayout
The memory layout of the native struct.int
Gets the suggested position to draw the strikethrough.int
Gets the suggested thickness to draw for the strikethrough.static Type
getType()
Get the GType of the FontMetrics classint
Gets the suggested position to draw the underline.int
Gets the suggested thickness to draw for the underline.int
Read the value of the fieldapproximate_char_width
.int
Read the value of the fieldapproximate_digit_width
.int
Read the value of the fieldascent
.int
Read the value of the fielddescent
.int
Read the value of the fieldheight
.int
Read the value of the fieldref_count
.int
Read the value of the fieldstrikethrough_position
.int
Read the value of the fieldstrikethrough_thickness
.int
Read the value of the fieldunderline_position
.int
Read the value of the fieldunderline_thickness
.ref()
Increase the reference count of a font metrics structure by one.void
unref()
Decrease the reference count of a font metrics structure by one.void
writeApproximateCharWidth
(int approximateCharWidth) Write a value in the fieldapproximate_char_width
.void
writeApproximateDigitWidth
(int approximateDigitWidth) Write a value in the fieldapproximate_digit_width
.void
writeAscent
(int ascent) Write a value in the fieldascent
.void
writeDescent
(int descent) Write a value in the fielddescent
.void
writeHeight
(int height) Write a value in the fieldheight
.void
writeRefCount
(int refCount) Write a value in the fieldref_count
.void
writeStrikethroughPosition
(int strikethroughPosition) Write a value in the fieldstrikethrough_position
.void
writeStrikethroughThickness
(int strikethroughThickness) Write a value in the fieldstrikethrough_thickness
.void
writeUnderlinePosition
(int underlinePosition) Write a value in the fieldunderline_position
.void
writeUnderlineThickness
(int underlineThickness) Write a value in the fieldunderline_thickness
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
FontMetrics
Create a FontMetrics proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
FontMetrics
Allocate a new FontMetrics.- Parameters:
arena
- to control the memory allocation scope
-
FontMetrics
public FontMetrics()Allocate a new FontMetrics. The memory is allocated withArena.ofAuto()
. -
FontMetrics
public FontMetrics(int refCount, int ascent, int descent, int height, int approximateCharWidth, int approximateDigitWidth, int underlinePosition, int underlineThickness, int strikethroughPosition, int strikethroughThickness, Arena arena) Allocate a new FontMetrics with the fields set to the provided values.- Parameters:
refCount
- value for the fieldrefCount
ascent
- value for the fieldascent
descent
- value for the fielddescent
height
- value for the fieldheight
approximateCharWidth
- value for the fieldapproximateCharWidth
approximateDigitWidth
- value for the fieldapproximateDigitWidth
underlinePosition
- value for the fieldunderlinePosition
underlineThickness
- value for the fieldunderlineThickness
strikethroughPosition
- value for the fieldstrikethroughPosition
strikethroughThickness
- value for the fieldstrikethroughThickness
arena
- to control the memory allocation scope
-
FontMetrics
public FontMetrics(int refCount, int ascent, int descent, int height, int approximateCharWidth, int approximateDigitWidth, int underlinePosition, int underlineThickness, int strikethroughPosition, int strikethroughThickness) Allocate a new FontMetrics with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
refCount
- value for the fieldrefCount
ascent
- value for the fieldascent
descent
- value for the fielddescent
height
- value for the fieldheight
approximateCharWidth
- value for the fieldapproximateCharWidth
approximateDigitWidth
- value for the fieldapproximateDigitWidth
underlinePosition
- value for the fieldunderlinePosition
underlineThickness
- value for the fieldunderlineThickness
strikethroughPosition
- value for the fieldstrikethroughPosition
strikethroughThickness
- value for the fieldstrikethroughThickness
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readRefCount
public int readRefCount()Read the value of the fieldref_count
.- Returns:
- The value of the field
ref_count
-
writeRefCount
public void writeRefCount(int refCount) Write a value in the fieldref_count
.- Parameters:
refCount
- The new value for the fieldref_count
-
readAscent
public int readAscent()Read the value of the fieldascent
.- Returns:
- The value of the field
ascent
-
writeAscent
public void writeAscent(int ascent) Write a value in the fieldascent
.- Parameters:
ascent
- The new value for the fieldascent
-
readDescent
public int readDescent()Read the value of the fielddescent
.- Returns:
- The value of the field
descent
-
writeDescent
public void writeDescent(int descent) Write a value in the fielddescent
.- Parameters:
descent
- The new value for the fielddescent
-
readHeight
public int readHeight()Read the value of the fieldheight
.- Returns:
- The value of the field
height
-
writeHeight
public void writeHeight(int height) Write a value in the fieldheight
.- Parameters:
height
- The new value for the fieldheight
-
readApproximateCharWidth
public int readApproximateCharWidth()Read the value of the fieldapproximate_char_width
.- Returns:
- The value of the field
approximate_char_width
-
writeApproximateCharWidth
public void writeApproximateCharWidth(int approximateCharWidth) Write a value in the fieldapproximate_char_width
.- Parameters:
approximateCharWidth
- The new value for the fieldapproximate_char_width
-
readApproximateDigitWidth
public int readApproximateDigitWidth()Read the value of the fieldapproximate_digit_width
.- Returns:
- The value of the field
approximate_digit_width
-
writeApproximateDigitWidth
public void writeApproximateDigitWidth(int approximateDigitWidth) Write a value in the fieldapproximate_digit_width
.- Parameters:
approximateDigitWidth
- The new value for the fieldapproximate_digit_width
-
readUnderlinePosition
public int readUnderlinePosition()Read the value of the fieldunderline_position
.- Returns:
- The value of the field
underline_position
-
writeUnderlinePosition
public void writeUnderlinePosition(int underlinePosition) Write a value in the fieldunderline_position
.- Parameters:
underlinePosition
- The new value for the fieldunderline_position
-
readUnderlineThickness
public int readUnderlineThickness()Read the value of the fieldunderline_thickness
.- Returns:
- The value of the field
underline_thickness
-
writeUnderlineThickness
public void writeUnderlineThickness(int underlineThickness) Write a value in the fieldunderline_thickness
.- Parameters:
underlineThickness
- The new value for the fieldunderline_thickness
-
readStrikethroughPosition
public int readStrikethroughPosition()Read the value of the fieldstrikethrough_position
.- Returns:
- The value of the field
strikethrough_position
-
writeStrikethroughPosition
public void writeStrikethroughPosition(int strikethroughPosition) Write a value in the fieldstrikethrough_position
.- Parameters:
strikethroughPosition
- The new value for the fieldstrikethrough_position
-
readStrikethroughThickness
public int readStrikethroughThickness()Read the value of the fieldstrikethrough_thickness
.- Returns:
- The value of the field
strikethrough_thickness
-
writeStrikethroughThickness
public void writeStrikethroughThickness(int strikethroughThickness) Write a value in the fieldstrikethrough_thickness
.- Parameters:
strikethroughThickness
- The new value for the fieldstrikethrough_thickness
-
getApproximateCharWidth
public int getApproximateCharWidth()Gets the approximate character width for a font metrics structure.This is merely a representative value useful, for example, for determining the initial size for a window. Actual characters in text will be wider and narrower than this.
- Returns:
- the character width, in Pango units.
-
getApproximateDigitWidth
public int getApproximateDigitWidth()Gets the approximate digit width for a font metrics structure.This is merely a representative value useful, for example, for determining the initial size for a window. Actual digits in text can be wider or narrower than this, though this value is generally somewhat more accurate than the result of pango_font_metrics_get_approximate_char_width() for digits.
- Returns:
- the digit width, in Pango units.
-
getAscent
public int getAscent()Gets the ascent from a font metrics structure.The ascent is the distance from the baseline to the logical top of a line of text. (The logical top may be above or below the top of the actual drawn ink. It is necessary to lay out the text to figure where the ink will be.)
- Returns:
- the ascent, in Pango units.
-
getDescent
public int getDescent()Gets the descent from a font metrics structure.The descent is the distance from the baseline to the logical bottom of a line of text. (The logical bottom may be above or below the bottom of the actual drawn ink. It is necessary to lay out the text to figure where the ink will be.)
- Returns:
- the descent, in Pango units.
-
getHeight
public int getHeight()Gets the line height from a font metrics structure.The line height is the recommended distance between successive baselines in wrapped text using this font.
If the line height is not available, 0 is returned.
- Returns:
- the height, in Pango units
-
getStrikethroughPosition
public int getStrikethroughPosition()Gets the suggested position to draw the strikethrough.The value returned is the distance above the baseline of the top of the strikethrough.
- Returns:
- the suggested strikethrough position, in Pango units.
-
getStrikethroughThickness
public int getStrikethroughThickness()Gets the suggested thickness to draw for the strikethrough.- Returns:
- the suggested strikethrough thickness, in Pango units.
-
getUnderlinePosition
public int getUnderlinePosition()Gets the suggested position to draw the underline.The value returned is the distance above the baseline of the top of the underline. Since most fonts have underline positions beneath the baseline, this value is typically negative.
- Returns:
- the suggested underline position, in Pango units.
-
getUnderlineThickness
public int getUnderlineThickness()Gets the suggested thickness to draw for the underline.- Returns:
- the suggested underline thickness, in Pango units.
-
ref
Increase the reference count of a font metrics structure by one.- Returns:
- this FontMetrics
-
unref
public void unref()Decrease the reference count of a font metrics structure by one.If the result is zero, frees the structure and any associated memory.
-