From a8489aeb8bec1af8bfa94ae293b7de56f323116d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 13:39:05 +0000 Subject: [PATCH 01/13] Initial plan From bb9b50cadedd20eecc9d094d4268171e9bd9450c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 13:45:31 +0000 Subject: [PATCH 02/13] Add attribute.stub.php with PHP OO API for Pango text attributes - Add Color class (readonly, 16-bit RGB with parse/toString) - Add AttrType enum with all PangoAttrType values and version guards - Add abstract Attribute base class with startIndex/endIndex and static factory methods for all attribute types - Add AttrString, AttrInt, AttrFloat, AttrColor, AttrSize, AttrFontDesc concrete attribute subclasses - Add Underline enum (with >= 1.50 cases) - Add Overline enum (>= 1.46) - Add ShowFlags abstract class with bitfield constants (>= 1.44) - Add BaselineShift, FontScale, TextTransform enums (>= 1.50) - Add AttrList class with insert/change/getAttributes/splice and update (>= 1.44), toString/fromString (>= 1.50) --- src/attribute.stub.php | 1007 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1007 insertions(+) create mode 100644 src/attribute.stub.php diff --git a/src/attribute.stub.php b/src/attribute.stub.php new file mode 100644 index 0000000..aef0240 --- /dev/null +++ b/src/attribute.stub.php @@ -0,0 +1,1007 @@ += PANGO_VERSION_ENCODE(1, 38, 0) + /** + * @cvalue PANGO_ATTR_FONT_FEATURES + */ + case FontFeatures = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_FOREGROUND_ALPHA + */ + case ForegroundAlpha = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_BACKGROUND_ALPHA + */ + case BackgroundAlpha = UNKNOWN; +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 44, 0) + /** + * @cvalue PANGO_ATTR_ALLOW_BREAKS + */ + case AllowBreaks = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_SHOW + */ + case Show = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_INSERT_HYPHENS + */ + case InsertHyphens = UNKNOWN; +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 46, 0) + /** + * @cvalue PANGO_ATTR_OVERLINE + */ + case Overline = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_OVERLINE_COLOR + */ + case OverlineColor = UNKNOWN; +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) + /** + * @cvalue PANGO_ATTR_LINE_HEIGHT + */ + case LineHeight = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_ABSOLUTE_LINE_HEIGHT + */ + case AbsoluteLineHeight = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_TEXT_TRANSFORM + */ + case TextTransform = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_WORD + */ + case Word = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_SENTENCE + */ + case Sentence = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_BASELINE_SHIFT + */ + case BaselineShift = UNKNOWN; + + /** + * @cvalue PANGO_ATTR_FONT_SCALE + */ + case FontScale = UNKNOWN; +#endif +} + +/** + * Attribute is the base class for all Pango text attributes. + * + * Attributes are used to modify the rendering of text in a Pango layout. + * Each attribute applies to a byte range in the text defined by + * startIndex and endIndex. + * + * Use the static factory methods (e.g., family(), style(), foreground()) + * to create specific attribute instances. + */ +abstract class Attribute +{ + /** + * The start byte index of the range. + * + * 0 is the beginning of the text (PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING). + */ + public int $startIndex; + + /** + * The end byte index of the range (exclusive). + * + * PHP_INT_MAX means the attribute applies to the end of the text + * (PANGO_ATTR_INDEX_TO_TEXT_END). + */ + public int $endIndex; + + /** + * Returns the type of this attribute. + */ + public function getAttrType(): AttrType {} + + /** + * Create a new language tag attribute. + * + * @param string $language A BCP 47 language tag string (e.g., "en", "de", "zh-cn"). + */ + public static function language(string $language): AttrString {} + + /** + * Create a new font-family attribute. + * + * @param string $family The font family name. + */ + public static function family(string $family): AttrString {} + + /** + * Create a new font-style attribute. + */ + public static function style(Style $style): AttrInt {} + + /** + * Create a new font-weight attribute. + */ + public static function weight(Weight $weight): AttrInt {} + + /** + * Create a new font-variant attribute. + */ + public static function variant(Variant $variant): AttrInt {} + + /** + * Create a new font-stretch attribute. + */ + public static function stretch(Stretch $stretch): AttrInt {} + + /** + * Create a new font-size attribute in Pango units. + * + * @param int $size The font size in Pango units (use Pango\Pango::SCALE * points). + */ + public static function size(int $size): AttrSize {} + + /** + * Create a new font-size attribute in device units. + * + * @param int $size The font size in Pango units (absolute, not scaled with the DPI). + */ + public static function sizeAbsolute(int $size): AttrSize {} + + /** + * Create a new font-description attribute. + * + * This attribute allows setting all font properties in one step using a + * FontDescription object. + */ + public static function fontDescription(FontDescription $desc): AttrFontDesc {} + + /** + * Create a new foreground color attribute. + * + * @param int $red Red component, range 0-65535. + * @param int $green Green component, range 0-65535. + * @param int $blue Blue component, range 0-65535. + */ + public static function foreground(int $red, int $green, int $blue): AttrColor {} + + /** + * Create a new background color attribute. + * + * @param int $red Red component, range 0-65535. + * @param int $green Green component, range 0-65535. + * @param int $blue Blue component, range 0-65535. + */ + public static function background(int $red, int $green, int $blue): AttrColor {} + + /** + * Create a new underline-style attribute. + */ + public static function underline(Underline $underline): AttrInt {} + + /** + * Create a new underline color attribute. + * + * This attribute modifies the color of underlines. If not set, underlines + * will use the foreground color. + * + * @param int $red Red component, range 0-65535. + * @param int $green Green component, range 0-65535. + * @param int $blue Blue component, range 0-65535. + */ + public static function underlineColor(int $red, int $green, int $blue): AttrColor {} + + /** + * Create a new strikethrough attribute. + * + * @param bool $strikethrough True if the text should be struck-through. + */ + public static function strikethrough(bool $strikethrough): AttrInt {} + + /** + * Create a new strikethrough color attribute. + * + * This attribute modifies the color of strikethroughs. If not set, + * strikethroughs will use the foreground color. + * + * @param int $red Red component, range 0-65535. + * @param int $green Green component, range 0-65535. + * @param int $blue Blue component, range 0-65535. + */ + public static function strikethroughColor(int $red, int $green, int $blue): AttrColor {} + + /** + * Create a new baseline displacement attribute. + * + * @param int $rise The amount that the text should be displaced vertically, in Pango + * units. Positive values displace the text upwards. + */ + public static function rise(int $rise): AttrInt {} + + /** + * Create a new font-scale-factor attribute. + * + * @param float $scaleFactor The factor to scale the font by relative to the base font. + */ + public static function scale(float $scaleFactor): AttrFloat {} + + /** + * 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. + * + * @param bool $enableFallback True to enable fallback, false to disable. + */ + public static function fallback(bool $enableFallback): AttrInt {} + + /** + * Create a new letter-spacing attribute. + * + * @param int $letterSpacing The amount of extra space to add between graphemes of the + * text, in Pango units. + */ + public static function letterSpacing(int $letterSpacing): AttrInt {} + + /** + * Create a new glyph-gravity attribute. + */ + public static function gravity(Gravity $gravity): AttrInt {} + + /** + * Create a new gravity-hint attribute. + */ + public static function gravityHint(GravityHint $hint): AttrInt {} + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 38, 0) + /** + * Create a new font-features attribute. + * + * @param string $features A string of font features in CSS syntax, e.g. "dlig=1". + */ + public static function fontFeatures(string $features): AttrString {} + + /** + * Create a new foreground-alpha attribute. + * + * @param int $alpha The alpha value, range 1-65536. + */ + public static function foregroundAlpha(int $alpha): AttrInt {} + + /** + * Create a new background-alpha attribute. + * + * @param int $alpha The alpha value, range 1-65536. + */ + public static function backgroundAlpha(int $alpha): AttrInt {} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 44, 0) + /** + * Create a new allow-breaks attribute. + * + * If breaks are disabled, the range will be kept in a single run as far as possible. + * + * @param bool $allowBreaks True if line breaks are allowed. + */ + public static function allowBreaks(bool $allowBreaks): AttrInt {} + + /** + * Create a new attribute to control what the display of invisible characters. + * + * @param int $flags Bitwise OR of ShowFlags constants. + */ + public static function show(int $flags): AttrInt {} + + /** + * 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. + * + * @param bool $insertHyphens True if hyphens should be inserted. + */ + public static function insertHyphens(bool $insertHyphens): AttrInt {} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 46, 0) + /** + * Create a new overline-style attribute. + */ + public static function overline(Overline $overline): AttrInt {} + + /** + * Create a new overline-color attribute. + * + * This attribute modifies the color of overlines. If not set, overlines + * will use the foreground color. + * + * @param int $red Red component, range 0-65535. + * @param int $green Green component, range 0-65535. + * @param int $blue Blue component, range 0-65535. + */ + public static function overlineColor(int $red, int $green, int $blue): AttrColor {} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) + /** + * Create a new line-height attribute that changes line spacing by a factor. + * + * @param float $factor The factor to scale the line height by. + */ + public static function lineHeight(float $factor): AttrFloat {} + + /** + * Create a new line-height attribute with an absolute line height in Pango units. + * + * @param int $height The line height in Pango units. + */ + public static function lineHeightAbsolute(int $height): AttrInt {} + + /** + * Create a new attribute that marks its range as a single word. + * + * Note that this may conflict with line breaking rules, so you can't use this + * expect for specially controlled text. + */ + public static function word(): AttrInt {} + + /** + * Create a new attribute that marks its range as a single sentence. + * + * Note that this may conflict with line breaking rules, so you can't use this + * except for specially controlled text. + */ + public static function sentence(): AttrInt {} + + /** + * Create a new baseline-shift attribute. + */ + public static function baselineShift(BaselineShift $shift): AttrInt {} + + /** + * Create a new font-scale attribute. + */ + public static function fontScale(FontScale $scale): AttrInt {} + + /** + * Create a new text-transform attribute. + */ + public static function textTransform(TextTransform $transform): AttrInt {} +#endif +} + +/** + * AttrString is an Attribute that holds a string value. + * + * It is used for: AttrType::Family, AttrType::Language, + * and (>= 1.38) AttrType::FontFeatures. + */ +final class AttrString extends Attribute +{ + /** + * The string value of the attribute. + */ + public string $value; +} + +/** + * AttrInt is an Attribute that holds an integer value. + * + * It is used for many attribute types including style, weight, underline, rise, etc. + */ +final class AttrInt extends Attribute +{ + /** + * The integer value of the attribute. + */ + public int $value; +} + +/** + * AttrFloat is an Attribute that holds a floating-point value. + * + * It is used for: AttrType::Scale, and (>= 1.50) AttrType::LineHeight. + */ +final class AttrFloat extends Attribute +{ + /** + * The float value of the attribute. + */ + public float $value; +} + +/** + * AttrColor is an Attribute that holds a Color value. + * + * It is used for: AttrType::Foreground, AttrType::Background, + * AttrType::UnderlineColor, AttrType::StrikethroughColor, + * and (>= 1.46) AttrType::OverlineColor. + */ +final class AttrColor extends Attribute +{ + /** + * The color value of the attribute. + */ + public Color $color; +} + +/** + * AttrSize is an Attribute that holds a font size. + * + * It is used for: AttrType::Size and AttrType::AbsoluteSize. + */ +final class AttrSize extends Attribute +{ + /** + * The font size in Pango units. + */ + public int $value; + + /** + * Whether this is an absolute size (device units) rather than a scaled size. + */ + public bool $absolute; +} + +/** + * AttrFontDesc is an Attribute that holds a FontDescription. + * + * It is used for: AttrType::FontDesc. + */ +final class AttrFontDesc extends Attribute +{ + /** + * The font description. + */ + public FontDescription $desc; +} + +/** + * Underline describes the type of underline used for decorating text. + */ +enum Underline: int +{ + /** + * No underline should be drawn. + * + * @cvalue PANGO_UNDERLINE_NONE + */ + case None = UNKNOWN; + + /** + * A single underline should be drawn. + * + * @cvalue PANGO_UNDERLINE_SINGLE + */ + case Single = UNKNOWN; + + /** + * A double underline should be drawn. + * + * @cvalue PANGO_UNDERLINE_DOUBLE + */ + case Double = UNKNOWN; + + /** + * A single underline should be drawn at a position beneath the ink extents + * of the text being underlined. + * + * This should be used only for underlining single characters, such as for + * keyboard accelerators. Pango::UNDERLINE_SINGLE should be used for extended + * portions of text. + * + * @cvalue PANGO_UNDERLINE_LOW + */ + case Low = UNKNOWN; + + /** + * An underline indicating an error should be drawn below. + * + * The exact style of rendering is platform-dependent but it typically looks + * like a wavy line. It is designed to indicate a misspelling. + * + * @cvalue PANGO_UNDERLINE_ERROR + */ + case Error = UNKNOWN; + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) + /** + * Like Single, but drawn continuously across multiple runs. + * + * @cvalue PANGO_UNDERLINE_SINGLE_LINE + */ + case SingleLine = UNKNOWN; + + /** + * Like Double, but drawn continuously across multiple runs. + * + * @cvalue PANGO_UNDERLINE_DOUBLE_LINE + */ + case DoubleLine = UNKNOWN; + + /** + * Like Error, but drawn continuously across multiple runs. + * + * @cvalue PANGO_UNDERLINE_ERROR_LINE + */ + case ErrorLine = UNKNOWN; +#endif +} + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 46, 0) +/** + * Overline describes the type of overline used for decorating text. + */ +enum Overline: int +{ + /** + * No overline should be drawn. + * + * @cvalue PANGO_OVERLINE_NONE + */ + case None = UNKNOWN; + + /** + * Draw a single overline above the ink extents of the text being underlined. + * + * @cvalue PANGO_OVERLINE_SINGLE + */ + case Single = UNKNOWN; +} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 44, 0) +/** + * ShowFlags affects how Pango renders characters that are usually invisible in the output. + * + * This class is not instantiable. + */ +abstract class ShowFlags +{ + /** + * No special treatment for invisible characters. + * + * @var int + * @cvalue PANGO_SHOW_NONE + */ + public const NONE = UNKNOWN; + + /** + * Render spaces, tabs and newlines visibly. + * + * @var int + * @cvalue PANGO_SHOW_SPACES + */ + public const SPACES = UNKNOWN; + + /** + * Render line breaks visibly. + * + * @var int + * @cvalue PANGO_SHOW_LINE_BREAKS + */ + public const LINE_BREAKS = UNKNOWN; + + /** + * Render default-ignorable Unicode characters visibly. + * + * @var int + * @cvalue PANGO_SHOW_IGNORABLES + */ + public const IGNORABLES = UNKNOWN; +} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) +/** + * BaselineShift describes how the baseline of the text should be shifted. + */ +enum BaselineShift: int +{ + /** + * Leave the baseline in place. + * + * @cvalue PANGO_BASELINE_SHIFT_NONE + */ + case None = UNKNOWN; + + /** + * Shift the baseline to the superscript position, relative to the default baseline. + * + * @cvalue PANGO_BASELINE_SHIFT_SUPERSCRIPT + */ + case Superscript = UNKNOWN; + + /** + * Shift the baseline to the subscript position, relative to the default baseline. + * + * @cvalue PANGO_BASELINE_SHIFT_SUBSCRIPT + */ + case Subscript = UNKNOWN; +} + +/** + * FontScale describes how the scale of the font should be changed relative to the inherited + * font size. + */ +enum FontScale: int +{ + /** + * Leave the font size unchanged. + * + * @cvalue PANGO_FONT_SCALE_NONE + */ + case None = UNKNOWN; + + /** + * Change the font to the size used for superscripts. + * + * @cvalue PANGO_FONT_SCALE_SUPERSCRIPT + */ + case Superscript = UNKNOWN; + + /** + * Change the font to the size used for subscripts. + * + * @cvalue PANGO_FONT_SCALE_SUBSCRIPT + */ + case Subscript = UNKNOWN; + + /** + * Change the font to the size used for Small Caps. + * + * @cvalue PANGO_FONT_SCALE_SMALL_CAPS + */ + case SmallCaps = UNKNOWN; +} + +/** + * TextTransform describes how text should be transformed during rendering. + */ +enum TextTransform: int +{ + /** + * No transformation. + * + * @cvalue PANGO_TEXT_TRANSFORM_NONE + */ + case None = UNKNOWN; + + /** + * Display letters and numbers as lowercase. + * + * @cvalue PANGO_TEXT_TRANSFORM_LOWERCASE + */ + case Lowercase = UNKNOWN; + + /** + * Display letters and numbers as uppercase. + * + * @cvalue PANGO_TEXT_TRANSFORM_UPPERCASE + */ + case Uppercase = UNKNOWN; + + /** + * Display the first character of each word in titlecase. + * + * @cvalue PANGO_TEXT_TRANSFORM_CAPITALIZE + */ + case Capitalize = UNKNOWN; +} +#endif + +/** + * AttrList represents a list of attributes (PangoAttrList) that apply to a section of text. + * + * The attributes in a AttrList are of the type Attribute. The list is meant to be used with the + * Layout class. + */ +class AttrList +{ + /** + * Create a new empty attribute list. + */ + public function __construct() {} + + /** + * Insert the given attribute into the AttrList. + * + * It will be inserted after all other attributes with a matching startIndex. + * + * @param Attribute $attr The attribute to insert. + */ + public function insert(Attribute $attr): void {} + + /** + * Insert the given attribute into the AttrList. + * + * It will be inserted before all other attributes with a matching startIndex. + * + * @param Attribute $attr The attribute to insert. + */ + public function insertBefore(Attribute $attr): void {} + + /** + * Insert the given attribute into the AttrList. + * + * It will replace any attributes of the same type on that segment and be merged + * with any adjoining attributes that are identical. + * + * This function is slower than insert() for creating an attribute list in order + * (potentially much slower for large lists). However, insertBefore() and insert() + * don't perform the equivalent of this function. + * + * @param Attribute $attr The attribute to insert. + */ + public function change(Attribute $attr): void {} + + /** + * Gets a list of all attributes in the AttrList. + * + * @return Attribute[] An array of Attribute objects. + */ + public function getAttributes(): array {} + + /** + * Checks whether list and otherList contain the same attributes and whether + * those attributes apply to the same ranges. + * + * Beware that this will return wrong values if any list contains duplicates. + */ + public function equal(AttrList $otherList): bool {} + + /** + * Insert the given attributes in other into list. + * + * The two lists must have the same attributes. If not, the behavior is undefined. + * + * @param AttrList $other The AttrList to splice into this list. + * @param int $pos The position in this list at which to insert other. + * @param int $len The length of the spliced segment. This may be different from the + * length of other in most cases. + */ + public function splice(AttrList $other, int $pos, int $len): void {} + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 44, 0) + /** + * Update indices of attributes in this list for a change in the text they refer to. + * + * The change that this function applies is removing $remove characters starting at + * $pos and inserting $add characters instead. + * + * Attributes that fall entirely in the ($pos, $pos + $remove) range are removed. + * Attributes that start or end inside the ($pos, $pos + $remove) range are shortened + * to reflect the removal. Attributes start and end positions are updated if they are + * behind $pos + $remove. + * + * @param int $pos The start of the change. + * @param int $remove The number of removed characters. + * @param int $add The number of added characters. + */ + public function update(int $pos, int $remove, int $add): void {} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) + /** + * Serialize this list to a string. + * + * No guarantees are made about the format of the resulting string; it may change + * between Pango versions. + * + * The output format is the one that is used by fromString() and by the Pango text + * attribute language for attributes in Pango markup. + */ + public function toString(): string {} + + /** + * Deserialize an AttrList from a string. + * + * The format is the one that is used by toString() and the Pango text attribute + * language for attributes in Pango markup. + * + * @return AttrList|null The deserialized AttrList, or NULL if parsing failed. + */ + public static function fromString(string $text): null|AttrList {} +#endif +} From a427f7b69349c43655847ddb86019963de02b8f9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 13:46:53 +0000 Subject: [PATCH 03/13] Fix review comments in attribute.stub.php - Fix grammar: 'what the display' -> 'the display' - Fix spelling: 'expect' -> 'except' (word() docblock) - Fix doc: 'underlined' -> 'overlined' in Overline::Single case - Clarify splice() documentation to accurately describe behavior --- src/attribute.stub.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index aef0240..97416e2 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -487,7 +487,7 @@ public static function backgroundAlpha(int $alpha): AttrInt {} public static function allowBreaks(bool $allowBreaks): AttrInt {} /** - * Create a new attribute to control what the display of invisible characters. + * Create a new attribute to control the display of invisible characters. * * @param int $flags Bitwise OR of ShowFlags constants. */ @@ -542,7 +542,7 @@ public static function lineHeightAbsolute(int $height): AttrInt {} * Create a new attribute that marks its range as a single word. * * Note that this may conflict with line breaking rules, so you can't use this - * expect for specially controlled text. + * except for specially controlled text. */ public static function word(): AttrInt {} @@ -743,7 +743,7 @@ enum Overline: int case None = UNKNOWN; /** - * Draw a single overline above the ink extents of the text being underlined. + * Draw a single overline above the ink extents of the text being overlined. * * @cvalue PANGO_OVERLINE_SINGLE */ @@ -952,9 +952,11 @@ public function getAttributes(): array {} public function equal(AttrList $otherList): bool {} /** - * Insert the given attributes in other into list. + * Splice the given attributes from $other into this list. * - * The two lists must have the same attributes. If not, the behavior is undefined. + * The splice point is specified by $pos and $len. Attributes in $other are + * adjusted to apply to the new range. Attributes in this list that overlap + * the range [$pos, $pos + $len) are adjusted accordingly. * * @param AttrList $other The AttrList to splice into this list. * @param int $pos The position in this list at which to insert other. From d75667279bedc52c987a693be376d8b4c417131c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 14:09:16 +0000 Subject: [PATCH 04/13] Refactor Attribute static factories into concrete class constructors --- src/attribute.stub.php | 338 ++++++++--------------------------------- 1 file changed, 65 insertions(+), 273 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index 97416e2..48d50be 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -274,8 +274,8 @@ enum AttrType: int * Each attribute applies to a byte range in the text defined by * startIndex and endIndex. * - * Use the static factory methods (e.g., family(), style(), foreground()) - * to create specific attribute instances. + * Instantiate one of the concrete subclasses (e.g., AttrString, AttrInt, + * AttrColor) to create a specific attribute. */ abstract class Attribute { @@ -298,277 +298,6 @@ abstract class Attribute * Returns the type of this attribute. */ public function getAttrType(): AttrType {} - - /** - * Create a new language tag attribute. - * - * @param string $language A BCP 47 language tag string (e.g., "en", "de", "zh-cn"). - */ - public static function language(string $language): AttrString {} - - /** - * Create a new font-family attribute. - * - * @param string $family The font family name. - */ - public static function family(string $family): AttrString {} - - /** - * Create a new font-style attribute. - */ - public static function style(Style $style): AttrInt {} - - /** - * Create a new font-weight attribute. - */ - public static function weight(Weight $weight): AttrInt {} - - /** - * Create a new font-variant attribute. - */ - public static function variant(Variant $variant): AttrInt {} - - /** - * Create a new font-stretch attribute. - */ - public static function stretch(Stretch $stretch): AttrInt {} - - /** - * Create a new font-size attribute in Pango units. - * - * @param int $size The font size in Pango units (use Pango\Pango::SCALE * points). - */ - public static function size(int $size): AttrSize {} - - /** - * Create a new font-size attribute in device units. - * - * @param int $size The font size in Pango units (absolute, not scaled with the DPI). - */ - public static function sizeAbsolute(int $size): AttrSize {} - - /** - * Create a new font-description attribute. - * - * This attribute allows setting all font properties in one step using a - * FontDescription object. - */ - public static function fontDescription(FontDescription $desc): AttrFontDesc {} - - /** - * Create a new foreground color attribute. - * - * @param int $red Red component, range 0-65535. - * @param int $green Green component, range 0-65535. - * @param int $blue Blue component, range 0-65535. - */ - public static function foreground(int $red, int $green, int $blue): AttrColor {} - - /** - * Create a new background color attribute. - * - * @param int $red Red component, range 0-65535. - * @param int $green Green component, range 0-65535. - * @param int $blue Blue component, range 0-65535. - */ - public static function background(int $red, int $green, int $blue): AttrColor {} - - /** - * Create a new underline-style attribute. - */ - public static function underline(Underline $underline): AttrInt {} - - /** - * Create a new underline color attribute. - * - * This attribute modifies the color of underlines. If not set, underlines - * will use the foreground color. - * - * @param int $red Red component, range 0-65535. - * @param int $green Green component, range 0-65535. - * @param int $blue Blue component, range 0-65535. - */ - public static function underlineColor(int $red, int $green, int $blue): AttrColor {} - - /** - * Create a new strikethrough attribute. - * - * @param bool $strikethrough True if the text should be struck-through. - */ - public static function strikethrough(bool $strikethrough): AttrInt {} - - /** - * Create a new strikethrough color attribute. - * - * This attribute modifies the color of strikethroughs. If not set, - * strikethroughs will use the foreground color. - * - * @param int $red Red component, range 0-65535. - * @param int $green Green component, range 0-65535. - * @param int $blue Blue component, range 0-65535. - */ - public static function strikethroughColor(int $red, int $green, int $blue): AttrColor {} - - /** - * Create a new baseline displacement attribute. - * - * @param int $rise The amount that the text should be displaced vertically, in Pango - * units. Positive values displace the text upwards. - */ - public static function rise(int $rise): AttrInt {} - - /** - * Create a new font-scale-factor attribute. - * - * @param float $scaleFactor The factor to scale the font by relative to the base font. - */ - public static function scale(float $scaleFactor): AttrFloat {} - - /** - * 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. - * - * @param bool $enableFallback True to enable fallback, false to disable. - */ - public static function fallback(bool $enableFallback): AttrInt {} - - /** - * Create a new letter-spacing attribute. - * - * @param int $letterSpacing The amount of extra space to add between graphemes of the - * text, in Pango units. - */ - public static function letterSpacing(int $letterSpacing): AttrInt {} - - /** - * Create a new glyph-gravity attribute. - */ - public static function gravity(Gravity $gravity): AttrInt {} - - /** - * Create a new gravity-hint attribute. - */ - public static function gravityHint(GravityHint $hint): AttrInt {} - -#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 38, 0) - /** - * Create a new font-features attribute. - * - * @param string $features A string of font features in CSS syntax, e.g. "dlig=1". - */ - public static function fontFeatures(string $features): AttrString {} - - /** - * Create a new foreground-alpha attribute. - * - * @param int $alpha The alpha value, range 1-65536. - */ - public static function foregroundAlpha(int $alpha): AttrInt {} - - /** - * Create a new background-alpha attribute. - * - * @param int $alpha The alpha value, range 1-65536. - */ - public static function backgroundAlpha(int $alpha): AttrInt {} -#endif - -#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 44, 0) - /** - * Create a new allow-breaks attribute. - * - * If breaks are disabled, the range will be kept in a single run as far as possible. - * - * @param bool $allowBreaks True if line breaks are allowed. - */ - public static function allowBreaks(bool $allowBreaks): AttrInt {} - - /** - * Create a new attribute to control the display of invisible characters. - * - * @param int $flags Bitwise OR of ShowFlags constants. - */ - public static function show(int $flags): AttrInt {} - - /** - * 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. - * - * @param bool $insertHyphens True if hyphens should be inserted. - */ - public static function insertHyphens(bool $insertHyphens): AttrInt {} -#endif - -#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 46, 0) - /** - * Create a new overline-style attribute. - */ - public static function overline(Overline $overline): AttrInt {} - - /** - * Create a new overline-color attribute. - * - * This attribute modifies the color of overlines. If not set, overlines - * will use the foreground color. - * - * @param int $red Red component, range 0-65535. - * @param int $green Green component, range 0-65535. - * @param int $blue Blue component, range 0-65535. - */ - public static function overlineColor(int $red, int $green, int $blue): AttrColor {} -#endif - -#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) - /** - * Create a new line-height attribute that changes line spacing by a factor. - * - * @param float $factor The factor to scale the line height by. - */ - public static function lineHeight(float $factor): AttrFloat {} - - /** - * Create a new line-height attribute with an absolute line height in Pango units. - * - * @param int $height The line height in Pango units. - */ - public static function lineHeightAbsolute(int $height): AttrInt {} - - /** - * Create a new attribute that marks its range as a single word. - * - * Note that this may conflict with line breaking rules, so you can't use this - * except for specially controlled text. - */ - public static function word(): AttrInt {} - - /** - * Create a new attribute that marks its range as a single sentence. - * - * Note that this may conflict with line breaking rules, so you can't use this - * except for specially controlled text. - */ - public static function sentence(): AttrInt {} - - /** - * Create a new baseline-shift attribute. - */ - public static function baselineShift(BaselineShift $shift): AttrInt {} - - /** - * Create a new font-scale attribute. - */ - public static function fontScale(FontScale $scale): AttrInt {} - - /** - * Create a new text-transform attribute. - */ - public static function textTransform(TextTransform $transform): AttrInt {} -#endif } /** @@ -583,6 +312,16 @@ final class AttrString extends Attribute * The string value of the attribute. */ public string $value; + + /** + * Create a new string attribute. + * + * @param AttrType $type The attribute type. Must be one of: + * AttrType::Language, AttrType::Family, + * or (>= 1.38) AttrType::FontFeatures. + * @param string $value The string value. + */ + public function __construct(AttrType $type, string $value) {} } /** @@ -596,6 +335,16 @@ final class AttrInt extends Attribute * The integer value of the attribute. */ public int $value; + + /** + * Create a new integer attribute. + * + * @param AttrType $type The attribute type. Must be one of the integer-valued + * attribute types (e.g. AttrType::Style, AttrType::Weight, + * AttrType::Underline, AttrType::Rise, etc.). + * @param int $value The integer value. + */ + public function __construct(AttrType $type, int $value) {} } /** @@ -609,6 +358,15 @@ final class AttrFloat extends Attribute * The float value of the attribute. */ public float $value; + + /** + * Create a new float attribute. + * + * @param AttrType $type The attribute type. Must be one of: + * AttrType::Scale, or (>= 1.50) AttrType::LineHeight. + * @param float $value The float value. + */ + public function __construct(AttrType $type, float $value) {} } /** @@ -624,6 +382,19 @@ final class AttrColor extends Attribute * The color value of the attribute. */ public Color $color; + + /** + * Create a new color attribute. + * + * @param AttrType $type The attribute type. Must be one of: + * AttrType::Foreground, AttrType::Background, + * AttrType::UnderlineColor, AttrType::StrikethroughColor, + * or (>= 1.46) AttrType::OverlineColor. + * @param int $red Red component, range 0-65535. + * @param int $green Green component, range 0-65535. + * @param int $blue Blue component, range 0-65535. + */ + public function __construct(AttrType $type, int $red, int $green, int $blue) {} } /** @@ -642,6 +413,17 @@ final class AttrSize extends Attribute * Whether this is an absolute size (device units) rather than a scaled size. */ public bool $absolute; + + /** + * Create a new font-size attribute. + * + * @param int $value The font size in Pango units. + * @param bool $absolute Whether to use absolute (device) units. + * If false, the size is scaled relative to the font's normal size + * (PANGO_ATTR_SIZE). If true, the size is in device units + * (PANGO_ATTR_ABSOLUTE_SIZE). + */ + public function __construct(int $value, bool $absolute = false) {} } /** @@ -655,6 +437,16 @@ final class AttrFontDesc extends Attribute * The font description. */ public FontDescription $desc; + + /** + * Create a new font-description attribute. + * + * This attribute allows setting all font properties in one step using a + * FontDescription object. + * + * @param FontDescription $desc The font description. + */ + public function __construct(FontDescription $desc) {} } /** From 451ebfc7183b79215c7d60e62f7531741ddf7dd8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 14:18:02 +0000 Subject: [PATCH 05/13] Move attribute classes into Pango\Attributes namespace, drop Attr abbreviations --- src/attribute.stub.php | 596 +++++++++++++++++++++-------------------- 1 file changed, 301 insertions(+), 295 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index 48d50be..789b5d8 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -5,7 +5,7 @@ * @generate-legacy-arginfo 80100 */ -namespace Pango; +namespace Pango { /** * Color represents a color in 16-bit RGB format. @@ -64,9 +64,247 @@ public function toString(): string {} } /** - * AttrType distinguishes between different types of Pango text attributes. + * Underline describes the type of underline used for decorating text. + */ +enum Underline: int +{ + /** + * No underline should be drawn. + * + * @cvalue PANGO_UNDERLINE_NONE + */ + case None = UNKNOWN; + + /** + * A single underline should be drawn. + * + * @cvalue PANGO_UNDERLINE_SINGLE + */ + case Single = UNKNOWN; + + /** + * A double underline should be drawn. + * + * @cvalue PANGO_UNDERLINE_DOUBLE + */ + case Double = UNKNOWN; + + /** + * A single underline should be drawn at a position beneath the ink extents + * of the text being underlined. + * + * This should be used only for underlining single characters, such as for + * keyboard accelerators. Pango::UNDERLINE_SINGLE should be used for extended + * portions of text. + * + * @cvalue PANGO_UNDERLINE_LOW + */ + case Low = UNKNOWN; + + /** + * An underline indicating an error should be drawn below. + * + * The exact style of rendering is platform-dependent but it typically looks + * like a wavy line. It is designed to indicate a misspelling. + * + * @cvalue PANGO_UNDERLINE_ERROR + */ + case Error = UNKNOWN; + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) + /** + * Like Single, but drawn continuously across multiple runs. + * + * @cvalue PANGO_UNDERLINE_SINGLE_LINE + */ + case SingleLine = UNKNOWN; + + /** + * Like Double, but drawn continuously across multiple runs. + * + * @cvalue PANGO_UNDERLINE_DOUBLE_LINE + */ + case DoubleLine = UNKNOWN; + + /** + * Like Error, but drawn continuously across multiple runs. + * + * @cvalue PANGO_UNDERLINE_ERROR_LINE + */ + case ErrorLine = UNKNOWN; +#endif +} + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 46, 0) +/** + * Overline describes the type of overline used for decorating text. + */ +enum Overline: int +{ + /** + * No overline should be drawn. + * + * @cvalue PANGO_OVERLINE_NONE + */ + case None = UNKNOWN; + + /** + * Draw a single overline above the ink extents of the text being overlined. + * + * @cvalue PANGO_OVERLINE_SINGLE + */ + case Single = UNKNOWN; +} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 44, 0) +/** + * ShowFlags affects how Pango renders characters that are usually invisible in the output. + * + * This class is not instantiable. + */ +abstract class ShowFlags +{ + /** + * No special treatment for invisible characters. + * + * @var int + * @cvalue PANGO_SHOW_NONE + */ + public const NONE = UNKNOWN; + + /** + * Render spaces, tabs and newlines visibly. + * + * @var int + * @cvalue PANGO_SHOW_SPACES + */ + public const SPACES = UNKNOWN; + + /** + * Render line breaks visibly. + * + * @var int + * @cvalue PANGO_SHOW_LINE_BREAKS + */ + public const LINE_BREAKS = UNKNOWN; + + /** + * Render default-ignorable Unicode characters visibly. + * + * @var int + * @cvalue PANGO_SHOW_IGNORABLES + */ + public const IGNORABLES = UNKNOWN; +} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) +/** + * BaselineShift describes how the baseline of the text should be shifted. + */ +enum BaselineShift: int +{ + /** + * Leave the baseline in place. + * + * @cvalue PANGO_BASELINE_SHIFT_NONE + */ + case None = UNKNOWN; + + /** + * Shift the baseline to the superscript position, relative to the default baseline. + * + * @cvalue PANGO_BASELINE_SHIFT_SUPERSCRIPT + */ + case Superscript = UNKNOWN; + + /** + * Shift the baseline to the subscript position, relative to the default baseline. + * + * @cvalue PANGO_BASELINE_SHIFT_SUBSCRIPT + */ + case Subscript = UNKNOWN; +} + +/** + * FontScale describes how the scale of the font should be changed relative to the inherited + * font size. + */ +enum FontScale: int +{ + /** + * Leave the font size unchanged. + * + * @cvalue PANGO_FONT_SCALE_NONE + */ + case None = UNKNOWN; + + /** + * Change the font to the size used for superscripts. + * + * @cvalue PANGO_FONT_SCALE_SUPERSCRIPT + */ + case Superscript = UNKNOWN; + + /** + * Change the font to the size used for subscripts. + * + * @cvalue PANGO_FONT_SCALE_SUBSCRIPT + */ + case Subscript = UNKNOWN; + + /** + * Change the font to the size used for Small Caps. + * + * @cvalue PANGO_FONT_SCALE_SMALL_CAPS + */ + case SmallCaps = UNKNOWN; +} + +/** + * TextTransform describes how text should be transformed during rendering. + */ +enum TextTransform: int +{ + /** + * No transformation. + * + * @cvalue PANGO_TEXT_TRANSFORM_NONE + */ + case None = UNKNOWN; + + /** + * Display letters and numbers as lowercase. + * + * @cvalue PANGO_TEXT_TRANSFORM_LOWERCASE + */ + case Lowercase = UNKNOWN; + + /** + * Display letters and numbers as uppercase. + * + * @cvalue PANGO_TEXT_TRANSFORM_UPPERCASE + */ + case Uppercase = UNKNOWN; + + /** + * Display the first character of each word in titlecase. + * + * @cvalue PANGO_TEXT_TRANSFORM_CAPITALIZE + */ + case Capitalize = UNKNOWN; +} +#endif + +} // namespace Pango + +namespace Pango\Attributes { + +/** + * Type distinguishes between different types of Pango text attributes. */ -enum AttrType: int +enum Type: int { /** * @cvalue PANGO_ATTR_INVALID @@ -274,8 +512,8 @@ enum AttrType: int * Each attribute applies to a byte range in the text defined by * startIndex and endIndex. * - * Instantiate one of the concrete subclasses (e.g., AttrString, AttrInt, - * AttrColor) to create a specific attribute. + * Instantiate one of the concrete subclasses (e.g., StringAttribute, IntAttribute, + * ColorAttribute) to create a specific attribute. */ abstract class Attribute { @@ -297,16 +535,16 @@ abstract class Attribute /** * Returns the type of this attribute. */ - public function getAttrType(): AttrType {} + public function getType(): Type {} } /** - * AttrString is an Attribute that holds a string value. + * StringAttribute is an Attribute that holds a string value. * - * It is used for: AttrType::Family, AttrType::Language, - * and (>= 1.38) AttrType::FontFeatures. + * It is used for: Type::Family, Type::Language, + * and (>= 1.38) Type::FontFeatures. */ -final class AttrString extends Attribute +final class StringAttribute extends Attribute { /** * The string value of the attribute. @@ -316,20 +554,20 @@ final class AttrString extends Attribute /** * Create a new string attribute. * - * @param AttrType $type The attribute type. Must be one of: - * AttrType::Language, AttrType::Family, - * or (>= 1.38) AttrType::FontFeatures. + * @param Type $type The attribute type. Must be one of: + * Type::Language, Type::Family, + * or (>= 1.38) Type::FontFeatures. * @param string $value The string value. */ - public function __construct(AttrType $type, string $value) {} + public function __construct(Type $type, string $value) {} } /** - * AttrInt is an Attribute that holds an integer value. + * IntAttribute is an Attribute that holds an integer value. * * It is used for many attribute types including style, weight, underline, rise, etc. */ -final class AttrInt extends Attribute +final class IntAttribute extends Attribute { /** * The integer value of the attribute. @@ -339,20 +577,20 @@ final class AttrInt extends Attribute /** * Create a new integer attribute. * - * @param AttrType $type The attribute type. Must be one of the integer-valued - * attribute types (e.g. AttrType::Style, AttrType::Weight, - * AttrType::Underline, AttrType::Rise, etc.). + * @param Type $type The attribute type. Must be one of the integer-valued + * attribute types (e.g. Type::Style, Type::Weight, + * Type::Underline, Type::Rise, etc.). * @param int $value The integer value. */ - public function __construct(AttrType $type, int $value) {} + public function __construct(Type $type, int $value) {} } /** - * AttrFloat is an Attribute that holds a floating-point value. + * FloatAttribute is an Attribute that holds a floating-point value. * - * It is used for: AttrType::Scale, and (>= 1.50) AttrType::LineHeight. + * It is used for: Type::Scale, and (>= 1.50) Type::LineHeight. */ -final class AttrFloat extends Attribute +final class FloatAttribute extends Attribute { /** * The float value of the attribute. @@ -362,47 +600,47 @@ final class AttrFloat extends Attribute /** * Create a new float attribute. * - * @param AttrType $type The attribute type. Must be one of: - * AttrType::Scale, or (>= 1.50) AttrType::LineHeight. + * @param Type $type The attribute type. Must be one of: + * Type::Scale, or (>= 1.50) Type::LineHeight. * @param float $value The float value. */ - public function __construct(AttrType $type, float $value) {} + public function __construct(Type $type, float $value) {} } /** - * AttrColor is an Attribute that holds a Color value. + * ColorAttribute is an Attribute that holds a Color value. * - * It is used for: AttrType::Foreground, AttrType::Background, - * AttrType::UnderlineColor, AttrType::StrikethroughColor, - * and (>= 1.46) AttrType::OverlineColor. + * It is used for: Type::Foreground, Type::Background, + * Type::UnderlineColor, Type::StrikethroughColor, + * and (>= 1.46) Type::OverlineColor. */ -final class AttrColor extends Attribute +final class ColorAttribute extends Attribute { /** * The color value of the attribute. */ - public Color $color; + public \Pango\Color $color; /** * Create a new color attribute. * - * @param AttrType $type The attribute type. Must be one of: - * AttrType::Foreground, AttrType::Background, - * AttrType::UnderlineColor, AttrType::StrikethroughColor, - * or (>= 1.46) AttrType::OverlineColor. + * @param Type $type The attribute type. Must be one of: + * Type::Foreground, Type::Background, + * Type::UnderlineColor, Type::StrikethroughColor, + * or (>= 1.46) Type::OverlineColor. * @param int $red Red component, range 0-65535. * @param int $green Green component, range 0-65535. * @param int $blue Blue component, range 0-65535. */ - public function __construct(AttrType $type, int $red, int $green, int $blue) {} + public function __construct(Type $type, int $red, int $green, int $blue) {} } /** - * AttrSize is an Attribute that holds a font size. + * SizeAttribute is an Attribute that holds a font size. * - * It is used for: AttrType::Size and AttrType::AbsoluteSize. + * It is used for: Type::Size and Type::AbsoluteSize. */ -final class AttrSize extends Attribute +final class SizeAttribute extends Attribute { /** * The font size in Pango units. @@ -427,16 +665,16 @@ public function __construct(int $value, bool $absolute = false) {} } /** - * AttrFontDesc is an Attribute that holds a FontDescription. + * FontDescriptionAttribute is an Attribute that holds a FontDescription. * - * It is used for: AttrType::FontDesc. + * It is used for: Type::FontDesc. */ -final class AttrFontDesc extends Attribute +final class FontDescriptionAttribute extends Attribute { /** * The font description. */ - public FontDescription $desc; + public \Pango\FontDescription $desc; /** * Create a new font-description attribute. @@ -444,252 +682,18 @@ final class AttrFontDesc extends Attribute * This attribute allows setting all font properties in one step using a * FontDescription object. * - * @param FontDescription $desc The font description. + * @param \Pango\FontDescription $desc The font description. */ - public function __construct(FontDescription $desc) {} + public function __construct(\Pango\FontDescription $desc) {} } /** - * Underline describes the type of underline used for decorating text. - */ -enum Underline: int -{ - /** - * No underline should be drawn. - * - * @cvalue PANGO_UNDERLINE_NONE - */ - case None = UNKNOWN; - - /** - * A single underline should be drawn. - * - * @cvalue PANGO_UNDERLINE_SINGLE - */ - case Single = UNKNOWN; - - /** - * A double underline should be drawn. - * - * @cvalue PANGO_UNDERLINE_DOUBLE - */ - case Double = UNKNOWN; - - /** - * A single underline should be drawn at a position beneath the ink extents - * of the text being underlined. - * - * This should be used only for underlining single characters, such as for - * keyboard accelerators. Pango::UNDERLINE_SINGLE should be used for extended - * portions of text. - * - * @cvalue PANGO_UNDERLINE_LOW - */ - case Low = UNKNOWN; - - /** - * An underline indicating an error should be drawn below. - * - * The exact style of rendering is platform-dependent but it typically looks - * like a wavy line. It is designed to indicate a misspelling. - * - * @cvalue PANGO_UNDERLINE_ERROR - */ - case Error = UNKNOWN; - -#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) - /** - * Like Single, but drawn continuously across multiple runs. - * - * @cvalue PANGO_UNDERLINE_SINGLE_LINE - */ - case SingleLine = UNKNOWN; - - /** - * Like Double, but drawn continuously across multiple runs. - * - * @cvalue PANGO_UNDERLINE_DOUBLE_LINE - */ - case DoubleLine = UNKNOWN; - - /** - * Like Error, but drawn continuously across multiple runs. - * - * @cvalue PANGO_UNDERLINE_ERROR_LINE - */ - case ErrorLine = UNKNOWN; -#endif -} - -#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 46, 0) -/** - * Overline describes the type of overline used for decorating text. - */ -enum Overline: int -{ - /** - * No overline should be drawn. - * - * @cvalue PANGO_OVERLINE_NONE - */ - case None = UNKNOWN; - - /** - * Draw a single overline above the ink extents of the text being overlined. - * - * @cvalue PANGO_OVERLINE_SINGLE - */ - case Single = UNKNOWN; -} -#endif - -#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 44, 0) -/** - * ShowFlags affects how Pango renders characters that are usually invisible in the output. + * AttributeList represents a list of attributes (PangoAttrList) that apply to a section of text. * - * This class is not instantiable. + * The attributes in an AttributeList are of the type Attribute. The list is meant to be used + * with the Layout class. */ -abstract class ShowFlags -{ - /** - * No special treatment for invisible characters. - * - * @var int - * @cvalue PANGO_SHOW_NONE - */ - public const NONE = UNKNOWN; - - /** - * Render spaces, tabs and newlines visibly. - * - * @var int - * @cvalue PANGO_SHOW_SPACES - */ - public const SPACES = UNKNOWN; - - /** - * Render line breaks visibly. - * - * @var int - * @cvalue PANGO_SHOW_LINE_BREAKS - */ - public const LINE_BREAKS = UNKNOWN; - - /** - * Render default-ignorable Unicode characters visibly. - * - * @var int - * @cvalue PANGO_SHOW_IGNORABLES - */ - public const IGNORABLES = UNKNOWN; -} -#endif - -#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) -/** - * BaselineShift describes how the baseline of the text should be shifted. - */ -enum BaselineShift: int -{ - /** - * Leave the baseline in place. - * - * @cvalue PANGO_BASELINE_SHIFT_NONE - */ - case None = UNKNOWN; - - /** - * Shift the baseline to the superscript position, relative to the default baseline. - * - * @cvalue PANGO_BASELINE_SHIFT_SUPERSCRIPT - */ - case Superscript = UNKNOWN; - - /** - * Shift the baseline to the subscript position, relative to the default baseline. - * - * @cvalue PANGO_BASELINE_SHIFT_SUBSCRIPT - */ - case Subscript = UNKNOWN; -} - -/** - * FontScale describes how the scale of the font should be changed relative to the inherited - * font size. - */ -enum FontScale: int -{ - /** - * Leave the font size unchanged. - * - * @cvalue PANGO_FONT_SCALE_NONE - */ - case None = UNKNOWN; - - /** - * Change the font to the size used for superscripts. - * - * @cvalue PANGO_FONT_SCALE_SUPERSCRIPT - */ - case Superscript = UNKNOWN; - - /** - * Change the font to the size used for subscripts. - * - * @cvalue PANGO_FONT_SCALE_SUBSCRIPT - */ - case Subscript = UNKNOWN; - - /** - * Change the font to the size used for Small Caps. - * - * @cvalue PANGO_FONT_SCALE_SMALL_CAPS - */ - case SmallCaps = UNKNOWN; -} - -/** - * TextTransform describes how text should be transformed during rendering. - */ -enum TextTransform: int -{ - /** - * No transformation. - * - * @cvalue PANGO_TEXT_TRANSFORM_NONE - */ - case None = UNKNOWN; - - /** - * Display letters and numbers as lowercase. - * - * @cvalue PANGO_TEXT_TRANSFORM_LOWERCASE - */ - case Lowercase = UNKNOWN; - - /** - * Display letters and numbers as uppercase. - * - * @cvalue PANGO_TEXT_TRANSFORM_UPPERCASE - */ - case Uppercase = UNKNOWN; - - /** - * Display the first character of each word in titlecase. - * - * @cvalue PANGO_TEXT_TRANSFORM_CAPITALIZE - */ - case Capitalize = UNKNOWN; -} -#endif - -/** - * AttrList represents a list of attributes (PangoAttrList) that apply to a section of text. - * - * The attributes in a AttrList are of the type Attribute. The list is meant to be used with the - * Layout class. - */ -class AttrList +class AttributeList { /** * Create a new empty attribute list. @@ -697,7 +701,7 @@ class AttrList public function __construct() {} /** - * Insert the given attribute into the AttrList. + * Insert the given attribute into the AttributeList. * * It will be inserted after all other attributes with a matching startIndex. * @@ -706,7 +710,7 @@ public function __construct() {} public function insert(Attribute $attr): void {} /** - * Insert the given attribute into the AttrList. + * Insert the given attribute into the AttributeList. * * It will be inserted before all other attributes with a matching startIndex. * @@ -715,7 +719,7 @@ public function insert(Attribute $attr): void {} public function insertBefore(Attribute $attr): void {} /** - * Insert the given attribute into the AttrList. + * Insert the given attribute into the AttributeList. * * It will replace any attributes of the same type on that segment and be merged * with any adjoining attributes that are identical. @@ -729,19 +733,19 @@ public function insertBefore(Attribute $attr): void {} public function change(Attribute $attr): void {} /** - * Gets a list of all attributes in the AttrList. + * Gets a list of all attributes in the AttributeList. * * @return Attribute[] An array of Attribute objects. */ public function getAttributes(): array {} /** - * Checks whether list and otherList contain the same attributes and whether + * Checks whether this list and $other contain the same attributes and whether * those attributes apply to the same ranges. * * Beware that this will return wrong values if any list contains duplicates. */ - public function equal(AttrList $otherList): bool {} + public function equal(AttributeList $other): bool {} /** * Splice the given attributes from $other into this list. @@ -750,12 +754,12 @@ public function equal(AttrList $otherList): bool {} * adjusted to apply to the new range. Attributes in this list that overlap * the range [$pos, $pos + $len) are adjusted accordingly. * - * @param AttrList $other The AttrList to splice into this list. + * @param AttributeList $other The AttributeList to splice into this list. * @param int $pos The position in this list at which to insert other. * @param int $len The length of the spliced segment. This may be different from the * length of other in most cases. */ - public function splice(AttrList $other, int $pos, int $len): void {} + public function splice(AttributeList $other, int $pos, int $len): void {} #if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 44, 0) /** @@ -789,13 +793,15 @@ public function update(int $pos, int $remove, int $add): void {} public function toString(): string {} /** - * Deserialize an AttrList from a string. + * Deserialize an AttributeList from a string. * * The format is the one that is used by toString() and the Pango text attribute * language for attributes in Pango markup. * - * @return AttrList|null The deserialized AttrList, or NULL if parsing failed. + * @return AttributeList|null The deserialized AttributeList, or NULL if parsing failed. */ - public static function fromString(string $text): null|AttrList {} + public static function fromString(string $text): null|AttributeList {} #endif } + +} // namespace Pango\Attributes From 2556c999653948a0f45a0b78a1bc516adc1b0e1e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 14:32:44 +0000 Subject: [PATCH 06/13] Remove Attribute suffix from class names in Pango\Attributes namespace where possible Renamed: - ColorAttribute -> Color - SizeAttribute -> Size - FontDescriptionAttribute -> FontDescription StringAttribute, IntAttribute, and FloatAttribute cannot be renamed as String, Int, and Float are reserved PHP type names. --- src/attribute.stub.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index 789b5d8..b99863d 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -513,7 +513,7 @@ enum Type: int * startIndex and endIndex. * * Instantiate one of the concrete subclasses (e.g., StringAttribute, IntAttribute, - * ColorAttribute) to create a specific attribute. + * Color) to create a specific attribute. */ abstract class Attribute { @@ -608,13 +608,13 @@ public function __construct(Type $type, float $value) {} } /** - * ColorAttribute is an Attribute that holds a Color value. + * Color is an Attribute that holds a Color value. * * It is used for: Type::Foreground, Type::Background, * Type::UnderlineColor, Type::StrikethroughColor, * and (>= 1.46) Type::OverlineColor. */ -final class ColorAttribute extends Attribute +final class Color extends Attribute { /** * The color value of the attribute. @@ -636,11 +636,11 @@ public function __construct(Type $type, int $red, int $green, int $blue) {} } /** - * SizeAttribute is an Attribute that holds a font size. + * Size is an Attribute that holds a font size. * * It is used for: Type::Size and Type::AbsoluteSize. */ -final class SizeAttribute extends Attribute +final class Size extends Attribute { /** * The font size in Pango units. @@ -665,11 +665,11 @@ public function __construct(int $value, bool $absolute = false) {} } /** - * FontDescriptionAttribute is an Attribute that holds a FontDescription. + * FontDescription is an Attribute that holds a FontDescription. * * It is used for: Type::FontDesc. */ -final class FontDescriptionAttribute extends Attribute +final class FontDescription extends Attribute { /** * The font description. From be41d2e126c9405f69f7807bdd7202bbadea98fd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:28:35 +0000 Subject: [PATCH 07/13] Replace generic attribute classes with concrete per-type attribute classes Remove StringAttribute, IntAttribute, FloatAttribute, Color, Size, and FontDescription generic classes. Add one concrete class per Type enum case: Language, Family, Style, Weight, Variant, Stretch, Size, AbsoluteSize, FontDesc, Foreground, Background, Underline, Strikethrough, Rise, Shape, Scale, Fallback, LetterSpacing, UnderlineColor, StrikethroughColor, Gravity, GravityHint, FontFeatures, ForegroundAlpha, BackgroundAlpha, AllowBreaks, Show, InsertHyphens, Overline, OverlineColor, LineHeight, AbsoluteLineHeight, TextTransform, Word, Sentence, BaselineShift, FontScale. --- src/attribute.stub.php | 722 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 658 insertions(+), 64 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index b99863d..dd4a90b 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -512,8 +512,8 @@ enum Type: int * Each attribute applies to a byte range in the text defined by * startIndex and endIndex. * - * Instantiate one of the concrete subclasses (e.g., StringAttribute, IntAttribute, - * Color) to create a specific attribute. + * Instantiate one of the concrete subclasses (e.g., Language, Style, + * Foreground) to create a specific attribute. */ abstract class Attribute { @@ -539,137 +539,171 @@ public function getType(): Type {} } /** - * StringAttribute is an Attribute that holds a string value. + * Language is an Attribute that holds a language tag. * - * It is used for: Type::Family, Type::Language, - * and (>= 1.38) Type::FontFeatures. + * It is used for: Type::Language. */ -final class StringAttribute extends Attribute +final class Language extends Attribute { /** - * The string value of the attribute. + * The language tag (e.g., "en", "fr"). */ public string $value; /** - * Create a new string attribute. + * Create a new language attribute. * - * @param Type $type The attribute type. Must be one of: - * Type::Language, Type::Family, - * or (>= 1.38) Type::FontFeatures. - * @param string $value The string value. + * @param string $value The language tag. */ - public function __construct(Type $type, string $value) {} + public function __construct(string $value) {} } /** - * IntAttribute is an Attribute that holds an integer value. + * Family is an Attribute that holds a font family name. * - * It is used for many attribute types including style, weight, underline, rise, etc. + * It is used for: Type::Family. */ -final class IntAttribute extends Attribute +final class Family extends Attribute { /** - * The integer value of the attribute. + * The font family name. + */ + public string $value; + + /** + * Create a new font family attribute. + * + * @param string $value The font family name. + */ + public function __construct(string $value) {} +} + +/** + * Style is an Attribute that holds a font style value. + * + * It is used for: Type::Style. + */ +final class Style extends Attribute +{ + /** + * The font style value (e.g., PANGO_STYLE_NORMAL, PANGO_STYLE_ITALIC). */ public int $value; /** - * Create a new integer attribute. + * Create a new font style attribute. * - * @param Type $type The attribute type. Must be one of the integer-valued - * attribute types (e.g. Type::Style, Type::Weight, - * Type::Underline, Type::Rise, etc.). - * @param int $value The integer value. + * @param int $value The font style value. */ - public function __construct(Type $type, int $value) {} + public function __construct(int $value) {} } /** - * FloatAttribute is an Attribute that holds a floating-point value. + * Weight is an Attribute that holds a font weight value. * - * It is used for: Type::Scale, and (>= 1.50) Type::LineHeight. + * It is used for: Type::Weight. */ -final class FloatAttribute extends Attribute +final class Weight extends Attribute { /** - * The float value of the attribute. + * The font weight value (e.g., PANGO_WEIGHT_NORMAL, PANGO_WEIGHT_BOLD). */ - public float $value; + public int $value; /** - * Create a new float attribute. + * Create a new font weight attribute. * - * @param Type $type The attribute type. Must be one of: - * Type::Scale, or (>= 1.50) Type::LineHeight. - * @param float $value The float value. + * @param int $value The font weight value. */ - public function __construct(Type $type, float $value) {} + public function __construct(int $value) {} } /** - * Color is an Attribute that holds a Color value. + * Variant is an Attribute that holds a font variant value. * - * It is used for: Type::Foreground, Type::Background, - * Type::UnderlineColor, Type::StrikethroughColor, - * and (>= 1.46) Type::OverlineColor. + * It is used for: Type::Variant. */ -final class Color extends Attribute +final class Variant extends Attribute { /** - * The color value of the attribute. + * The font variant value (e.g., PANGO_VARIANT_NORMAL, PANGO_VARIANT_SMALL_CAPS). */ - public \Pango\Color $color; + public int $value; /** - * Create a new color attribute. + * Create a new font variant attribute. * - * @param Type $type The attribute type. Must be one of: - * Type::Foreground, Type::Background, - * Type::UnderlineColor, Type::StrikethroughColor, - * or (>= 1.46) Type::OverlineColor. - * @param int $red Red component, range 0-65535. - * @param int $green Green component, range 0-65535. - * @param int $blue Blue component, range 0-65535. + * @param int $value The font variant value. */ - public function __construct(Type $type, int $red, int $green, int $blue) {} + public function __construct(int $value) {} } /** - * Size is an Attribute that holds a font size. + * Stretch is an Attribute that holds a font stretch value. * - * It is used for: Type::Size and Type::AbsoluteSize. + * It is used for: Type::Stretch. */ -final class Size extends Attribute +final class Stretch extends Attribute { /** - * The font size in Pango units. + * The font stretch value (e.g., PANGO_STRETCH_NORMAL, PANGO_STRETCH_CONDENSED). */ public int $value; /** - * Whether this is an absolute size (device units) rather than a scaled size. + * Create a new font stretch attribute. + * + * @param int $value The font stretch value. + */ + public function __construct(int $value) {} +} + +/** + * Size is an Attribute that holds a font size in Pango units. + * + * It is used for: Type::Size. + */ +final class Size extends Attribute +{ + /** + * The font size in Pango units (1/PANGO_SCALE points). */ - public bool $absolute; + public int $value; /** - * Create a new font-size attribute. + * Create a new font size attribute. * * @param int $value The font size in Pango units. - * @param bool $absolute Whether to use absolute (device) units. - * If false, the size is scaled relative to the font's normal size - * (PANGO_ATTR_SIZE). If true, the size is in device units - * (PANGO_ATTR_ABSOLUTE_SIZE). */ - public function __construct(int $value, bool $absolute = false) {} + public function __construct(int $value) {} +} + +/** + * AbsoluteSize is an Attribute that holds a font size in device units. + * + * It is used for: Type::AbsoluteSize. + */ +final class AbsoluteSize extends Attribute +{ + /** + * The font size in device units (1/PANGO_SCALE pixels). + */ + public int $value; + + /** + * Create a new absolute font size attribute. + * + * @param int $value The font size in device units. + */ + public function __construct(int $value) {} } /** - * FontDescription is an Attribute that holds a FontDescription. + * FontDesc is an Attribute that holds a font description. * * It is used for: Type::FontDesc. */ -final class FontDescription extends Attribute +final class FontDesc extends Attribute { /** * The font description. @@ -677,7 +711,7 @@ final class FontDescription extends Attribute public \Pango\FontDescription $desc; /** - * Create a new font-description attribute. + * Create a new font description attribute. * * This attribute allows setting all font properties in one step using a * FontDescription object. @@ -687,6 +721,566 @@ final class FontDescription extends Attribute public function __construct(\Pango\FontDescription $desc) {} } +/** + * Foreground is an Attribute that holds the foreground color. + * + * It is used for: Type::Foreground. + */ +final class Foreground extends Attribute +{ + /** + * The foreground color. + */ + public \Pango\Color $color; + + /** + * Create a new foreground color attribute. + * + * @param \Pango\Color $color The foreground color. + */ + public function __construct(\Pango\Color $color) {} +} + +/** + * Background is an Attribute that holds the background color. + * + * It is used for: Type::Background. + */ +final class Background extends Attribute +{ + /** + * The background color. + */ + public \Pango\Color $color; + + /** + * Create a new background color attribute. + * + * @param \Pango\Color $color The background color. + */ + public function __construct(\Pango\Color $color) {} +} + +/** + * Underline is an Attribute that holds an underline style. + * + * It is used for: Type::Underline. + */ +final class Underline extends Attribute +{ + /** + * The underline style value (e.g., PANGO_UNDERLINE_SINGLE). + */ + public int $value; + + /** + * Create a new underline attribute. + * + * @param int $value The underline style value. + */ + public function __construct(int $value) {} +} + +/** + * Strikethrough is an Attribute that holds a strikethrough flag. + * + * It is used for: Type::Strikethrough. + */ +final class Strikethrough extends Attribute +{ + /** + * Whether strikethrough is enabled. + */ + public int $value; + + /** + * Create a new strikethrough attribute. + * + * @param int $value Non-zero to enable strikethrough. + */ + public function __construct(int $value) {} +} + +/** + * Rise is an Attribute that holds a baseline shift in Pango units. + * + * It is used for: Type::Rise. + */ +final class Rise extends Attribute +{ + /** + * The rise value in Pango units. Positive values shift the baseline up. + */ + public int $value; + + /** + * Create a new rise attribute. + * + * @param int $value The rise value in Pango units. + */ + public function __construct(int $value) {} +} + +/** + * Shape is an Attribute that holds ink and logical rectangles for a custom glyph shape. + * + * It is used for: Type::Shape. + */ +final class Shape extends Attribute +{ + /** + * The ink rectangle of the glyph. + */ + public \Pango\Rectangle $inkRect; + + /** + * The logical rectangle of the glyph. + */ + public \Pango\Rectangle $logicalRect; + + /** + * Create a new shape attribute. + * + * @param \Pango\Rectangle $inkRect The ink rectangle. + * @param \Pango\Rectangle $logicalRect The logical rectangle. + */ + public function __construct(\Pango\Rectangle $inkRect, \Pango\Rectangle $logicalRect) {} +} + +/** + * Scale is an Attribute that holds a font scale factor. + * + * It is used for: Type::Scale. + */ +final class Scale extends Attribute +{ + /** + * The scale factor. + */ + public float $value; + + /** + * Create a new scale attribute. + * + * @param float $value The scale factor. + */ + public function __construct(float $value) {} +} + +/** + * Fallback is an Attribute that holds a fallback flag. + * + * It is used for: Type::Fallback. + */ +final class Fallback extends Attribute +{ + /** + * Whether fallback to other fonts is enabled. + */ + public int $value; + + /** + * Create a new fallback attribute. + * + * @param int $value Non-zero to enable fallback to other fonts. + */ + public function __construct(int $value) {} +} + +/** + * LetterSpacing is an Attribute that holds extra spacing between graphemes in Pango units. + * + * It is used for: Type::LetterSpacing. + */ +final class LetterSpacing extends Attribute +{ + /** + * The extra letter spacing in Pango units. + */ + public int $value; + + /** + * Create a new letter spacing attribute. + * + * @param int $value The extra spacing in Pango units. + */ + public function __construct(int $value) {} +} + +/** + * UnderlineColor is an Attribute that holds the color of the underline decoration. + * + * It is used for: Type::UnderlineColor. + */ +final class UnderlineColor extends Attribute +{ + /** + * The underline color. + */ + public \Pango\Color $color; + + /** + * Create a new underline color attribute. + * + * @param \Pango\Color $color The underline color. + */ + public function __construct(\Pango\Color $color) {} +} + +/** + * StrikethroughColor is an Attribute that holds the color of the strikethrough decoration. + * + * It is used for: Type::StrikethroughColor. + */ +final class StrikethroughColor extends Attribute +{ + /** + * The strikethrough color. + */ + public \Pango\Color $color; + + /** + * Create a new strikethrough color attribute. + * + * @param \Pango\Color $color The strikethrough color. + */ + public function __construct(\Pango\Color $color) {} +} + +/** + * Gravity is an Attribute that holds a glyph orientation. + * + * It is used for: Type::Gravity. + */ +final class Gravity extends Attribute +{ + /** + * The gravity value (e.g., PANGO_GRAVITY_SOUTH). + */ + public int $value; + + /** + * Create a new gravity attribute. + * + * @param int $value The gravity value. + */ + public function __construct(int $value) {} +} + +/** + * GravityHint is an Attribute that holds a gravity hint. + * + * It is used for: Type::GravityHint. + */ +final class GravityHint extends Attribute +{ + /** + * The gravity hint value (e.g., PANGO_GRAVITY_HINT_NATURAL). + */ + public int $value; + + /** + * Create a new gravity hint attribute. + * + * @param int $value The gravity hint value. + */ + public function __construct(int $value) {} +} + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 38, 0) +/** + * FontFeatures is an Attribute that holds OpenType font features. + * + * It is used for: Type::FontFeatures. + */ +final class FontFeatures extends Attribute +{ + /** + * The font features string in CSS format (e.g., "dlig=1, kern=0"). + */ + public string $value; + + /** + * Create a new font features attribute. + * + * @param string $value The font features string. + */ + public function __construct(string $value) {} +} + +/** + * ForegroundAlpha is an Attribute that holds the opacity of the foreground color. + * + * It is used for: Type::ForegroundAlpha. + */ +final class ForegroundAlpha extends Attribute +{ + /** + * The alpha value, range 1-65535. + */ + public int $value; + + /** + * Create a new foreground alpha attribute. + * + * @param int $value The alpha value (1 = nearly transparent, 65535 = opaque). + */ + public function __construct(int $value) {} +} + +/** + * BackgroundAlpha is an Attribute that holds the opacity of the background color. + * + * It is used for: Type::BackgroundAlpha. + */ +final class BackgroundAlpha extends Attribute +{ + /** + * The alpha value, range 1-65535. + */ + public int $value; + + /** + * Create a new background alpha attribute. + * + * @param int $value The alpha value (1 = nearly transparent, 65535 = opaque). + */ + public function __construct(int $value) {} +} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 44, 0) +/** + * AllowBreaks is an Attribute that controls whether line breaks are allowed. + * + * It is used for: Type::AllowBreaks. + */ +final class AllowBreaks extends Attribute +{ + /** + * Whether line breaks are allowed. + */ + public int $value; + + /** + * Create a new allow-breaks attribute. + * + * @param int $value Non-zero to allow line breaks. + */ + public function __construct(int $value) {} +} + +/** + * Show is an Attribute that controls the display of invisible characters. + * + * It is used for: Type::Show. + */ +final class Show extends Attribute +{ + /** + * A combination of ShowFlags constants. + */ + public int $value; + + /** + * Create a new show attribute. + * + * @param int $value A combination of ShowFlags constants. + */ + public function __construct(int $value) {} +} + +/** + * InsertHyphens is an Attribute that controls automatic hyphen insertion. + * + * It is used for: Type::InsertHyphens. + */ +final class InsertHyphens extends Attribute +{ + /** + * Whether automatic hyphen insertion is enabled. + */ + public int $value; + + /** + * Create a new insert-hyphens attribute. + * + * @param int $value Non-zero to enable automatic hyphen insertion. + */ + public function __construct(int $value) {} +} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 46, 0) +/** + * Overline is an Attribute that holds an overline style. + * + * It is used for: Type::Overline. + */ +final class Overline extends Attribute +{ + /** + * The overline style value (e.g., PANGO_OVERLINE_SINGLE). + */ + public int $value; + + /** + * Create a new overline attribute. + * + * @param int $value The overline style value. + */ + public function __construct(int $value) {} +} + +/** + * OverlineColor is an Attribute that holds the color of the overline decoration. + * + * It is used for: Type::OverlineColor. + */ +final class OverlineColor extends Attribute +{ + /** + * The overline color. + */ + public \Pango\Color $color; + + /** + * Create a new overline color attribute. + * + * @param \Pango\Color $color The overline color. + */ + public function __construct(\Pango\Color $color) {} +} +#endif + +#if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 50, 0) +/** + * LineHeight is an Attribute that holds a line height scale factor. + * + * It is used for: Type::LineHeight. + */ +final class LineHeight extends Attribute +{ + /** + * The line height scale factor. + */ + public float $value; + + /** + * Create a new line height attribute. + * + * @param float $value The line height scale factor. + */ + public function __construct(float $value) {} +} + +/** + * AbsoluteLineHeight is an Attribute that holds an absolute line height in Pango units. + * + * It is used for: Type::AbsoluteLineHeight. + */ +final class AbsoluteLineHeight extends Attribute +{ + /** + * The absolute line height in Pango units. + */ + public int $value; + + /** + * Create a new absolute line height attribute. + * + * @param int $value The absolute line height in Pango units. + */ + public function __construct(int $value) {} +} + +/** + * TextTransform is an Attribute that holds a text transformation. + * + * It is used for: Type::TextTransform. + */ +final class TextTransform extends Attribute +{ + /** + * The text transform value (e.g., PANGO_TEXT_TRANSFORM_UPPERCASE). + */ + public int $value; + + /** + * Create a new text transform attribute. + * + * @param int $value The text transform value. + */ + public function __construct(int $value) {} +} + +/** + * Word is an Attribute that marks word boundaries. + * + * It is used for: Type::Word. + */ +final class Word extends Attribute +{ + /** + * Create a new word boundary attribute. + */ + public function __construct() {} +} + +/** + * Sentence is an Attribute that marks sentence boundaries. + * + * It is used for: Type::Sentence. + */ +final class Sentence extends Attribute +{ + /** + * Create a new sentence boundary attribute. + */ + public function __construct() {} +} + +/** + * BaselineShift is an Attribute that holds a baseline shift. + * + * It is used for: Type::BaselineShift. + */ +final class BaselineShift extends Attribute +{ + /** + * The baseline shift value (e.g., PANGO_BASELINE_SHIFT_SUPERSCRIPT). + */ + public int $value; + + /** + * Create a new baseline shift attribute. + * + * @param int $value The baseline shift value. + */ + public function __construct(int $value) {} +} + +/** + * FontScale is an Attribute that holds a font scale. + * + * It is used for: Type::FontScale. + */ +final class FontScale extends Attribute +{ + /** + * The font scale value (e.g., PANGO_FONT_SCALE_SUPERSCRIPT). + */ + public int $value; + + /** + * Create a new font scale attribute. + * + * @param int $value The font scale value. + */ + public function __construct(int $value) {} +} +#endif + /** * AttributeList represents a list of attributes (PangoAttrList) that apply to a section of text. * From 057746b2c846a14bdc47bed6dc8e6ac8938137e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 16:18:36 +0000 Subject: [PATCH 08/13] Replace Color::toString() with __toString() magic method --- src/attribute.stub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index dd4a90b..65a1c4a 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -60,7 +60,7 @@ public static function parse(string $spec): Color {} * The string is in the hexadecimal form #rrrrggggbbbb, where r, g and b are hex digits * representing the red, green, and blue components respectively. */ - public function toString(): string {} + public function __toString(): string {} } /** From a881540feda80bc113f47db546ffcc8bcc43ec04 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Jul 2026 08:48:27 +0000 Subject: [PATCH 09/13] Change Language attribute constructor to accept Language class instead of string --- src/attribute.stub.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index 65a1c4a..638a2ee 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -539,23 +539,23 @@ public function getType(): Type {} } /** - * Language is an Attribute that holds a language tag. + * Language is an Attribute that holds a Pango language. * * It is used for: Type::Language. */ final class Language extends Attribute { /** - * The language tag (e.g., "en", "fr"). + * The language. */ - public string $value; + public \Pango\Language $value; /** * Create a new language attribute. * - * @param string $value The language tag. + * @param \Pango\Language $value The language. */ - public function __construct(string $value) {} + public function __construct(\Pango\Language $value) {} } /** From 64d9f31a11b24f75e054b52cbade0fc10352c9c9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Jul 2026 08:57:39 +0000 Subject: [PATCH 10/13] Change Variant attribute to accept Pango\Variant enum instead of int --- src/attribute.stub.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index 638a2ee..3f683b9 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -626,16 +626,16 @@ public function __construct(int $value) {} final class Variant extends Attribute { /** - * The font variant value (e.g., PANGO_VARIANT_NORMAL, PANGO_VARIANT_SMALL_CAPS). + * The font variant value. */ - public int $value; + public \Pango\Variant $value; /** * Create a new font variant attribute. * - * @param int $value The font variant value. + * @param \Pango\Variant $value The font variant value. */ - public function __construct(int $value) {} + public function __construct(\Pango\Variant $value) {} } /** From 37c412951d52e21527b3336b3a6654e19bcd0446 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Jul 2026 09:02:32 +0000 Subject: [PATCH 11/13] Change Style attribute to accept Pango\Style enum instead of int --- src/attribute.stub.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index 3f683b9..493a975 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -586,16 +586,16 @@ public function __construct(string $value) {} final class Style extends Attribute { /** - * The font style value (e.g., PANGO_STYLE_NORMAL, PANGO_STYLE_ITALIC). + * The font style value. */ - public int $value; + public \Pango\Style $value; /** * Create a new font style attribute. * - * @param int $value The font style value. + * @param \Pango\Style $value The font style value. */ - public function __construct(int $value) {} + public function __construct(\Pango\Style $value) {} } /** From d612b152104a800ff3afebaad96e4109f33ebe84 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Jul 2026 09:12:29 +0000 Subject: [PATCH 12/13] Replace int with enum types for 9 attribute classes --- src/attribute.stub.php | 72 +++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index 493a975..19d8a87 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -606,16 +606,16 @@ public function __construct(\Pango\Style $value) {} final class Weight extends Attribute { /** - * The font weight value (e.g., PANGO_WEIGHT_NORMAL, PANGO_WEIGHT_BOLD). + * The font weight value. */ - public int $value; + public \Pango\Weight $value; /** * Create a new font weight attribute. * - * @param int $value The font weight value. + * @param \Pango\Weight $value The font weight value. */ - public function __construct(int $value) {} + public function __construct(\Pango\Weight $value) {} } /** @@ -646,16 +646,16 @@ public function __construct(\Pango\Variant $value) {} final class Stretch extends Attribute { /** - * The font stretch value (e.g., PANGO_STRETCH_NORMAL, PANGO_STRETCH_CONDENSED). + * The font stretch value. */ - public int $value; + public \Pango\Stretch $value; /** * Create a new font stretch attribute. * - * @param int $value The font stretch value. + * @param \Pango\Stretch $value The font stretch value. */ - public function __construct(int $value) {} + public function __construct(\Pango\Stretch $value) {} } /** @@ -769,16 +769,16 @@ public function __construct(\Pango\Color $color) {} final class Underline extends Attribute { /** - * The underline style value (e.g., PANGO_UNDERLINE_SINGLE). + * The underline style value. */ - public int $value; + public \Pango\Underline $value; /** * Create a new underline attribute. * - * @param int $value The underline style value. + * @param \Pango\Underline $value The underline style value. */ - public function __construct(int $value) {} + public function __construct(\Pango\Underline $value) {} } /** @@ -955,16 +955,16 @@ public function __construct(\Pango\Color $color) {} final class Gravity extends Attribute { /** - * The gravity value (e.g., PANGO_GRAVITY_SOUTH). + * The gravity value. */ - public int $value; + public \Pango\Gravity $value; /** * Create a new gravity attribute. * - * @param int $value The gravity value. + * @param \Pango\Gravity $value The gravity value. */ - public function __construct(int $value) {} + public function __construct(\Pango\Gravity $value) {} } /** @@ -975,16 +975,16 @@ public function __construct(int $value) {} final class GravityHint extends Attribute { /** - * The gravity hint value (e.g., PANGO_GRAVITY_HINT_NATURAL). + * The gravity hint value. */ - public int $value; + public \Pango\GravityHint $value; /** * Create a new gravity hint attribute. * - * @param int $value The gravity hint value. + * @param \Pango\GravityHint $value The gravity hint value. */ - public function __construct(int $value) {} + public function __construct(\Pango\GravityHint $value) {} } #if PANGO_VERSION >= PANGO_VERSION_ENCODE(1, 38, 0) @@ -1120,16 +1120,16 @@ public function __construct(int $value) {} final class Overline extends Attribute { /** - * The overline style value (e.g., PANGO_OVERLINE_SINGLE). + * The overline style value. */ - public int $value; + public \Pango\Overline $value; /** * Create a new overline attribute. * - * @param int $value The overline style value. + * @param \Pango\Overline $value The overline style value. */ - public function __construct(int $value) {} + public function __construct(\Pango\Overline $value) {} } /** @@ -1202,16 +1202,16 @@ public function __construct(int $value) {} final class TextTransform extends Attribute { /** - * The text transform value (e.g., PANGO_TEXT_TRANSFORM_UPPERCASE). + * The text transform value. */ - public int $value; + public \Pango\TextTransform $value; /** * Create a new text transform attribute. * - * @param int $value The text transform value. + * @param \Pango\TextTransform $value The text transform value. */ - public function __construct(int $value) {} + public function __construct(\Pango\TextTransform $value) {} } /** @@ -1248,16 +1248,16 @@ public function __construct() {} final class BaselineShift extends Attribute { /** - * The baseline shift value (e.g., PANGO_BASELINE_SHIFT_SUPERSCRIPT). + * The baseline shift value. */ - public int $value; + public \Pango\BaselineShift $value; /** * Create a new baseline shift attribute. * - * @param int $value The baseline shift value. + * @param \Pango\BaselineShift $value The baseline shift value. */ - public function __construct(int $value) {} + public function __construct(\Pango\BaselineShift $value) {} } /** @@ -1268,16 +1268,16 @@ public function __construct(int $value) {} final class FontScale extends Attribute { /** - * The font scale value (e.g., PANGO_FONT_SCALE_SUPERSCRIPT). + * The font scale value. */ - public int $value; + public \Pango\FontScale $value; /** * Create a new font scale attribute. * - * @param int $value The font scale value. + * @param \Pango\FontScale $value The font scale value. */ - public function __construct(int $value) {} + public function __construct(\Pango\FontScale $value) {} } #endif From 63524347708c2246aa74543d2f85c5c59d90d4a4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Jul 2026 09:57:28 +0000 Subject: [PATCH 13/13] feat: convert boolean-like attributes to bool type in attribute.stub.php --- src/attribute.stub.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/attribute.stub.php b/src/attribute.stub.php index 19d8a87..fba232a 100644 --- a/src/attribute.stub.php +++ b/src/attribute.stub.php @@ -791,14 +791,14 @@ final class Strikethrough extends Attribute /** * Whether strikethrough is enabled. */ - public int $value; + public bool $value; /** * Create a new strikethrough attribute. * - * @param int $value Non-zero to enable strikethrough. + * @param bool $value True to enable strikethrough. */ - public function __construct(int $value) {} + public function __construct(bool $value) {} } /** @@ -877,14 +877,14 @@ final class Fallback extends Attribute /** * Whether fallback to other fonts is enabled. */ - public int $value; + public bool $value; /** * Create a new fallback attribute. * - * @param int $value Non-zero to enable fallback to other fonts. + * @param bool $value True to enable fallback to other fonts. */ - public function __construct(int $value) {} + public function __construct(bool $value) {} } /** @@ -1060,14 +1060,14 @@ final class AllowBreaks extends Attribute /** * Whether line breaks are allowed. */ - public int $value; + public bool $value; /** * Create a new allow-breaks attribute. * - * @param int $value Non-zero to allow line breaks. + * @param bool $value True to allow line breaks. */ - public function __construct(int $value) {} + public function __construct(bool $value) {} } /** @@ -1100,14 +1100,14 @@ final class InsertHyphens extends Attribute /** * Whether automatic hyphen insertion is enabled. */ - public int $value; + public bool $value; /** * Create a new insert-hyphens attribute. * - * @param int $value Non-zero to enable automatic hyphen insertion. + * @param bool $value True to enable automatic hyphen insertion. */ - public function __construct(int $value) {} + public function __construct(bool $value) {} } #endif