Package ch.bailu.gtk.pango
Class Pango
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Package
ch.bailu.gtk.pango.Pango
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Attribute
attrAllowBreaksNew
(boolean allow_breaks) Create a new allow-breaks attribute.static Attribute
attrBackgroundAlphaNew
(int alpha) Create a new background alpha attribute.static Attribute
attrBackgroundNew
(int red, int green, int blue) Create a new background color attribute.static Attribute
attrBaselineShiftNew
(int shift) Create a new baseline displacement attribute.static Attribute
attrFallbackNew
(boolean enable_fallback) Create a new font fallback attribute.static Attribute
attrFamilyNew
(Str family) Create a new font family attribute.static Attribute
Create a new font description attribute.static Attribute
attrFontFeaturesNew
(Str features) Create a new font features tag attribute.static Attribute
attrFontScaleNew
(int scale) Create a new font scale attribute.static Attribute
attrForegroundAlphaNew
(int alpha) Create a new foreground alpha attribute.static Attribute
attrForegroundNew
(int red, int green, int blue) Create a new foreground color attribute.static Attribute
attrGravityHintNew
(int hint) Create a new gravity hint attribute.static Attribute
attrGravityNew
(int gravity) Create a new gravity attribute.static Attribute
attrInsertHyphensNew
(boolean insert_hyphens) Create a new insert-hyphens attribute.static Attribute
attrLanguageNew
(Language language) Create a new language tag attribute.static Attribute
attrLetterSpacingNew
(int letter_spacing) Create a new letter-spacing attribute.static Attribute
attrLineHeightNew
(double factor) Modify the height of logical line extents by a factor.static Attribute
attrLineHeightNewAbsolute
(int height) Override the height of logical line extents to be @height.static AttrList
attrListFromString
(Str text) Deserializes a `PangoAttrList` from a string.static Attribute
attrOverlineColorNew
(int red, int green, int blue) Create a new overline color attribute.static Attribute
attrOverlineNew
(int overline) Create a new overline-style attribute.static Attribute
attrRiseNew
(int rise) Create a new baseline displacement attribute.static Attribute
attrScaleNew
(double scale_factor) Create a new font size scale attribute.static Attribute
Marks the range of the attribute as a single sentence.static Attribute
attrShapeNew
(Rectangle ink_rect, Rectangle logical_rect) Create a new shape attribute.static Attribute
attrShapeNewWithData
(Rectangle ink_rect, Rectangle logical_rect, Pointer data, Pango.OnAttrDataCopyFunc copy_func, Pango.OnDestroyNotify destroy_func) Creates a new shape attribute.static Attribute
attrShowNew
(int flags) Create a new attribute that influences how invisible
characters are rendered.static Attribute
attrSizeNew
(int size) Create a new font-size attribute in fractional points.static Attribute
attrSizeNewAbsolute
(int size) Create a new font-size attribute in device units.static Attribute
attrStretchNew
(int stretch) Create a new font stretch attribute.static Attribute
attrStrikethroughColorNew
(int red, int green, int blue) Create a new strikethrough color attribute.static Attribute
attrStrikethroughNew
(boolean strikethrough) Create a new strike-through attribute.static Attribute
attrStyleNew
(int style) Create a new font slant style attribute.static Attribute
attrTextTransformNew
(int transform) Create a new attribute that influences how characters
are transformed during shaping.static Str
attrTypeGetName
(int type) Fetches the attribute type name.static int
attrTypeRegister
(Str name) Allocate a new attribute type ID.static Attribute
attrUnderlineColorNew
(int red, int green, int blue) Create a new underline color attribute.static Attribute
attrUnderlineNew
(int underline) Create a new underline-style attribute.static Attribute
attrVariantNew
(int variant) Create a new font variant attribute (normal or small caps).static Attribute
attrWeightNew
(int weight) Create a new font weight attribute.static Attribute
Marks the range of the attribute as a single word.static int
bidiTypeForUnichar
(byte ch) Determines the bidirectional type of a character.static void
defaultBreak
(Str text, int length, Analysis analysis, LogAttr attrs, int attrs_len) This is the default break algorithm.static void
extentsToPixels
(Rectangle inclusive, Rectangle nearest) Converts extents from Pango units to device units.static int
findBaseDir
(Str text, int length) Searches a string the first character that has a strong
direction, according to the Unicode bidirectional algorithm.static void
findParagraphBoundary
(Str text, int length, Int paragraph_delimiter_index, Int next_paragraph_start) Locates a paragraph boundary in @text.static FontDescription
Creates a new font description from a string representation.static ClassHandler
static int
gravityGetForMatrix
(Matrix matrix) Finds the gravity that best matches the rotation component
in a `PangoMatrix`.static int
gravityGetForScript
(int script, int base_gravity, int hint) Returns the gravity to use in laying out a `PangoItem`.static int
gravityGetForScriptAndWidth
(int script, boolean wide, int base_gravity, int hint) Returns the gravity to use in laying out a single character
or `PangoItem`.static double
gravityToRotation
(int gravity) Converts a `PangoGravity` value to its natural rotation in radians.static boolean
isZeroWidth
(byte ch) Checks if a character that should not be normally rendered.static List
itemize
(Context context, Str text, int start_index, int length, AttrList attrs, AttrIterator cached_iter) Breaks a piece of text into segments with consistent directional
level and font.static List
itemizeWithBaseDir
(Context context, int base_dir, Str text, int start_index, int length, AttrList attrs, AttrIterator cached_iter) Like `pango_itemize()`, but with an explicitly specified base direction.static Language
languageFromString
(Str language) Convert a language tag to a `PangoLanguage`.static Language
Returns the `PangoLanguage` for the current locale of the process.static int
static MarkupParseContext
markupParserNew
(byte accel_marker) Incrementally parses marked-up text to create a plain-text string
and an attribute list.static boolean
parseStretch
(Str str, Int stretch, boolean warn) Parses a font stretch.static boolean
parseStyle
(Str str, Int style, boolean warn) Parses a font style.static boolean
parseVariant
(Str str, Int variant, boolean warn) Parses a font variant.static boolean
parseWeight
(Str str, Int weight, boolean warn) Parses a font weight.static void
quantizeLineGeometry
(Int thickness, Int position) Quantizes the thickness and position of a line to whole device pixels.static List
reorderItems
(List items) Reorder items from logical order to visual order.static Language
scriptGetSampleLanguage
(int script) Finds a language tag that is reasonably representative of @script.static void
shape
(Str text, int length, Analysis analysis, GlyphString glyphs) Convert the characters in @text into glyphs.static void
shapeFull
(Str item_text, int item_length, Str paragraph_text, int paragraph_length, Analysis analysis, GlyphString glyphs) Convert the characters in @text into glyphs.static void
shapeItem
(Item item, Str paragraph_text, int paragraph_length, LogAttr log_attrs, GlyphString glyphs, int flags) Convert the characters in @item into glyphs.static void
shapeWithFlags
(Str item_text, int item_length, Str paragraph_text, int paragraph_length, Analysis analysis, GlyphString glyphs, int flags) Convert the characters in @text into glyphs.static TabArray
tabArrayFromString
(Str text) Deserializes a `PangoTabArray` from a string.static int
unicharDirection
(byte ch) Determines the inherent direction of a character.static int
unitsFromDouble
(double d) Converts a floating-point number to Pango units.static double
unitsToDouble
(int i) Converts a number in Pango units to floating-point.static int
version()
Returns the encoded version of Pango available at run-time.static Str
versionCheck
(int required_major, int required_minor, int required_micro) Checks that the Pango library in use is compatible with the
given version.static Str
Returns the version of Pango available at run-time.Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
-
Constructor Details
-
Pango
public Pango()
-
-
Method Details
-
getClassHandler
-
attrAllowBreaksNew
Create a new allow-breaks attribute.
If breaks are disabled, the range will be kept in a
single run, as far as possible.- Parameters:
allow_breaks
- %TRUE if we line breaks are allowed- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrBackgroundAlphaNew
Create a new background alpha attribute.- Parameters:
alpha
- the alpha value, between 1 and 65536- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrBackgroundNew
Create a new background color attribute.- Parameters:
red
- the red value (ranging from 0 to 65535)green
- the green valueblue
- the blue value- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrBaselineShiftNew
Create a new baseline displacement attribute.
The effect of this attribute is to shift the baseline of a run,
relative to the run of preceding run.
<picture>
<source srcset="baseline-shift-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Baseline Shift" src="baseline-shift-light.png">
</picture>- Parameters:
shift
- either a `PangoBaselineShift` enumeration value or an absolute value (> 1024) in Pango units, relative to the baseline of the previous run. Positive values displace the text upwards.- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrFallbackNew
Create a new font fallback attribute.
If fallback is disabled, characters will only be
used from the closest matching font on the system.
No fallback will be done to other fonts on the system
that might contain the characters in the text.- Parameters:
enable_fallback
- %TRUE if we should fall back on other fonts for characters the active font is missing- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrFamilyNew
Create a new font family attribute.- Parameters:
family
- the family or comma-separated list of families- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrFontDescNew
Create a new font description attribute.
This attribute allows setting family, style, weight, variant,
stretch, and size simultaneously.- Parameters:
desc
- the font description- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrFontFeaturesNew
Create a new font features tag attribute.
You can use this attribute to select OpenType font features like small-caps,
alternative glyphs, ligatures, etc. for fonts that support them.- Parameters:
features
- a string with OpenType font features, with the syntax of the [CSS font-feature-settings property](https://www.w3.org/TR/css-fonts-4/#font-rend-desc)- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrFontScaleNew
Create a new font scale attribute.
The effect of this attribute is to change the font size of a run,
relative to the size of preceding run.- Parameters:
scale
- a `PangoFontScale` value, which indicates font size change relative to the size of the previous run.- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrForegroundAlphaNew
Create a new foreground alpha attribute.- Parameters:
alpha
- the alpha value, between 1 and 65536- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrForegroundNew
Create a new foreground color attribute.- Parameters:
red
- the red value (ranging from 0 to 65535)green
- the green valueblue
- the blue value- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrGravityHintNew
Create a new gravity hint attribute.- Parameters:
hint
- the gravity hint value- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrGravityNew
Create a new gravity attribute.- Parameters:
gravity
- the gravity value; should not be %PANGO_GRAVITY_AUTO- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrInsertHyphensNew
Create a new insert-hyphens attribute.
Pango will insert hyphens when breaking lines in
the middle of a word. This attribute can be used
to suppress the hyphen.- Parameters:
insert_hyphens
- %TRUE if hyphens should be inserted- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrLanguageNew
Create a new language tag attribute.- Parameters:
language
- language tag- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrLetterSpacingNew
Create a new letter-spacing attribute.- Parameters:
letter_spacing
- amount of extra space to add between graphemes of the text, in Pango units- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrLineHeightNew
Modify the height of logical line extents by a factor.
This affects the values returned by
[method@Pango.LayoutLine.get_extents],
[method@Pango.LayoutLine.get_pixel_extents] and
[method@Pango.LayoutIter.get_line_extents].- Parameters:
factor
- the scaling factor to apply to the logical height- Returns:
-
attrLineHeightNewAbsolute
Override the height of logical line extents to be @height.
This affects the values returned by
[method@Pango.LayoutLine.get_extents],
[method@Pango.LayoutLine.get_pixel_extents] and
[method@Pango.LayoutIter.get_line_extents].- Parameters:
height
- the line height, in %PANGO_SCALE-ths of a point- Returns:
-
attrListFromString
Deserializes a `PangoAttrList` from a string.
This is the counterpart to [method@Pango.AttrList.to_string].
See that functions for details about the format.- Parameters:
text
- a string- Returns:
- a new `PangoAttrList`
-
attrOverlineColorNew
Create a new overline color attribute.
This attribute modifies the color of overlines.
If not set, overlines will use the foreground color.- Parameters:
red
- the red value (ranging from 0 to 65535)green
- the green valueblue
- the blue value- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrOverlineNew
Create a new overline-style attribute.- Parameters:
overline
- the overline style- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrRiseNew
Create a new baseline displacement attribute.- Parameters:
rise
- the amount that the text should be displaced vertically, in Pango units. Positive values displace the text upwards.- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrScaleNew
Create a new font size scale attribute.
The base font for the affected text will have
its size multiplied by @scale_factor.- Parameters:
scale_factor
- factor to scale the font- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrSentenceNew
Marks the range of the attribute as a single sentence.
Note that this may require adjustments to word and
sentence classification around the range.- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrShapeNew
Create a new shape attribute.
A shape is used to impose a particular ink and logical
rectangle on the result of shaping a particular glyph.
This might be used, for instance, for embedding a picture
or a widget inside a `PangoLayout`.- Parameters:
ink_rect
- ink rectangle to assign to each characterlogical_rect
- logical rectangle to assign to each character- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrShapeNewWithData
public static Attribute attrShapeNewWithData(@Nonnull Rectangle ink_rect, @Nonnull Rectangle logical_rect, @Nullable Pointer data, Pango.OnAttrDataCopyFunc copy_func, Pango.OnDestroyNotify destroy_func) Creates a new shape attribute.
Like [func@Pango.AttrShape.new], but a user data pointer
is also provided; this pointer can be accessed when later
rendering the glyph.- Parameters:
ink_rect
- ink rectangle to assign to each characterlogical_rect
- logical rectangle to assign to each characterdata
- user data pointercopy_func
- function to copy @data when the attribute is copied. If %NULL, @data is simply copied as a pointerdestroy_func
- function to free @data when the attribute is freed- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrShowNew
Create a new attribute that influences how invisible
characters are rendered.- Parameters:
flags
- `PangoShowFlags` to apply- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrSizeNew
Create a new font-size attribute in fractional points.- Parameters:
size
- the font size, in %PANGO_SCALE-ths of a point- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrSizeNewAbsolute
Create a new font-size attribute in device units.- Parameters:
size
- the font size, in %PANGO_SCALE-ths of a device unit- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrStretchNew
Create a new font stretch attribute.- Parameters:
stretch
- the stretch- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrStrikethroughColorNew
Create a new strikethrough color attribute.
This attribute modifies the color of strikethrough lines.
If not set, strikethrough lines will use the foreground color.- Parameters:
red
- the red value (ranging from 0 to 65535)green
- the green valueblue
- the blue value- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrStrikethroughNew
Create a new strike-through attribute.- Parameters:
strikethrough
- %TRUE if the text should be struck-through- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrStyleNew
Create a new font slant style attribute.- Parameters:
style
- the slant style- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrTextTransformNew
Create a new attribute that influences how characters
are transformed during shaping.- Parameters:
transform
- `PangoTextTransform` to apply- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrTypeGetName
Fetches the attribute type name.
The attribute type name is the string passed in
when registering the type using
[func@Pango.AttrType.register].
The returned value is an interned string (see
g_intern_string() for what that means) that should
not be modified or freed.- Parameters:
type
- an attribute type ID to fetch the name for- Returns:
- the type ID name (which may be %NULL), or %NULL if @type is a built-in Pango attribute type or invalid.
-
attrTypeRegister
Allocate a new attribute type ID.
The attribute type name can be accessed later
by using [func@Pango.AttrType.get_name].- Parameters:
name
- an identifier for the type- Returns:
- the new type ID.
-
attrUnderlineColorNew
Create a new underline color attribute.
This attribute modifies the color of underlines.
If not set, underlines will use the foreground color.- Parameters:
red
- the red value (ranging from 0 to 65535)green
- the green valueblue
- the blue value- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrUnderlineNew
Create a new underline-style attribute.- Parameters:
underline
- the underline style- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrVariantNew
Create a new font variant attribute (normal or small caps).- Parameters:
variant
- the variant- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy].
-
attrWeightNew
Create a new font weight attribute.- Parameters:
weight
- the weight- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
attrWordNew
Marks the range of the attribute as a single word.
Note that this may require adjustments to word and
sentence classification around the range.- Returns:
- the newly allocated `PangoAttribute`, which should be freed with [method@Pango.Attribute.destroy]
-
bidiTypeForUnichar
public static int bidiTypeForUnichar(byte ch) Determines the bidirectional type of a character.
The bidirectional type is specified in the Unicode Character Database.
A simplified version of this function is available as [func@unichar_direction].- Parameters:
ch
- a Unicode character- Returns:
- the bidirectional character type, as used in the Unicode bidirectional algorithm.
-
defaultBreak
public static void defaultBreak(@Nonnull Str text, int length, @Nullable Analysis analysis, @Nonnull LogAttr attrs, int attrs_len) This is the default break algorithm.
It applies rules from the [Unicode Line Breaking Algorithm](http://www.unicode.org/unicode/reports/tr14/)
without language-specific tailoring, therefore the @analyis argument is unused
and can be %NULL.
See [func@Pango.tailor_break] for language-specific breaks.
See [func@Pango.attr_break] for attribute-based customization.- Parameters:
text
- text to break. Must be valid UTF-8length
- length of text in bytes (may be -1 if @text is nul-terminated)analysis
- a `PangoAnalysis` structure for the @textattrs
- logical attributes to fill inattrs_len
- size of the array passed as @attrs
-
extentsToPixels
Converts extents from Pango units to device units.
The conversion is done by dividing by the %PANGO_SCALE factor and
performing rounding.
The @inclusive rectangle is converted by flooring the x/y coordinates
and extending width/height, such that the final rectangle completely
includes the original rectangle.
The @nearest rectangle is converted by rounding the coordinates
of the rectangle to the nearest device unit (pixel).
The rule to which argument to use is: if you want the resulting device-space
rectangle to completely contain the original rectangle, pass it in as
@inclusive. If you want two touching-but-not-overlapping rectangles stay
touching-but-not-overlapping after rounding to device units, pass them in
as @nearest.- Parameters:
inclusive
- rectangle to round to pixels inclusivelynearest
- rectangle to round to nearest pixels
-
findBaseDir
Searches a string the first character that has a strong
direction, according to the Unicode bidirectional algorithm.- Parameters:
text
- the text to process. Must be valid UTF-8length
- length of @text in bytes (may be -1 if @text is nul-terminated)- Returns:
- The direction corresponding to the first strong character. If no such character is found, then %PANGO_DIRECTION_NEUTRAL is returned.
-
findParagraphBoundary
public static void findParagraphBoundary(@Nonnull Str text, int length, @Nonnull Int paragraph_delimiter_index, @Nonnull Int next_paragraph_start) Locates a paragraph boundary in @text.
A boundary is caused by delimiter characters, such as
a newline, carriage return, carriage return-newline pair,
or Unicode paragraph separator character.
The index of the run of delimiters is returned in
@paragraph_delimiter_index. The index of the start of the
next paragraph (index after all delimiters) is stored n
@next_paragraph_start.
If no delimiters are found, both @paragraph_delimiter_index
and @next_paragraph_start are filled with the length of @text
(an index one off the end).- Parameters:
text
- UTF-8 textlength
- length of @text in bytes, or -1 if nul-terminatedparagraph_delimiter_index
- return location for index of delimiternext_paragraph_start
- return location for start of next paragraph
-
fontDescriptionFromString
Creates a new font description from a string representation.
The string must have the form
"\[FAMILY-LIST] \[STYLE-OPTIONS] \[SIZE] \[VARIATIONS]",
where FAMILY-LIST is a comma-separated list of families optionally
terminated by a comma, STYLE_OPTIONS is a whitespace-separated list
of words where each word describes one of style, variant, weight,
stretch, or gravity, and SIZE is a decimal number (size in points)
or optionally followed by the unit modifier "px" for absolute size.
VARIATIONS is a comma-separated list of font variation
specifications of the form "\@axis=value" (the = sign is optional).
The following words are understood as styles:
"Normal", "Roman", "Oblique", "Italic".
The following words are understood as variants:
"Small-Caps", "All-Small-Caps", "Petite-Caps", "All-Petite-Caps",
"Unicase", "Title-Caps".
The following words are understood as weights:
"Thin", "Ultra-Light", "Extra-Light", "Light", "Semi-Light",
"Demi-Light", "Book", "Regular", "Medium", "Semi-Bold", "Demi-Bold",
"Bold", "Ultra-Bold", "Extra-Bold", "Heavy", "Black", "Ultra-Black",
"Extra-Black".
The following words are understood as stretch values:
"Ultra-Condensed", "Extra-Condensed", "Condensed", "Semi-Condensed",
"Semi-Expanded", "Expanded", "Extra-Expanded", "Ultra-Expanded".
The following words are understood as gravity values:
"Not-Rotated", "South", "Upside-Down", "North", "Rotated-Left",
"East", "Rotated-Right", "West".
Any one of the options may be absent. If FAMILY-LIST is absent, then
the family_name field of the resulting font description will be
initialized to %NULL. If STYLE-OPTIONS is missing, then all style
options will be set to the default values. If SIZE is missing, the
size in the resulting font description will be set to 0.
A typical example:
"Cantarell Italic Light 15 \@wght=200"- Parameters:
str
- string representation of a font description.- Returns:
- a new `PangoFontDescription`.
-
gravityGetForMatrix
Finds the gravity that best matches the rotation component
in a `PangoMatrix`.- Parameters:
matrix
- a `PangoMatrix`- Returns:
- the gravity of @matrix, which will never be %PANGO_GRAVITY_AUTO, or %PANGO_GRAVITY_SOUTH if @matrix is %NULL
-
gravityGetForScript
public static int gravityGetForScript(int script, int base_gravity, int hint) Returns the gravity to use in laying out a `PangoItem`.
The gravity is determined based on the script, base gravity, and hint.
If @base_gravity is %PANGO_GRAVITY_AUTO, it is first replaced with the
preferred gravity of @script. To get the preferred gravity of a script,
pass %PANGO_GRAVITY_AUTO and %PANGO_GRAVITY_HINT_STRONG in.- Parameters:
script
- `PangoScript` to querybase_gravity
- base gravity of the paragraphhint
- orientation hint- Returns:
- resolved gravity suitable to use for a run of text with @script
-
gravityGetForScriptAndWidth
public static int gravityGetForScriptAndWidth(int script, boolean wide, int base_gravity, int hint) Returns the gravity to use in laying out a single character
or `PangoItem`.
The gravity is determined based on the script, East Asian width,
base gravity, and hint,
This function is similar to [func@Pango.Gravity.get_for_script] except
that this function makes a distinction between narrow/half-width and
wide/full-width characters also. Wide/full-width characters always
stand *upright*, that is, they always take the base gravity,
whereas narrow/full-width characters are always rotated in vertical
context.
If @base_gravity is %PANGO_GRAVITY_AUTO, it is first replaced with the
preferred gravity of @script.- Parameters:
script
- `PangoScript` to querywide
- %TRUE for wide characters as returned by g_unichar_iswide()base_gravity
- base gravity of the paragraphhint
- orientation hint- Returns:
- resolved gravity suitable to use for a run of text with @script and @wide.
-
gravityToRotation
public static double gravityToRotation(int gravity) Converts a `PangoGravity` value to its natural rotation in radians.
Note that [method@Pango.Matrix.rotate] takes angle in degrees, not radians.
So, to call [method@Pango.Matrix,rotate] with the output of this function
you should multiply it by (180. / G_PI).- Parameters:
gravity
- gravity to query, should not be %PANGO_GRAVITY_AUTO- Returns:
- the rotation value corresponding to @gravity.
-
isZeroWidth
public static boolean isZeroWidth(byte ch) Checks if a character that should not be normally rendered.
This includes all Unicode characters with "ZERO WIDTH" in their name,
as well as *bidi* formatting characters, and a few other ones.
This is totally different from [func@GLib.unichar_iszerowidth] and is at best misnamed.- Parameters:
ch
- a Unicode character- Returns:
- %TRUE if @ch is a zero-width character, %FALSE otherwise
-
itemize
public static List itemize(@Nonnull Context context, @Nonnull Str text, int start_index, int length, @Nonnull AttrList attrs, @Nullable AttrIterator cached_iter) Breaks a piece of text into segments with consistent directional
level and font.
Each byte of @text will be contained in exactly one of the items in the
returned list; the generated list of items will be in logical order (the
start offsets of the items are ascending).
@cached_iter should be an iterator over @attrs currently positioned
at a range before or containing @start_index; @cached_iter will be
advanced to the range covering the position just after
@start_index + @length. (i.e. if itemizing in a loop, just keep passing
in the same @cached_iter).- Parameters:
context
- a structure holding information that affects the itemization process.text
- the text to itemize. Must be valid UTF-8start_index
- first byte in @text to processlength
- the number of bytes (not characters) to process after @start_index. This must be >= 0.attrs
- the set of attributes that apply to @text.cached_iter
- Cached attribute iterator- Returns:
- a `GList` of [struct@Pango.Item] structures. The items should be freed using [method@Pango.Item.free] in combination with [func@GLib.List.free_full].
-
itemizeWithBaseDir
public static List itemizeWithBaseDir(@Nonnull Context context, int base_dir, @Nonnull Str text, int start_index, int length, @Nonnull AttrList attrs, @Nullable AttrIterator cached_iter) Like `pango_itemize()`, but with an explicitly specified base direction.
The base direction is used when computing bidirectional levels.
[func@itemize] gets the base direction from the `PangoContext`
(see [method@Pango.Context.set_base_dir]).- Parameters:
context
- a structure holding information that affects the itemization process.base_dir
- base direction to use for bidirectional processingtext
- the text to itemize.start_index
- first byte in @text to processlength
- the number of bytes (not characters) to process after @start_index. This must be >= 0.attrs
- the set of attributes that apply to @text.cached_iter
- Cached attribute iterator- Returns:
- a `GList` of [struct@Pango.Item] structures. The items should be freed using [method@Pango.Item.free] probably in combination with [func@GLib.List.free_full].
-
languageFromString
Convert a language tag to a `PangoLanguage`.
The language tag must be in a RFC-3066 format. `PangoLanguage` pointers
can be efficiently copied (copy the pointer) and compared with other
language tags (compare the pointer.)
This function first canonicalizes the string by converting it to
lowercase, mapping '_' to '-', and stripping all characters other
than letters and '-'.
Use [func@Pango.Language.get_default] if you want to get the
`PangoLanguage` for the current locale of the process.- Parameters:
language
- a string representing a language tag- Returns:
- a `PangoLanguage`
-
languageGetDefault
Returns the `PangoLanguage` for the current locale of the process.
On Unix systems, this is the return value is derived from
`setlocale (LC_CTYPE, NULL)`, and the user can
affect this through the environment variables LC_ALL, LC_CTYPE or
LANG (checked in that order). The locale string typically is in
the form lang_COUNTRY, where lang is an ISO-639 language code, and
COUNTRY is an ISO-3166 country code. For instance, sv_FI for
Swedish as written in Finland or pt_BR for Portuguese as written in
Brazil.
On Windows, the C library does not use any such environment
variables, and setting them won't affect the behavior of functions
like ctime(). The user sets the locale through the Regional Options
in the Control Panel. The C library (in the setlocale() function)
does not use country and language codes, but country and language
names spelled out in English.
However, this function does check the above environment
variables, and does return a Unix-style locale string based on
either said environment variables or the thread's current locale.
Your application should call `setlocale(LC_ALL, "")` for the user
settings to take effect. GTK does this in its initialization
functions automatically (by calling gtk_set_locale()).
See the setlocale() manpage for more details.
Note that the default language can change over the life of an application.
Also note that this function will not do the right thing if you
use per-thread locales with uselocale(). In that case, you should
just call pango_language_from_string() yourself.- Returns:
- the default language as a `PangoLanguage`
-
layoutDeserializeErrorQuark
public static int layoutDeserializeErrorQuark()- Returns:
-
markupParserNew
Incrementally parses marked-up text to create a plain-text string
and an attribute list.
See the [Pango Markup](pango_markup.html) docs for details about the
supported markup.
If @accel_marker is nonzero, the given character will mark the
character following it as an accelerator. For example, @accel_marker
might be an ampersand or underscore. All characters marked
as an accelerator will receive a %PANGO_UNDERLINE_LOW attribute,
and the first character so marked will be returned in @accel_char,
when calling [func@markup_parser_finish]. Two @accel_marker characters
following each other produce a single literal @accel_marker character.
To feed markup to the parser, use [method@GLib.MarkupParseContext.parse]
on the returned [struct@GLib.MarkupParseContext]. When done with feeding markup
to the parser, use [func@markup_parser_finish] to get the data out
of it, and then use [method@GLib.MarkupParseContext.free] to free it.
This function is designed for applications that read Pango markup
from streams. To simply parse a string containing Pango markup,
the [func@Pango.parse_markup] API is recommended instead.- Parameters:
accel_marker
- character that precedes an accelerator, or 0 for none- Returns:
- a `GMarkupParseContext` that should be destroyed with [method@GLib.MarkupParseContext.free].
-
parseStretch
Parses a font stretch.
The allowed values are
"ultra_condensed", "extra_condensed", "condensed",
"semi_condensed", "normal", "semi_expanded", "expanded",
"extra_expanded" and "ultra_expanded". Case variations are
ignored and the '_' characters may be omitted.- Parameters:
str
- a string to parse.stretch
- a `PangoStretch` to store the result in.warn
- if %TRUE, issue a g_warning() on bad input.- Returns:
- %TRUE if @str was successfully parsed.
-
parseStyle
Parses a font style.
The allowed values are "normal", "italic" and "oblique", case
variations being
ignored.- Parameters:
str
- a string to parse.style
- a `PangoStyle` to store the result in.warn
- if %TRUE, issue a g_warning() on bad input.- Returns:
- %TRUE if @str was successfully parsed.
-
parseVariant
Parses a font variant.
The allowed values are "normal", "small-caps", "all-small-caps",
"petite-caps", "all-petite-caps", "unicase" and "title-caps",
case variations being ignored.- Parameters:
str
- a string to parse.variant
- a `PangoVariant` to store the result in.warn
- if %TRUE, issue a g_warning() on bad input.- Returns:
- %TRUE if @str was successfully parsed.
-
parseWeight
Parses a font weight.
The allowed values are "heavy",
"ultrabold", "bold", "normal", "light", "ultraleight"
and integers. Case variations are ignored.- Parameters:
str
- a string to parse.weight
- a `PangoWeight` to store the result in.warn
- if %TRUE, issue a g_warning() on bad input.- Returns:
- %TRUE if @str was successfully parsed.
-
quantizeLineGeometry
Quantizes the thickness and position of a line to whole device pixels.
This is typically used for underline or strikethrough. The purpose of
this function is to avoid such lines looking blurry.
Care is taken to make sure @thickness is at least one pixel when this
function returns, but returned @position may become zero as a result
of rounding.- Parameters:
thickness
- pointer to the thickness of a line, in Pango unitsposition
- corresponding position
-
reorderItems
Reorder items from logical order to visual order.
The visual order is determined from the associated directional
levels of the items. The original list is unmodified.
(Please open a bug if you use this function.
It is not a particularly convenient interface, and the code
is duplicated elsewhere in Pango for that reason.)- Parameters:
items
- a `GList` of `PangoItem` in logical order.- Returns:
- a `GList` of `PangoItem` structures in visual order.
-
scriptGetSampleLanguage
Finds a language tag that is reasonably representative of @script.
The language will usually be the most widely spoken or used language
written in that script: for instance, the sample language for
%PANGO_SCRIPT_CYRILLIC is ru (Russian), the sample language for
%PANGO_SCRIPT_ARABIC is ar.
For some scripts, no sample language will be returned because
there is no language that is sufficiently representative. The
best example of this is %PANGO_SCRIPT_HAN, where various different
variants of written Chinese, Japanese, and Korean all use
significantly different sets of Han characters and forms
of shared characters. No sample language can be provided
for many historical scripts as well.
As of 1.18, this function checks the environment variables
`PANGO_LANGUAGE` and `LANGUAGE` (checked in that order) first.
If one of them is set, it is parsed as a list of language tags
separated by colons or other separators. This function
will return the first language in the parsed list that Pango
believes may use @script for writing. This last predicate
is tested using [method@Pango.Language.includes_script]. This can
be used to control Pango's font selection for non-primary
languages. For example, a `PANGO_LANGUAGE` enviroment variable
set to "en:fa" makes Pango choose fonts suitable for Persian (fa)
instead of Arabic (ar) when a segment of Arabic text is found
in an otherwise non-Arabic text. The same trick can be used to
choose a default language for %PANGO_SCRIPT_HAN when setting
context language is not feasible.- Parameters:
script
- a `PangoScript`- Returns:
- a `PangoLanguage` that is representative of the script
-
shape
public static void shape(@Nonnull Str text, int length, @Nonnull Analysis analysis, @Nonnull GlyphString glyphs) Convert the characters in @text into glyphs.
Given a segment of text and the corresponding `PangoAnalysis` structure
returned from [func@Pango.itemize], convert the characters into glyphs. You
may also pass in only a substring of the item from [func@Pango.itemize].
It is recommended that you use [func@Pango.shape_full] instead, since
that API allows for shaping interaction happening across text item
boundaries.
Some aspects of hyphen insertion and text transformation (in particular,
capitalization) require log attrs, and thus can only be handled by
[func@Pango.shape_item].
Note that the extra attributes in the @analyis that is returned from
[func@Pango.itemize] have indices that are relative to the entire paragraph,
so you need to subtract the item offset from their indices before
calling [func@Pango.shape].- Parameters:
text
- the text to processlength
- the length (in bytes) of @textanalysis
- `PangoAnalysis` structure from [func@Pango.itemize]glyphs
- glyph string in which to store results
-
shapeFull
public static void shapeFull(@Nonnull Str item_text, int item_length, @Nullable Str paragraph_text, int paragraph_length, @Nonnull Analysis analysis, @Nonnull GlyphString glyphs) Convert the characters in @text into glyphs.
Given a segment of text and the corresponding `PangoAnalysis` structure
returned from [func@Pango.itemize], convert the characters into glyphs.
You may also pass in only a substring of the item from [func@Pango.itemize].
This is similar to [func@Pango.shape], except it also can optionally take
the full paragraph text as input, which will then be used to perform
certain cross-item shaping interactions. If you have access to the broader
text of which @item_text is part of, provide the broader text as
@paragraph_text. If @paragraph_text is %NULL, item text is used instead.
Some aspects of hyphen insertion and text transformation (in particular,
capitalization) require log attrs, and thus can only be handled by
[func@Pango.shape_item].
Note that the extra attributes in the @analyis that is returned from
[func@Pango.itemize] have indices that are relative to the entire paragraph,
so you do not pass the full paragraph text as @paragraph_text, you need
to subtract the item offset from their indices before calling
[func@Pango.shape_full].- Parameters:
item_text
- valid UTF-8 text to shape.item_length
- the length (in bytes) of @item_text. -1 means nul-terminated text.paragraph_text
- text of the paragraph (see details).paragraph_length
- the length (in bytes) of @paragraph_text. -1 means nul-terminated text.analysis
- `PangoAnalysis` structure from [func@Pango.itemize].glyphs
- glyph string in which to store results.
-
shapeItem
public static void shapeItem(@Nonnull Item item, @Nullable Str paragraph_text, int paragraph_length, @Nullable LogAttr log_attrs, @Nonnull GlyphString glyphs, int flags) Convert the characters in @item into glyphs.
This is similar to [func@Pango.shape_with_flags], except it takes a
`PangoItem` instead of separate @item_text and @analysis arguments.
It also takes @log_attrs, which are needed for implementing some aspects
of hyphen insertion and text transforms (in particular, capitalization).
Note that the extra attributes in the @analyis that is returned from
[func@Pango.itemize] have indices that are relative to the entire paragraph,
so you do not pass the full paragraph text as @paragraph_text, you need
to subtract the item offset from their indices before calling
[func@Pango.shape_with_flags].- Parameters:
item
- `PangoItem` to shapeparagraph_text
- text of the paragraph (see details).paragraph_length
- the length (in bytes) of @paragraph_text. -1 means nul-terminated text.log_attrs
- array of `PangoLogAttr` for @itemglyphs
- glyph string in which to store resultsflags
- flags influencing the shaping process
-
shapeWithFlags
public static void shapeWithFlags(@Nonnull Str item_text, int item_length, @Nullable Str paragraph_text, int paragraph_length, @Nonnull Analysis analysis, @Nonnull GlyphString glyphs, int flags) Convert the characters in @text into glyphs.
Given a segment of text and the corresponding `PangoAnalysis` structure
returned from [func@Pango.itemize], convert the characters into glyphs.
You may also pass in only a substring of the item from [func@Pango.itemize].
This is similar to [func@Pango.shape_full], except it also takes flags
that can influence the shaping process.
Some aspects of hyphen insertion and text transformation (in particular,
capitalization) require log attrs, and thus can only be handled by
[func@Pango.shape_item].
Note that the extra attributes in the @analyis that is returned from
[func@Pango.itemize] have indices that are relative to the entire paragraph,
so you do not pass the full paragraph text as @paragraph_text, you need
to subtract the item offset from their indices before calling
[func@Pango.shape_with_flags].- Parameters:
item_text
- valid UTF-8 text to shapeitem_length
- the length (in bytes) of @item_text. -1 means nul-terminated text.paragraph_text
- text of the paragraph (see details).paragraph_length
- the length (in bytes) of @paragraph_text. -1 means nul-terminated text.analysis
- `PangoAnalysis` structure from [func@Pango.itemize]glyphs
- glyph string in which to store resultsflags
- flags influencing the shaping process
-
tabArrayFromString
Deserializes a `PangoTabArray` from a string.
This is the counterpart to [method@Pango.TabArray.to_string].
See that functions for details about the format.- Parameters:
text
- a string- Returns:
- a new `PangoTabArray`
-
unicharDirection
public static int unicharDirection(byte ch) Determines the inherent direction of a character.
The inherent direction is either `PANGO_DIRECTION_LTR`, `PANGO_DIRECTION_RTL`,
or `PANGO_DIRECTION_NEUTRAL`.
This function is useful to categorize characters into left-to-right
letters, right-to-left letters, and everything else. If full Unicode
bidirectional type of a character is needed, [func@Pango.BidiType.for_unichar]
can be used instead.- Parameters:
ch
- a Unicode character- Returns:
- the direction of the character.
-
unitsFromDouble
public static int unitsFromDouble(double d) Converts a floating-point number to Pango units.
The conversion is done by multiplying @d by %PANGO_SCALE and
rounding the result to nearest integer.- Parameters:
d
- double floating-point value- Returns:
- the value in Pango units.
-
unitsToDouble
public static double unitsToDouble(int i) Converts a number in Pango units to floating-point.
The conversion is done by dividing @i by %PANGO_SCALE.- Parameters:
i
- value in Pango units- Returns:
- the double value.
-
version
public static int version()Returns the encoded version of Pango available at run-time.
This is similar to the macro %PANGO_VERSION except that the macro
returns the encoded version available at compile-time. A version
number can be encoded into an integer using PANGO_VERSION_ENCODE().- Returns:
- The encoded version of Pango library available at run time.
-
versionCheck
Checks that the Pango library in use is compatible with the
given version.
Generally you would pass in the constants %PANGO_VERSION_MAJOR,
%PANGO_VERSION_MINOR, %PANGO_VERSION_MICRO as the three arguments
to this function; that produces a check that the library in use at
run-time is compatible with the version of Pango the application or
module was compiled against.
Compatibility is defined by two things: first the version
of the running library is newer than the version
@required_major.required_minor.@required_micro. Second
the running library must be binary compatible with the
version @required_major.required_minor.@required_micro
(same major version.)
For compile-time version checking use PANGO_VERSION_CHECK().- Parameters:
required_major
- the required major versionrequired_minor
- the required minor versionrequired_micro
- the required major version- Returns:
- %NULL if the Pango library is compatible with the given version, or a string describing the version mismatch. The returned string is owned by Pango and should not be modified or freed.
-
versionString
Returns the version of Pango available at run-time.
This is similar to the macro %PANGO_VERSION_STRING except that the
macro returns the version available at compile-time.- Returns:
- A string containing the version of Pango library available at run time. The returned string is owned by Pango and should not be modified or freed.
-