#include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
// EXTERNAL INCLUDES
-#include <string>
-#include <iostream>
#include <cstring>
#include <dali/public-api/adaptor-framework/key.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/images/resource-image.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/object/type-registry-helper.h>
-#include <dali/devel-api/scripting/scripting.h>
#include <dali/devel-api/adaptor-framework/virtual-keyboard.h>
+#include <dali/devel-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/rendering-backend.h>
-#include <dali-toolkit/internal/text/layouts/layout-engine.h>
+#include <dali-toolkit/internal/controls/text-controls/text-font-style.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
#include <dali-toolkit/internal/text/text-view.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#endif
const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
-
} // unnamed namespace
namespace
}
case Toolkit::TextField::Property::FONT_STYLE:
{
- if( impl.mController )
- {
- const std::string fontStyle = value.Get< std::string >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_STYLE %s\n", impl.mController.Get(), fontStyle.c_str() );
-
- if( impl.mController->GetDefaultFontStyle() != fontStyle )
- {
- impl.mController->SetDefaultFontStyle( fontStyle );
- }
- }
+ SetFontStyleProperty( impl.mController, value );
break;
}
case Toolkit::TextField::Property::POINT_SIZE:
}
case Toolkit::TextField::Property::FONT_STYLE:
{
- if( impl.mController )
- {
- value = impl.mController->GetDefaultFontStyle();
- }
+ GetFontStyleProperty( impl.mController, value );
break;
}
case Toolkit::TextField::Property::POINT_SIZE:
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// FILE HEADER
+#include <dali-toolkit/internal/controls/text-controls/text-font-style.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/builder/json-parser.h>
+#include <dali-toolkit/devel-api/builder/tree-node.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+namespace
+{
+const std::string STYLE_KEY( "style" );
+const std::string WIDTH_KEY( "width" );
+const std::string WEIGHT_KEY( "weight" );
+const std::string SLANT_KEY( "slant" );
+const std::string EMPTY_STRING( "" );
+
+} // namespace
+
+/**
+ * @brief Creates a map with pairs 'key,value' with the font's style parameters.
+ *
+ * @param[in] node Data structure with the font's style parameters.
+ * @param[out] map A map with the font's style parameters.
+ *
+ */
+void CreateFontStyleMap( const TreeNode* const node, Property::Map& map )
+{
+ switch( node->GetType() )
+ {
+ case TreeNode::IS_NULL:
+ case TreeNode::OBJECT:
+ case TreeNode::ARRAY: // FALL THROUGH
+ {
+ break;
+ }
+ case TreeNode::STRING:
+ {
+ map.Insert( node->GetName(), Property::Value( node->GetString() ) );
+ break;
+ }
+ case TreeNode::INTEGER:
+ case TreeNode::FLOAT:
+ case TreeNode::BOOLEAN: // FALL THROUGH
+ {
+ break;
+ }
+ }
+
+ for( TreeNode::ConstIterator it = node->CBegin(), endIt = node->CEnd(); it != endIt; ++it )
+ {
+ const TreeNode::KeyNodePair& pair = *it;
+ CreateFontStyleMap( &pair.second, map );
+ }
+}
+
+/**
+ * @brief Parses the font's style string.
+ *
+ * @param[in] style The font's style string.
+ * @param[out] map A map with the font's style parameters.
+ *
+ */
+void ParseFontStyleString( const std::string& style, Property::Map& map )
+{
+ Toolkit::JsonParser parser = Toolkit::JsonParser::New();
+
+ if( parser.Parse( style ) )
+ {
+ const TreeNode* const node = parser.GetRoot();
+
+ CreateFontStyleMap( node, map );
+ }
+}
+
+void SetFontStyleProperty( ControllerPtr controller, const Property::Value& value )
+{
+ if( controller )
+ {
+ const std::string style = value.Get< std::string >();
+
+ // Stores the string to be recovered by the GetFontStyleProperty() function.
+ controller->SetDefaultFontStyle( style );
+
+ // Parses and applies the style.
+ Property::Map map;
+ ParseFontStyleString( style, map );
+
+ if( !map.Empty() )
+ {
+ /// Width key
+ Property::Value* widthValue = map.Find( WIDTH_KEY );
+
+ if( widthValue )
+ {
+ const std::string widthStr = widthValue->Get<std::string>();
+
+ FontWidth width = TextAbstraction::FontWidth::NORMAL;
+ if( Scripting::GetEnumeration< FontWidth >( widthStr.c_str(),
+ FONT_WIDTH_STRING_TABLE,
+ FONT_WIDTH_STRING_TABLE_COUNT,
+ width ) )
+ {
+ if( controller->GetDefaultFontWidth() != width )
+ {
+ controller->SetDefaultFontWidth( width );
+ }
+ }
+ }
+ else
+ {
+ controller->SetDefaultFontWidth( TextAbstraction::FontWidth::NORMAL );
+ }
+
+ /// Weight key
+ Property::Value* weightValue = map.Find( WEIGHT_KEY );
+
+ if( weightValue )
+ {
+ const std::string weightStr = weightValue->Get<std::string>();
+
+ FontWeight weight = TextAbstraction::FontWeight::NORMAL;
+ if( Scripting::GetEnumeration< FontWeight >( weightStr.c_str(),
+ FONT_WEIGHT_STRING_TABLE,
+ FONT_WEIGHT_STRING_TABLE_COUNT,
+ weight ) )
+ {
+ if( controller->GetDefaultFontWeight() != weight )
+ {
+ controller->SetDefaultFontWeight( weight );
+ }
+ }
+ }
+ else
+ {
+ controller->SetDefaultFontWeight( TextAbstraction::FontWeight::NORMAL );
+ }
+
+ /// Slant key
+ Property::Value* slantValue = map.Find( SLANT_KEY );
+
+ if( slantValue )
+ {
+ const std::string slantStr = slantValue->Get<std::string>();
+
+ FontSlant slant = TextAbstraction::FontSlant::NORMAL;
+ if( Scripting::GetEnumeration< FontSlant >( slantStr.c_str(),
+ FONT_SLANT_STRING_TABLE,
+ FONT_SLANT_STRING_TABLE_COUNT,
+ slant ) )
+ {
+ if( controller->GetDefaultFontSlant() != slant )
+ {
+ controller->SetDefaultFontSlant( slant );
+ }
+ }
+ }
+ else
+ {
+ controller->SetDefaultFontSlant( TextAbstraction::FontSlant::NORMAL );
+ }
+ }
+ }
+}
+
+void GetFontStyleProperty( ControllerPtr controller, Property::Value& value )
+{
+ if( controller )
+ {
+ value = controller->GetDefaultFontStyle();
+ }
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__
+#define __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/scripting/scripting.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/text-controller.h>
+#include <dali-toolkit/internal/text/text-definitions.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+const Scripting::StringEnum FONT_WIDTH_STRING_TABLE[] =
+{
+ { "ultra-condensed", TextAbstraction::FontWidth::ULTRA_CONDENSED },
+ { "extra-condensed", TextAbstraction::FontWidth::EXTRA_CONDENSED },
+ { "condensed", TextAbstraction::FontWidth::CONDENSED },
+ { "semi-condensed", TextAbstraction::FontWidth::SEMI_CONDENSED },
+ { "normal", TextAbstraction::FontWidth::NORMAL },
+ { "semi-expanded", TextAbstraction::FontWidth::SEMI_EXPANDED },
+ { "expanded", TextAbstraction::FontWidth::EXPANDED },
+ { "extra-expanded", TextAbstraction::FontWidth::EXTRA_EXPANDED },
+ { "ultra-expanded", TextAbstraction::FontWidth::ULTRA_EXPANDED },
+};
+const unsigned int FONT_WIDTH_STRING_TABLE_COUNT = sizeof( FONT_WIDTH_STRING_TABLE ) / sizeof( FONT_WIDTH_STRING_TABLE[0] );
+
+const Scripting::StringEnum FONT_WEIGHT_STRING_TABLE[] =
+{
+ { "thin", TextAbstraction::FontWeight::THIN },
+ { "ultra-light", TextAbstraction::FontWeight::ULTRA_LIGHT },
+ { "extra-light", TextAbstraction::FontWeight::EXTRA_LIGHT },
+ { "light", TextAbstraction::FontWeight::LIGHT },
+ { "demi-light", TextAbstraction::FontWeight::DEMI_LIGHT },
+ { "semi-light", TextAbstraction::FontWeight::SEMI_LIGHT },
+ { "book", TextAbstraction::FontWeight::BOOK },
+ { "normal", TextAbstraction::FontWeight::NORMAL },
+ { "regular", TextAbstraction::FontWeight::REGULAR },
+ { "medium", TextAbstraction::FontWeight::MEDIUM },
+ { "demi-bold", TextAbstraction::FontWeight::DEMI_BOLD },
+ { "semi-bold", TextAbstraction::FontWeight::SEMI_BOLD },
+ { "bold", TextAbstraction::FontWeight::BOLD },
+ { "ultra-bold", TextAbstraction::FontWeight::ULTRA_BOLD },
+ { "extra-bold", TextAbstraction::FontWeight::EXTRA_BOLD },
+ { "black", TextAbstraction::FontWeight::BLACK },
+ { "heavy", TextAbstraction::FontWeight::HEAVY },
+ { "extra-black", TextAbstraction::FontWeight::EXTRA_BLACK }
+};
+const unsigned int FONT_WEIGHT_STRING_TABLE_COUNT = sizeof( FONT_WEIGHT_STRING_TABLE ) / sizeof( FONT_WEIGHT_STRING_TABLE[0] );
+
+const Scripting::StringEnum FONT_SLANT_STRING_TABLE[] =
+{
+ { "normal", TextAbstraction::FontSlant::NORMAL },
+ { "roman", TextAbstraction::FontSlant::ROMAN },
+ { "italic", TextAbstraction::FontSlant::ITALIC },
+ { "oblique", TextAbstraction::FontSlant::OBLIQUE }
+};
+const unsigned int FONT_SLANT_STRING_TABLE_COUNT = sizeof( FONT_SLANT_STRING_TABLE ) / sizeof( FONT_SLANT_STRING_TABLE[0] );
+
+/**
+ * @brief Sets the font's style property.
+ *
+ * @param[in] controller The text's controller.
+ * @param[in] value The value of the font's style.
+ *
+ */
+void SetFontStyleProperty( ControllerPtr controller, const Property::Value& value );
+
+/**
+ * @brief Retrieves the font's style property.
+ *
+ * @param[in] controller The text's controller.
+ * @param[out] value The value of the font's style.
+ */
+void GetFontStyleProperty( ControllerPtr controller, Property::Value& value );
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__
#include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/object/type-registry-helper.h>
-#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/rendering-backend.h>
-#include <dali-toolkit/internal/text/layouts/layout-engine.h>
+#include <dali-toolkit/internal/controls/text-controls/text-font-style.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
#include <dali-toolkit/internal/text/text-view.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
}
case Toolkit::TextLabel::Property::FONT_STYLE:
{
- if( impl.mController )
- {
- const std::string fontStyle = value.Get< std::string >();
-
- if( impl.mController->GetDefaultFontStyle() != fontStyle )
- {
- impl.mController->SetDefaultFontStyle( fontStyle );
- }
- }
+ SetFontStyleProperty( impl.mController, value );
break;
}
case Toolkit::TextLabel::Property::POINT_SIZE:
}
case Toolkit::TextLabel::Property::FONT_STYLE:
{
- if( impl.mController )
- {
- value = impl.mController->GetDefaultFontStyle();
- }
+ GetFontStyleProperty( impl.mController, value );
break;
}
case Toolkit::TextLabel::Property::POINT_SIZE:
$(toolkit_src_dir)/controls/super-blur-view/super-blur-view-impl.cpp \
$(toolkit_src_dir)/controls/table-view/table-view-impl.cpp \
$(toolkit_src_dir)/controls/text-controls/text-field-impl.cpp \
+ $(toolkit_src_dir)/controls/text-controls/text-font-style.cpp \
$(toolkit_src_dir)/controls/text-controls/text-label-impl.cpp \
$(toolkit_src_dir)/controls/text-controls/text-selection-popup-impl.cpp \
$(toolkit_src_dir)/controls/text-controls/text-selection-toolbar-impl.cpp \
float xBearing; ///< The x bearing of the first glyph.
};
-const std::string EMPTY_STRING("");
-
} // namespace
namespace Dali
FontId defaultFontId = 0u;
if( NULL == mFontDefaults )
{
- defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
- EMPTY_STRING );
+ TextAbstraction::FontDescription fontDescription;
+ defaultFontId = mFontClient.GetFontId( fontDescription );
}
else
{
FontId defaultFontId = 0u;
if( NULL == mFontDefaults )
{
- defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
- EMPTY_STRING );
+ TextAbstraction::FontDescription fontDescription;
+ defaultFontId = mFontClient.GetFontId( fontDescription );
}
else
{
struct FontDefaults
{
FontDefaults()
- : mDefaultFontFamily(""),
- mDefaultFontStyle(""),
+ : mFontDescription(),
+ mFontStyle(),
mDefaultPointSize(0.0f),
mFontId(0u)
{
if( !mFontId )
{
Dali::TextAbstraction::PointSize26Dot6 pointSize = mDefaultPointSize*64;
- mFontId = fontClient.GetFontId( mDefaultFontFamily, mDefaultFontStyle, pointSize );
+ mFontId = fontClient.GetFontId( mFontDescription, pointSize );
}
return mFontId;
}
- std::string mDefaultFontFamily;
- std::string mDefaultFontStyle;
+ TextAbstraction::FontDescription mFontDescription;
+ std::string mFontStyle;
float mDefaultPointSize;
FontId mFontId;
};
mOperationsPending( NO_OPERATION ),
mMaximumNumberOfCharacters( 50 ),
mRecalculateNaturalSize( true ),
- mUserDefinedFontFamily( false)
+ mUserDefinedFontFamily( false )
{
mLogicalModel = LogicalModel::New();
mVisualModel = VisualModel::New();
Length mMaximumNumberOfCharacters; ///< Maximum number of characters that can be inserted.
bool mRecalculateNaturalSize:1; ///< Whether the natural size needs to be recalculated.
- bool mUserDefinedFontFamily:1; ///< Whether the Font family was Set by the user instead of being left as sytem default
+ bool mUserDefinedFontFamily:1; ///< Whether the Font family was set by the user instead of being left as sytem default.
};
} // namespace Text
const unsigned int POINTS_PER_INCH = 72;
const std::string EMPTY_STRING("");
+const unsigned int ZERO = 0u;
float ConvertToEven( float value )
{
mImpl->mFontDefaults = new FontDefaults();
}
- mImpl->mFontDefaults->mDefaultFontFamily = defaultFontFamily;
+ mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily;
mImpl->mUserDefinedFontFamily = userDefined;
+
// Clear the font-specific data
ClearFontData();
{
if( mImpl->mFontDefaults )
{
- return mImpl->mFontDefaults->mDefaultFontFamily;
+ return mImpl->mFontDefaults->mFontDescription.family;
}
return EMPTY_STRING;
}
-void Controller::SetDefaultFontStyle( const std::string& defaultFontStyle )
+void Controller::SetDefaultFontStyle( const std::string& style )
{
if( !mImpl->mFontDefaults )
{
mImpl->mFontDefaults = new FontDefaults();
}
- mImpl->mFontDefaults->mDefaultFontStyle = defaultFontStyle;
+ mImpl->mFontDefaults->mFontStyle = style;
+}
+
+const std::string& Controller::GetDefaultFontStyle() const
+{
+ if( mImpl->mFontDefaults )
+ {
+ return mImpl->mFontDefaults->mFontStyle;
+ }
+
+ return EMPTY_STRING;
+}
+
+void Controller::SetDefaultFontWidth( FontWidth width )
+{
+ if( !mImpl->mFontDefaults )
+ {
+ mImpl->mFontDefaults = new FontDefaults();
+ }
+
+ mImpl->mFontDefaults->mFontDescription.width = width;
// Clear the font-specific data
ClearFontData();
mImpl->RequestRelayout();
}
-const std::string& Controller::GetDefaultFontStyle() const
+FontWidth Controller::GetDefaultFontWidth() const
{
if( mImpl->mFontDefaults )
{
- return mImpl->mFontDefaults->mDefaultFontStyle;
+ return mImpl->mFontDefaults->mFontDescription.width;
}
- return EMPTY_STRING;
+ return TextAbstraction::FontWidth::NORMAL;
+}
+
+void Controller::SetDefaultFontWeight( FontWeight weight )
+{
+ if( !mImpl->mFontDefaults )
+ {
+ mImpl->mFontDefaults = new FontDefaults();
+ }
+
+ mImpl->mFontDefaults->mFontDescription.weight = weight;
+
+ // Clear the font-specific data
+ ClearFontData();
+
+ mImpl->mOperationsPending = ALL_OPERATIONS;
+ mImpl->mRecalculateNaturalSize = true;
+
+ mImpl->RequestRelayout();
+}
+
+FontWeight Controller::GetDefaultFontWeight() const
+{
+ if( mImpl->mFontDefaults )
+ {
+ return mImpl->mFontDefaults->mFontDescription.weight;
+ }
+
+ return TextAbstraction::FontWeight::NORMAL;
+}
+
+void Controller::SetDefaultFontSlant( FontSlant slant )
+{
+ if( !mImpl->mFontDefaults )
+ {
+ mImpl->mFontDefaults = new FontDefaults();
+ }
+
+ mImpl->mFontDefaults->mFontDescription.slant = slant;
+
+ // Clear the font-specific data
+ ClearFontData();
+
+ mImpl->mOperationsPending = ALL_OPERATIONS;
+ mImpl->mRecalculateNaturalSize = true;
+
+ mImpl->RequestRelayout();
+}
+
+FontSlant Controller::GetDefaultFontSlant() const
+{
+ if( mImpl->mFontDefaults )
+ {
+ return mImpl->mFontDefaults->mFontDescription.slant;
+ }
+
+ return TextAbstraction::FontSlant::NORMAL;
}
void Controller::SetDefaultPointSize( float pointSize )
if ( !mImpl->mUserDefinedFontFamily ) // If user defined font then should not update when system font changes
{
DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
- mImpl->mFontDefaults->mDefaultFontFamily=newDefaultFont;
+ mImpl->mFontDefaults->mFontDescription.family = newDefaultFont;
mImpl->UpdateModel( ALL_OPERATIONS );
mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
mImpl->mRecalculateNaturalSize = true;
const std::string& GetDefaultFontFamily() const;
/**
- * @brief Set the default font style.
+ * @brief Sets the font's style string.
*
- * @param[in] defaultFontStyle The default font style.
+ * @note The style set may be changed by the underlying font system. The string is stored to be recovered.
+ *
+ * @param[in] style The font's style string.
*/
- void SetDefaultFontStyle( const std::string& defaultFontStyle );
+ void SetDefaultFontStyle( const std::string& style );
/**
- * @brief Retrieve the default font style.
+ * @brief Retrieves the font's style.
*
- * @return The default font style.
+ * @return The font's style.
*/
const std::string& GetDefaultFontStyle() const;
/**
+ * @brief Sets the default font width.
+ *
+ * @param[in] width The font width.
+ */
+ void SetDefaultFontWidth( FontWidth width );
+
+ /**
+ * @brief Retrieves the default font width.
+ *
+ * @return The default font width.
+ */
+ FontWidth GetDefaultFontWidth() const;
+
+ /**
+ * @brief Sets the default font weight.
+ *
+ * @param[in] weight The font weight.
+ */
+ void SetDefaultFontWeight( FontWeight weight );
+
+ /**
+ * @brief Retrieves the default font weight.
+ *
+ * @return The default font weight.
+ */
+ FontWeight GetDefaultFontWeight() const;
+
+ /**
+ * @brief Sets the default font slant.
+ *
+ * @param[in] slant The font slant.
+ */
+ void SetDefaultFontSlant( FontSlant slant );
+
+ /**
+ * @brief Retrieves the default font slant.
+ *
+ * @return The default font slant.
+ */
+ FontSlant GetDefaultFontSlant() const;
+
+ /**
* @brief Set the default point size.
*
- * @param[in] defaultFontStyle The default point size.
+ * @param[in] pointSize The default point size.
*/
void SetDefaultPointSize( float pointSize );
// EXTERNAL INCLUDES
#include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
+#include <dali/devel-api/text-abstraction/font-list.h>
#include <dali/devel-api/text-abstraction/font-metrics.h>
#include <dali/devel-api/text-abstraction/glyph-info.h>
#include <dali/devel-api/text-abstraction/script.h>
{
typedef TextAbstraction::FontId FontId; ///< The unique identifier for a font face (generated by FontClient).
+typedef TextAbstraction::FontWidth::Type FontWidth; ///< The font's width.
+typedef TextAbstraction::FontWeight::Type FontWeight; ///< The font's weight.
+typedef TextAbstraction::FontSlant::Type FontSlant; ///< The font's slant.
typedef TextAbstraction::FontMetrics FontMetrics; ///< The metrics for a Font expressed in 26.6 fractional pixel format.
typedef TextAbstraction::PointSize26Dot6 PointSize26Dot6; ///< The point size in 26.6 fractional points.
typedef TextAbstraction::FaceIndex FaceIndex; ///< Used with fonts which allow several font faces.
FontId id = fontRun[i].fontId;
TextAbstraction::FontDescription fontDescription;
fontClient.GetDescription( id, fontDescription );
- o << "ID:" << id << ", " << fontDescription.family << " style:" << fontDescription.style << " size:" << (fontClient.GetPointSize(id) / 64);
+ o << "ID:" << id << ", " << fontDescription.family << " width: " << fontDescription.width << " weight: " << fontDescription.weight << " slant: " << fontDescription.slant << " size:" << (fontClient.GetPointSize(id) / 64);
if( i+1 < fontRun.Count() )
{
PLACEHOLDER_TEXT, ///< name "placeholder-text", The text to display when the TextField is empty and inactive, type STRING
PLACEHOLDER_TEXT_FOCUSED, ///< name "placeholder-text-focused", The text to display when the TextField is empty with key-input focus, type STRING
FONT_FAMILY, ///< name "font-family", The requested font family, type STRING
- FONT_STYLE, ///< name "font-style", The requested font style e.g. Regular/Italic, type STRING
+ FONT_STYLE, ///< name "font-style", The requested font style, type STRING
POINT_SIZE, ///< name "point-size", The size of font in points, type FLOAT
MAX_LENGTH, ///< name "max-length" The maximum number of characters that can be inserted, type INTEGER
EXCEED_POLICY, ///< name "exceed-policy" Specifies how the text is truncated when it does not fit, type INTEGER
RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend", The type or rendering e.g. bitmap-based, type INT
TEXT, ///< name "text", The text to display in UTF-8 format, type STRING
FONT_FAMILY, ///< name "font-family", The requested font family, type STRING
- FONT_STYLE, ///< name "font-style", The requested font style e.g. Regular/Italic, type STRING
+ FONT_STYLE, ///< name "font-style", The requested font style, type STRING
POINT_SIZE, ///< name "point-size", The size of font in points, type FLOAT
MULTI_LINE, ///< name "multi-line", The single-line or multi-line layout option, type BOOLEAN
HORIZONTAL_ALIGNMENT, ///< name "horizontal-alignment", The line horizontal alignment, type STRING, values "BEGIN", "CENTER", "END"
"label":
{
"point-size":8,
- "font-style":"Light"
+ "font-style":"{\"weight\":\"light\"}"
}
},
"scrollview":
"label":
{
"point-size":8,
- "font-style":"Light"
+ "font-style":"{\"weight\":\"light\"}"
}
},
"scrollview":
--- /dev/null
+<!--
+/**-->
+
+# Font Selection {#font-selection}
+
+By default TextLabel or TextField will automatically select a suitable font from the platform.
+Typically fonts do not support all scripts, for example Latin fonts often do not provide Arabic glyphs.
+Therefore you should expect the text control to select different fonts for each script.
+
+Alternatively a font may be requested using either or all of FONT_FAMILY, FONT_STYLE, and POINT_SIZE properties:
+
+- FONT_FAMILY
+ Is a string with the font's family name. i.e. *FreeSerif*
+- FONT_STYLE
+ Is a json formatted string with the font's style. Possible *key, value* pairs are:
+ + *width* Modifies the space between glyphs. Possible values are:
+ - *ultra-condensed*
+ - *extra-condensed*
+ - *condensed*
+ - *semi-condensed*
+ - *normal*
+ - *semi-expanded*
+ - *expanded*
+ - *extra-expanded*
+ - *ultra-expanded*
+ + *weight* Modifies the thickness or darkness of the glyphs. Possible values are:
+ - *thin*
+ - *ultra-light*
+ - *extra-light*
+ - *light*
+ - *demi-light*
+ - *semi-light*
+ - *book*
+ - *normal*
+ - *regular*
+ - *medium*
+ - *demi-bold*
+ - *semi-bold*
+ - *bold*
+ - *ultra-bold*
+ - *extra-bold*
+ - *black*
+ - *heavy*
+ - *extra-black*
+ + *slant* Whether to use italics. Usually *italic* is a different font whilst the *oblique* has been generated by slanting the *normal* one. Possible values are:
+ - *normal*
+ - *roman* Same as *normal*
+ - *italic*
+ - *oblique*
+- POINT_SIZE
+ Is a float with the font's size in points. To get the point size from pixels, could use the formula: <em>point_size = 72 * pixels / vertical_dpi</em> where <em>vertical_dpi</em> is the device's vertical resolution in dots per inch.
+
+~~~{.cpp}
+// C++
+
+label.SetProperty( TextLabel::Property::FONT_FAMILY, "FreeSerif" );
+label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"bold\",\"slant\":\"italic\"}" );
+label.SetProperty( TextLabel::Property::POINT_SIZE, 12.0f );
+~~~
+
+~~~{.js}
+// JavaScript
+
+label.fontFamily = "FreeSerif";
+label.fontStyle = "{\"weight\":\"bold\",\"slant\":\"italic\"}";
+label.pointSize = 12;
+~~~
+
+However the text control will fall-back to using the default font, if the requested font does not support the required scripts.
+
+### Font Styles
+
+Setting a font size programmatically is not ideal for applications which support multiple screen resolutions etc.
+A more flexible approach is to prepare various JSON stylesheets, and request a different style for each platform:
+
+~~~{.cpp}
+// C++
+StyleManager styleManager = StyleManager::Get();
+styleManager.RequestThemeChange( "example-path/example.json" );
+~~~
+
+To change the font for standard text controls, this JSON syntax can be used:
+
+~~~{.json}
+{
+ "styles":
+ {
+ "textlabel":
+ {
+ "font-family":"FreeSerif",
+ "font-style":"{\"weight\":\"bold\",\"slant\":\"italic\"}",
+ "point-size":8
+ }
+ }
+}
+~~~
+
+However the same point-size is unlikely to be suitable for all text controls in an application.
+To set custom sizes simply set a "style name" for each case, and then provide a style override in JSON:
+
+~~~{.cpp}
+ // C++
+
+ label.SetProperty( Control::Property::STYLE_NAME, "custom" );
+~~~
+~~~{.js}
+ // JavaScript
+
+ label.styleName = "custom"';
+~~~
+
+~~~{.json}
+{
+ "styles":
+ {
+ "textlabel":
+ {
+ "font-family":"FreeSerif",
+ "font-style":"{\"weight\":\"bold\",\"slant\":\"italic\"}",
+ "point-size":8
+ },
+
+ "custom":
+ {
+ "point-size":10
+ }
+ }
+}
+~~~
+
+In the example above, standard text labels will have point-size 8, and "custom" labels will have point-size 10.
+
+*/
### Font Selection
-TextField will automatically select a suitable fonts, in the same was as TextLabel.
-The preferred font can also be selected from a JSON stylesheet:
-
-~~~{.json}
-{
- "styles":
- {
- "textfield":
- {
- "font-family":"Arial",
- "font-style":"Regular",
- "point-size":8
- }
- }
-}
-~~~
+By default TextField will automatically select a suitable font from the platform. However, a different font could be selected. See the [Font Selection](@ref font-selection) section for more details.
### Text Alignment
### Font Selection
-By default TextLabel will automatically select a suitable font from the platform.
-Typically fonts do not support all scripts, for example Latin fonts often do not provide Arabic glyphs.
-Therefore you should expect TextLabel to select different fonts for each script.
-
-Alternatively a font may be requested using either or all of FONT_FAMILY, FONT_STYLE, and POINT_SIZE properties:
-
-~~~{.cpp}
-// C++
-
-label.SetProperty( TextLabel::Property::FONT_FAMILY, "HelveticaNue" );
-label.SetProperty( TextLabel::Property::FONT_STYLE, "Regular" );
-label.SetProperty( TextLabel::Property::POINT_SIZE, 12.0f );
-~~~
-
-~~~{.js}
-// JavaScript
-
-label.fontFamily = "HelveticaNue";
-label.fontStyle = "Regular";
-label.pointSize = 12;
-~~~
-
-However the TextLabel will fall-back to using the default font, if the requested font does not support the required scripts.
-
-### Font Styles
-
-Setting a font size programmatically is not ideal for applications which support multiple screen resolutions etc.
-A more flexible approach is to prepare various JSON stylesheets, and request a different style for each platform:
-
-~~~{.cpp}
-// C++
-StyleManager styleManager = StyleManager::Get();
-styleManager.RequestThemeChange( "example-path/example.json" );
-~~~
-
-To change the font for standard text labels, this JSON syntax can be used:
-
-~~~{.json}
-{
- "styles":
- {
- "textlabel":
- {
- "font-family":"Arial",
- "font-style":"Regular",
- "point-size":8
- }
- }
-}
-~~~
-
-However the same point-size is unlikely to be suitable for all labels in an application.
-To set custom sizes simply set a "style name" for each case, and then provide a style override in JSON:
-
-~~~{.cpp}
- // C++
-
- label.SetProperty( Control::Property::STYLE_NAME, "custom" );
-~~~
-~~~{.js}
- // JavaScript
-
- label.styleName = "custom"';
-~~~
-
-~~~{.json}
-{
- "styles":
- {
- "textlabel":
- {
- "font-family":"Arial",
- "font-style":"Regular",
- "point-size":8
- },
-
- "custom":
- {
- "point-size":10
- }
- }
-}
-~~~
-
-In the example above, standard text labels will have point-size 8, and "custom" labels will have point-size 10.
+By default TextLabel will automatically select a suitable font from the platform. However, a different font could be selected. See the [Font Selection](@ref font-selection) section for more details.
### Text Alignment