src/hbcore/utils/hbfontspec.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 5 627c4a0fd0e7
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 #include "hbfontspec.h"
    25 #include "hbfontspec.h"
       
    26 #ifndef HB_BOOTSTRAPPED
    26 #include "hbinstance_p.h"
    27 #include "hbinstance_p.h"
    27 #include "hbtypefaceinfo_p.h"
    28 #include "hbtypefaceinfo_p.h"
    28 #include "hbstyle.h"
    29 #include "hbstyle.h"
    29 
    30 #endif
       
    31 
       
    32 #include <QVariant>
    30 #include <QFont>
    33 #include <QFont>
    31 #include <QSharedData>
    34 
    32 
    35 /*!
    33 /*!
    36 	@stable
    34     @beta
       
    35     @hbcore
    37     @hbcore
    36     \class HbFontSpec
    38     \class HbFontSpec
    37     \brief HbFontSpec is used to request a system font.
    39     \brief HbFontSpec is used to request a system font.
    38 
    40 
    39     It introduces a list of font roles, which can be used to request system
    41     It introduces a list of font roles, which can be used to request system
   135 If text height is not set with setTextHeight() resolves the
   137 If text height is not set with setTextHeight() resolves the
   136 default text height based on the font role.
   138 default text height based on the font role.
   137 */
   139 */
   138 qreal HbFontSpecPrivate::textHeight() const
   140 qreal HbFontSpecPrivate::textHeight() const
   139 {
   141 {
       
   142 #ifdef HB_BOOTSTRAPPED
       
   143     return 0;
       
   144 #else
   140     if ( (mRole != HbFontSpec::Undefined) && (mTextHeight < 0) ) {
   145     if ( (mRole != HbFontSpec::Undefined) && (mTextHeight < 0) ) {
   141         qreal parameterValue;
   146         qreal parameterValue;
   142         QString parameterName;
   147         QString parameterName;
   143         switch (mRole){
   148         switch (mRole){
   144             case HbFontSpec::Primary:
   149             case HbFontSpec::Primary:
   160         }
   165         }
   161         HbInstance::instance()->style()->parameter( parameterName, parameterValue );
   166         HbInstance::instance()->style()->parameter( parameterName, parameterValue );
   162         mTextHeight = parameterValue;
   167         mTextHeight = parameterValue;
   163     }
   168     }
   164 	return mTextHeight;
   169 	return mTextHeight;
       
   170 #endif
   165 }
   171 }
   166 
   172 
   167 /*!
   173 /*!
   168 \internal
   174 \internal
   169 */
   175 */
   170 QFont HbFontSpecPrivate::font() const
   176 QFont HbFontSpecPrivate::font() const
   171 {
   177 {
       
   178 #ifdef HB_BOOTSTRAPPED
       
   179     return QFont();
       
   180 #else
   172     if ( mRole == HbFontSpec::Undefined ) {
   181     if ( mRole == HbFontSpec::Undefined ) {
   173         return QFont();
   182         return QFont();
   174     }
   183     }
   175     QString typefaceFamily;
   184     QString typefaceFamily;
   176     int weight;
   185     int weight;
   186     qreal height = textHeight();
   195     qreal height = textHeight();
   187 	int downSizedSize = tInfo->textHeightToSizeInPixels(typefaceFamily, weight, height);
   196 	int downSizedSize = tInfo->textHeightToSizeInPixels(typefaceFamily, weight, height);
   188     font.setPixelSize(downSizedSize);
   197     font.setPixelSize(downSizedSize);
   189 
   198 
   190     return font;
   199     return font;
       
   200 #endif
   191 }
   201 }
   192 
   202 
   193 /*!
   203 /*!
   194     Default constructor. The font role is HbFontSpec::Undefined and
   204     Default constructor. The font role is HbFontSpec::Undefined and
   195     the font matches a default constructed QFont instance.
   205     the font matches a default constructed QFont instance.
   284 {
   294 {
   285     return d->font();
   295     return d->font();
   286 }
   296 }
   287 
   297 
   288 /*!
   298 /*!
   289     \deprecated HbFontSpec::pixelSize() const
       
   290         is deprecated. Use QFont instead.
       
   291 */
       
   292 int HbFontSpec::pixelSize() const
       
   293 {
       
   294     return -1;
       
   295 }
       
   296 
       
   297 /*!
       
   298     \deprecated HbFontSpec::setPixelSize(int)
       
   299         is deprecated. Use QFont instead.
       
   300 */
       
   301 void HbFontSpec::setPixelSize(int pixelSize)
       
   302 {
       
   303     Q_UNUSED(pixelSize);
       
   304 }
       
   305 
       
   306 /*!
       
   307     \deprecated HbFontSpec::pointSize() const
       
   308         is deprecated. Use QFont instead.
       
   309 */
       
   310 int HbFontSpec::pointSize() const
       
   311 {
       
   312     return -1;
       
   313 }
       
   314 
       
   315 /*!
       
   316     \deprecated HbFontSpec::setPointSize(int)
       
   317         is deprecated. Use QFont instead.
       
   318 */
       
   319 void HbFontSpec::setPointSize(int pointSize)
       
   320 {
       
   321     Q_UNUSED(pointSize);
       
   322 }
       
   323 
       
   324 /*!
       
   325     \deprecated HbFontSpec::fontDelta() const
       
   326         is deprecated. Use QFont instead.
       
   327 */
       
   328 QFont HbFontSpec::fontDelta() const
       
   329 {
       
   330     return QFont();
       
   331 }
       
   332 
       
   333 /*!
       
   334     \deprecated HbFontSpec::setFontDelta(const QFont&)
       
   335         is deprecated. Use QFont instead.
       
   336 */
       
   337 void HbFontSpec::setFontDelta(const QFont &fontDelta)
       
   338 {
       
   339     Q_UNUSED(fontDelta);
       
   340 }
       
   341 
       
   342 /*!
       
   343     Returns the fontspec as a QVariant.
   299     Returns the fontspec as a QVariant.
   344 */
   300 */
   345 HbFontSpec::operator QVariant() const
   301 HbFontSpec::operator QVariant() const
   346 {
   302 {
   347     return QVariant::fromValue(*this);
   303     return QVariant::fromValue(*this);
   363 {
   319 {
   364     return (!(*this == other));
   320     return (!(*this == other));
   365 }
   321 }
   366 
   322 
   367 /*!
   323 /*!
   368     \deprecated HbFontSpec::textPaneHeight() const
       
   369         is deprecated. Use textHeight instead.
       
   370 */
       
   371 qreal HbFontSpec::textPaneHeight() const
       
   372 {
       
   373 	return textHeight();
       
   374 }
       
   375 
       
   376 /*!
       
   377     \deprecated HbFontSpec::setTextPaneHeight(qreal)
       
   378         is deprecated. Use textHeight instead.
       
   379 */
       
   380 void HbFontSpec::setTextPaneHeight(qreal textHeight)
       
   381 {
       
   382     setTextHeight(textHeight);
       
   383 }
       
   384 
       
   385 /*!
       
   386     Returns the text height that was set using \a setTextHeight.
   324     Returns the text height that was set using \a setTextHeight.
   387 
   325 
   388     If text height is not set returns default value defined by the font role.
   326     If text height is not set returns default value defined by the font role.
   389 
   327 
   390     \sa HbFontSpec::setTextHeight
   328     \sa HbFontSpec::setTextHeight