mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-10-31 00:06:02 -04:00 
			
		
		
		
	labels, and move methods for calculating curved text placement out of PAL so that they can be reused elsewhere
		
			
				
	
	
		
			234 lines
		
	
	
		
			9.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			234 lines
		
	
	
		
			9.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/core/textrenderer/qgstextrenderer.h                              *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | |
|  ************************************************************************/
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| class QgsTextRenderer
 | |
| {
 | |
| %Docstring(signature="appended")
 | |
| Handles rendering text using rich formatting options, including drop shadows, buffers
 | |
| and background shapes.
 | |
| 
 | |
| .. versionadded:: 3.0
 | |
| %End
 | |
| 
 | |
| %TypeHeaderCode
 | |
| #include "qgstextrenderer.h"
 | |
| %End
 | |
|   public:
 | |
| 
 | |
|     enum DrawMode
 | |
|     {
 | |
|       Rect,
 | |
|       Point,
 | |
|       Label,
 | |
|     };
 | |
| 
 | |
|     enum TextPart
 | |
|     {
 | |
|       Text,
 | |
|       Buffer,
 | |
|       Background,
 | |
|       Shadow,
 | |
|     };
 | |
| 
 | |
|     enum HAlignment
 | |
|     {
 | |
|       AlignLeft,
 | |
|       AlignCenter,
 | |
|       AlignRight,
 | |
|       AlignJustify,
 | |
|     };
 | |
| 
 | |
|     static HAlignment convertQtHAlignment( Qt::Alignment alignment );
 | |
| %Docstring
 | |
| Converts a Qt horizontal ``alignment`` flag to a QgsTextRenderer.HAlignment value.
 | |
| 
 | |
| .. seealso:: :py:func:`convertQtVAlignment`
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     enum VAlignment
 | |
|     {
 | |
|       AlignTop,
 | |
|       AlignVCenter,
 | |
|       AlignBottom,
 | |
|     };
 | |
| 
 | |
|     static VAlignment convertQtVAlignment( Qt::Alignment alignment );
 | |
| %Docstring
 | |
| Converts a Qt vertical ``alignment`` flag to a QgsTextRenderer.VAlignment value.
 | |
| 
 | |
| .. seealso:: :py:func:`convertQtHAlignment`
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     static int sizeToPixel( double size, const QgsRenderContext &c, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &mapUnitScale = QgsMapUnitScale() );
 | |
| %Docstring
 | |
| Calculates pixel size (considering output size should be in pixel or map units, scale factors and optionally oversampling)
 | |
| 
 | |
| :param size: size to convert
 | |
| :param c: rendercontext
 | |
| :param unit: size units
 | |
| :param mapUnitScale: a mapUnitScale clamper
 | |
| 
 | |
| :return: font pixel size
 | |
| %End
 | |
| 
 | |
| 
 | |
|     static void drawText( const QRectF &rect, double rotation, HAlignment alignment, const QStringList &textLines,
 | |
|                           QgsRenderContext &context, const QgsTextFormat &format,
 | |
|                           bool drawAsOutlines = true, VAlignment vAlignment = AlignTop );
 | |
| %Docstring
 | |
| Draws text within a rectangle using the specified settings.
 | |
| 
 | |
| :param rect: destination rectangle for text
 | |
| :param rotation: text rotation
 | |
| :param alignment: horizontal alignment
 | |
| :param textLines: list of lines of text to draw
 | |
| :param context: render context
 | |
| :param format: text format
 | |
| :param drawAsOutlines: set to ``False`` to render text as text. This allows outputs to
 | |
|                        formats like SVG to maintain text as text objects, but at the cost of degraded
 | |
|                        rendering and may result in side effects like misaligned text buffers. This setting is deprecated and has no effect
 | |
|                        as of QGIS 3.4.3 and the text format should be set using :py:func:`QgsRenderContext.setTextRenderFormat()` instead.
 | |
| :param vAlignment: vertical alignment (since QGIS 3.16)
 | |
| %End
 | |
| 
 | |
|     static void drawText( QPointF point, double rotation, HAlignment alignment, const QStringList &textLines,
 | |
|                           QgsRenderContext &context, const QgsTextFormat &format,
 | |
|                           bool drawAsOutlines = true );
 | |
| %Docstring
 | |
| Draws text at a point origin using the specified settings.
 | |
| 
 | |
| :param point: origin of text
 | |
| :param rotation: text rotation
 | |
| :param alignment: horizontal alignment
 | |
| :param textLines: list of lines of text to draw
 | |
| :param context: render context
 | |
| :param format: text format
 | |
| :param drawAsOutlines: set to ``False`` to render text as text. This allows outputs to
 | |
|                        formats like SVG to maintain text as text objects, but at the cost of degraded
 | |
|                        rendering and may result in side effects like misaligned text buffers. This setting is deprecated and has no effect
 | |
|                        as of QGIS 3.4.3 and the text format should be set using :py:func:`QgsRenderContext.setTextRenderFormat()` instead.
 | |
| %End
 | |
| 
 | |
|  static void drawPart( const QRectF &rect, double rotation, HAlignment alignment, const QStringList &textLines,
 | |
|                                             QgsRenderContext &context, const QgsTextFormat &format,
 | |
|                                             TextPart part, bool drawAsOutlines = true ) /Deprecated/;
 | |
| %Docstring
 | |
| Draws a single component of rendered text using the specified settings.
 | |
| 
 | |
| :param rect: destination rectangle for text
 | |
| :param rotation: text rotation
 | |
| :param alignment: horizontal alignment
 | |
| :param textLines: list of lines of text to draw
 | |
| :param context: render context
 | |
| :param format: text format
 | |
| :param part: component of text to draw. Note that Shadow parts cannot be drawn
 | |
|              individually and instead are drawn with their associated part (e.g., drawn together
 | |
|              with the text or background parts)
 | |
| :param drawAsOutlines: set to ``False`` to render text as text. This allows outputs to
 | |
|                        formats like SVG to maintain text as text objects, but at the cost of degraded
 | |
|                        rendering and may result in side effects like misaligned text buffers. This setting is deprecated and has no effect
 | |
|                        as of QGIS 3.4.3 and the text format should be set using :py:func:`QgsRenderContext.setTextRenderFormat()` instead.
 | |
| 
 | |
| .. deprecated::
 | |
|    Private API only, will be removed in 4.0
 | |
| %End
 | |
| 
 | |
|  static void drawPart( QPointF origin, double rotation, HAlignment alignment, const QStringList &textLines,
 | |
|                                             QgsRenderContext &context, const QgsTextFormat &format,
 | |
|                                             TextPart part, bool drawAsOutlines = true ) /Deprecated/;
 | |
| %Docstring
 | |
| Draws a single component of rendered text using the specified settings.
 | |
| 
 | |
| :param origin: origin for start of text. Y coordinate will be used as baseline.
 | |
| :param rotation: text rotation
 | |
| :param alignment: horizontal alignment
 | |
| :param textLines: list of lines of text to draw
 | |
| :param context: render context
 | |
| :param format: text format
 | |
| :param part: component of text to draw. Note that Shadow parts cannot be drawn
 | |
|              individually and instead are drawn with their associated part (e.g., drawn together
 | |
|              with the text or background parts)
 | |
| :param drawAsOutlines: set to ``False`` to render text as text. This allows outputs to
 | |
|                        formats like SVG to maintain text as text objects, but at the cost of degraded
 | |
|                        rendering and may result in side effects like misaligned text buffers. This setting is deprecated and has no effect
 | |
|                        as of QGIS 3.4.3 and the text format should be set using :py:func:`QgsRenderContext.setTextRenderFormat()` instead.
 | |
| 
 | |
| .. deprecated::
 | |
|    Private API only, will be removed in 4.0
 | |
| %End
 | |
| 
 | |
|     static QFontMetricsF fontMetrics( QgsRenderContext &context, const QgsTextFormat &format, double scaleFactor = 1.0 );
 | |
| %Docstring
 | |
| Returns the font metrics for the given text ``format``, when rendered
 | |
| in the specified render ``context``. The font metrics will take into account
 | |
| all scaling required by the render context.
 | |
| 
 | |
| The optional ``scaleFactor`` argument can specify a font size scaling factor. It is recommended to set this to
 | |
| QgsTextRenderer.FONT_WORKAROUND_SCALE and then manually scale painter devices or calculations
 | |
| based on the resultant font metrics. Failure to do so will result in poor quality text rendering
 | |
| at small font sizes.
 | |
| 
 | |
| .. versionadded:: 3.2
 | |
| %End
 | |
| 
 | |
|     static double textWidth( const QgsRenderContext &context, const QgsTextFormat &format, const QStringList &textLines,
 | |
|                              QFontMetricsF *fontMetrics = 0 );
 | |
| %Docstring
 | |
| Returns the width of a text based on a given format.
 | |
| 
 | |
| :param context: render context
 | |
| :param format: text format
 | |
| :param textLines: list of lines of text to calculate width from
 | |
| :param fontMetrics: font metrics
 | |
| %End
 | |
| 
 | |
|     static double textHeight( const QgsRenderContext &context, const QgsTextFormat &format, const QStringList &textLines, DrawMode mode = Point,
 | |
|                               QFontMetricsF *fontMetrics = 0 );
 | |
| %Docstring
 | |
| Returns the height of a text based on a given format.
 | |
| 
 | |
| :param context: render context
 | |
| :param format: text format
 | |
| :param textLines: list of lines of text to calculate width from
 | |
| :param mode: draw mode
 | |
| :param fontMetrics: font metrics
 | |
| %End
 | |
| 
 | |
|     static double textHeight( const QgsRenderContext &context, const QgsTextFormat &format, QChar character, bool includeEffects = false );
 | |
| %Docstring
 | |
| Returns the height of a character when rendered with the specified text ``format``.
 | |
| 
 | |
| :param context: render context
 | |
| :param format: text format
 | |
| :param character: character to determine height of. If ``character`` is invalid, then the maximum character height will be returned.
 | |
| :param includeEffects: if ``True``, then the size of formatting effects such as buffers and shadows will be considered in the
 | |
|                        returned height. If ``False``, then the returned size considers the character only.
 | |
| 
 | |
| .. versionadded:: 3.16
 | |
| %End
 | |
| 
 | |
|     static const double FONT_WORKAROUND_SCALE;
 | |
| 
 | |
| };
 | |
| 
 | |
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/core/textrenderer/qgstextrenderer.h                              *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | |
|  ************************************************************************/
 |