Warning, /education/gcompris/src/core/GCText.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - GCText.qml
0002  *
0003  * SPDX-FileCopyrightText: 2014 Johnny Jazeix <jazeix@gmail.com>
0004  *
0005  * Authors:
0006  *   Johnny Jazeix <jazeix@gmail.com>
0007  *   Holger Kaelberer <holger.k@elberer.de>
0008  *
0009  *   SPDX-License-Identifier: GPL-3.0-or-later
0010  */
0011 import QtQuick 2.12
0012 import GCompris 1.0
0013 import "."
0014 
0015 /**
0016  * A QML component unifying text presentation in GCompris.
0017  * @ingroup components
0018  *
0019  * GCText wraps QtQuick's Text to provide
0020  *
0021  * (1) a uniform font-family,<br/>
0022  * (2) DPI based automatic font-scaling and<br/>
0023  * (3) application-wide manual font-sizing.<br/>
0024  *
0025  * Activities should almost always use the @ref fontSize property to
0026  * define font sizes, it implements both (2) and (3). <b>Do not</b> set
0027  * @c font.pointSize directly, or GCText's automatic scaling will be
0028  * deactivated. If you really need to enforce a fixed font size (which
0029  * might be the case for dialogs) use the fixFontSize property.
0030  *
0031  * The xxxSize properties are meant to be enum-like values for often needed
0032  * font sizes. (QtQuick does not support enum definitions on QML layer, cf.
0033  * Qt issue #14861.)
0034  *
0035  * @inherit QtQuick.Text
0036  * @sa GCSingletonFontLoader
0037  */
0038 Text {
0039     /**
0040      * type:int
0041      * Tiny font-size.
0042      * Value: 10
0043      */
0044     readonly property int tinySize:     10.0
0045 
0046     /**
0047      * type:int
0048      * Small font-size.
0049      * Value: 12
0050      */
0051     readonly property int smallSize:    12.0
0052 
0053     /**
0054      * type:int
0055      * Regular font-size.
0056      * Value: 14
0057      */
0058     readonly property int regularSize:  14.0
0059 
0060     /**
0061      * type:int
0062      * Medium font-size.
0063      * Value: 16
0064      */
0065     readonly property int mediumSize:   16.0
0066 
0067     /**
0068      * type:int
0069      * Large font-size.
0070      * Value: 24
0071      */
0072     readonly property int largeSize:    24.0
0073 
0074     /**
0075      * type:int
0076      * Huge font-size.
0077      * Value: 32
0078      */
0079     readonly property int hugeSize:     32.0
0080 
0081     /**
0082      * type:bool
0083      * Whether to not apply ApplicationSettings.baseFontSize.
0084      *
0085      * Set to true if you don't want to scale fonts. Used in some rare cases
0086      * like for dialogs.
0087      */
0088     property bool fixFontSize: false
0089 
0090     /**
0091      * type:int
0092      * Font size wrapping font.pointSize and applying font-scaling.
0093      *
0094      * Font-sizes are best specified using the fontSize property, which
0095      * wraps font.pointSize to take the DPI of the display into account.
0096      * If font.pointSize is used directly text might appear to small on some
0097      * devices.
0098      *
0099      * If you really need to specify font.pixelSize instead of pointSize,
0100      * you need to clear font.pointSize explicitly with NaN:
0101      *
0102      * @code
0103      * font.pointSize: NaN
0104      * @endcode
0105      *
0106      * Default is 14.
0107      */
0108     property int fontSize: 14
0109 
0110     /**
0111      * type:int
0112      * Read only value of the calculated pointSize
0113      */
0114     readonly property int pointSize: font.pointSize
0115 
0116     font.pointSize: ((fixFontSize ? 0 : ApplicationSettings.baseFontSize)
0117                       + fontSize) * ApplicationInfo.fontRatio
0118     font.family: GCSingletonFontLoader.fontLoader.name
0119     font.capitalization: ApplicationSettings.fontCapitalization
0120     font.letterSpacing: ApplicationSettings.fontLetterSpacing
0121     color: "#191919"
0122 }