qfontmetrics.sip 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // qfontmetrics.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtGui Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QFontMetrics
  22. {
  23. %TypeHeaderCode
  24. #include <qfontmetrics.h>
  25. %End
  26. public:
  27. explicit QFontMetrics(const QFont &);
  28. QFontMetrics(const QFont &font, const QPaintDevice *pd);
  29. QFontMetrics(const QFontMetrics &);
  30. ~QFontMetrics();
  31. int ascent() const;
  32. int descent() const;
  33. int height() const;
  34. int leading() const;
  35. int lineSpacing() const;
  36. int minLeftBearing() const;
  37. int minRightBearing() const;
  38. int maxWidth() const;
  39. int xHeight() const;
  40. bool inFont(QChar) const;
  41. int leftBearing(QChar) const;
  42. int rightBearing(QChar) const;
  43. %If (Qt_6_3_0 -)
  44. QRect boundingRect(const QString &text, const QTextOption &textOption) const;
  45. %End
  46. QRect boundingRect(QChar) const /PyName=boundingRectChar/;
  47. QRect boundingRect(const QString &text) const;
  48. QRect boundingRect(const QRect &rect, int flags, const QString &text, int tabStops = 0, SIP_PYLIST tabArray /AllowNone,TypeHint="Optional[List[int]]"/ = 0) const;
  49. %MethodCode
  50. int *tabarray = qtgui_tabarray(a4);
  51. sipRes = new QRect(sipCpp->boundingRect(*a0, a1, *a2, a3, tabarray));
  52. if (!tabarray)
  53. delete[] tabarray;
  54. %End
  55. QRect boundingRect(int x, int y, int width, int height, int flags, const QString &text, int tabStops = 0, SIP_PYLIST tabArray /AllowNone,TypeHint="Optional[List[int]]"/ = 0) const;
  56. %MethodCode
  57. int *tabarray = qtgui_tabarray(a7);
  58. sipRes = new QRect(sipCpp->boundingRect(a0, a1, a2, a3, a4, *a5, a6, tabarray));
  59. if (!tabarray)
  60. delete[] tabarray;
  61. %End
  62. QSize size(int flags, const QString &text, int tabStops = 0, SIP_PYLIST tabArray /AllowNone,TypeHint="Optional[List[int]]"/ = 0) const;
  63. %MethodCode
  64. int *tabarray = qtgui_tabarray(a3);
  65. sipRes = new QSize(sipCpp->size(a0, *a1, a2, tabarray));
  66. if (!tabarray)
  67. delete[] tabarray;
  68. %End
  69. int underlinePos() const;
  70. int overlinePos() const;
  71. int strikeOutPos() const;
  72. int lineWidth() const;
  73. int averageCharWidth() const;
  74. QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags = 0) const;
  75. bool operator==(const QFontMetrics &other) const;
  76. bool operator!=(const QFontMetrics &other) const;
  77. %If (Qt_6_3_0 -)
  78. QRect tightBoundingRect(const QString &text, const QTextOption &textOption) const;
  79. %End
  80. QRect tightBoundingRect(const QString &text) const;
  81. bool inFontUcs4(uint character) const;
  82. void swap(QFontMetrics &other /Constrained/);
  83. int capHeight() const;
  84. %If (Qt_6_3_0 -)
  85. int horizontalAdvance(const QString &, const QTextOption &textOption) const;
  86. %End
  87. int horizontalAdvance(const QString &, int length = -1) const;
  88. qreal fontDpi() const;
  89. };
  90. class QFontMetricsF
  91. {
  92. %TypeHeaderCode
  93. #include <qfontmetrics.h>
  94. %End
  95. public:
  96. explicit QFontMetricsF(const QFont &);
  97. QFontMetricsF(const QFont &font, const QPaintDevice *pd);
  98. QFontMetricsF(const QFontMetrics &);
  99. QFontMetricsF(const QFontMetricsF &);
  100. ~QFontMetricsF();
  101. qreal ascent() const;
  102. qreal descent() const;
  103. qreal height() const;
  104. qreal leading() const;
  105. qreal lineSpacing() const;
  106. qreal minLeftBearing() const;
  107. qreal minRightBearing() const;
  108. qreal maxWidth() const;
  109. qreal xHeight() const;
  110. bool inFont(QChar) const;
  111. qreal leftBearing(QChar) const;
  112. qreal rightBearing(QChar) const;
  113. %If (Qt_6_3_0 -)
  114. QRectF boundingRect(const QString &text, const QTextOption &textOption) const;
  115. %End
  116. QRectF boundingRect(QChar) const /PyName=boundingRectChar/;
  117. QRectF boundingRect(const QString &string) const;
  118. QRectF boundingRect(const QRectF &rect, int flags, const QString &text, int tabStops = 0, SIP_PYLIST tabArray /AllowNone,TypeHint="Optional[List[int]]"/ = 0) const;
  119. %MethodCode
  120. int *tabarray = qtgui_tabarray(a4);
  121. sipRes = new QRectF(sipCpp->boundingRect(*a0, a1, *a2, a3, tabarray));
  122. if (!tabarray)
  123. delete[] tabarray;
  124. %End
  125. QSizeF size(int flags, const QString &text, int tabStops = 0, SIP_PYLIST tabArray /AllowNone,TypeHint="Optional[List[int]]"/ = 0) const;
  126. %MethodCode
  127. int *tabarray = qtgui_tabarray(a3);
  128. sipRes = new QSizeF(sipCpp->size(a0, *a1, a2, tabarray));
  129. if (!tabarray)
  130. delete[] tabarray;
  131. %End
  132. qreal underlinePos() const;
  133. qreal overlinePos() const;
  134. qreal strikeOutPos() const;
  135. qreal lineWidth() const;
  136. qreal averageCharWidth() const;
  137. QString elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags = 0) const;
  138. bool operator==(const QFontMetricsF &other) const;
  139. bool operator!=(const QFontMetricsF &other) const;
  140. %If (Qt_6_3_0 -)
  141. QRectF tightBoundingRect(const QString &text, const QTextOption &textOption) const;
  142. %End
  143. QRectF tightBoundingRect(const QString &text) const;
  144. bool inFontUcs4(uint character) const;
  145. void swap(QFontMetricsF &other /Constrained/);
  146. qreal capHeight() const;
  147. %If (Qt_6_3_0 -)
  148. qreal horizontalAdvance(const QString &string, const QTextOption &textOption) const;
  149. %End
  150. qreal horizontalAdvance(const QString &string, int length = -1) const;
  151. qreal fontDpi() const;
  152. };
  153. %ModuleHeaderCode
  154. // Used by QFontMetrics and QFontMetricsF.
  155. int *qtgui_tabarray(PyObject *l);
  156. %End
  157. %ModuleCode
  158. // Convert an optional Python list to a 0 terminated array of integers on the
  159. // heap.
  160. int *qtgui_tabarray(PyObject *l)
  161. {
  162. if (!l || l == Py_None)
  163. return 0;
  164. int *arr = new int[PyList_Size(l) + 1];
  165. Py_ssize_t i;
  166. for (i = 0; i < PyList_Size(l); ++i)
  167. arr[i] = PyLong_AsLong(PyList_GetItem(l, i));
  168. arr[i] = 0;
  169. return arr;
  170. }
  171. %End