テキスト描画
Description説明
The simplest way to draw text with Candera is using a TextNode2D, a 3D text widget from でテキストを描画する最も簡単な方法は、TextNode2D、CGI Studio Widget Library,Library orの the3D テキスト ウィジェット、または 2D TextBrush effect. Refer to:効果を使用することです。参照する:
To learn about how to use Candera::TextNode2D, please refer to the following section:の使用方法については、次のセクションを参照してください。
To learn about details, how to use the Candera TextEngine interface directly, refer to the following chapters.インターフェイスを直接使用する方法の詳細については、次の章を参照してください。
Chapters章
Using Candera::TextNode2D の使用
Chapters章
Overview概要
TextNode2D representsは、高速テキスト aレンダリングに特化した RenderNode specialized for fast text rendering.を表します。
Text and style have to be provided. In addition, it requires aテキストとスタイルを提供する必要があります。さらに、レンダリング用の BitmapBrush effect効果と、関連付けられた forBitmapBrush rendering効果によってレンダリングされる画像の生成に使用されるCandera::TextNodeRendererオブジェクトが必要です。
Candera::TextNodeRenderer の4 objectつの実装が利用可能で、それぞれが既存のCandera::TextBrushレンダリング usedコンセプト for(ビットマップ、サーフェス、グリフ、およびグリフ generatingキャッシュ) theの images,1 whichつの willCacheType be then rendered by the associated BitmapBrush effect.オプションに対応しています。
Text layouting is supported by attaching a Candera::TextNode2DLayouter を to the node. It is responsible for arranging and truncating the associated text of a ノードにアタッチすることでサポートされます。Candera::TextNode2D. The default layouter implements both horizontal and vertical truncation.の関連テキストの配置と切り詰めを担当します。デフォルトのレイアウタは、水平方向と垂直方向の両方の切り捨てを実装しています。
Candera::TextNodeRenderer object is used for generating the correct images from provided text.オブジェクトは、提供されたテキストから正しい画像を生成するために使用されます。
The level cache strategies which apply for a Candera::TextNode2Dに適用されるレベル are described below:キャッシュ戦略を以下に説明します。
Bitmap:ビットマップ:very非常に大きなメモリlarge memory footprint, very large update times, small render timeフットプリント、非常に長い更新時間、短いレンダリング時間- Surface:
large大きなビデオvideoメモリmemory footprint, large update times, small render timeフットプリント、長い更新時間、短いレンダリング時間 - Glyph (
former以前の NoCache):smallメモリmemory footprint, small update times, very large render time.フットプリントが小さく、更新時間が短く、レンダリング時間が非常に長い。 - GlyphCache:
small小さいメモリmemory footprint, small update times, medium render timeフットプリント、短い更新時間、中程度のレンダリング時間 - GlyphAtlas:
small小さな (butしかしグローバルな)global)ビデオvideoメモリmemory footprint, small update times, small render time.フットプリント、短い更新時間、短いレンダリング時間。
-
Chooseパフォーマンスのバランスを取るために適切なキャッシュを選択してください。静的テキストを使用する場合はビットマップまたはサーフェスtheレンダリングappropriate cache for a balance in performance. It is recommended to use either Bitmap or Surface rendering type when static texts are used, while for dynamic texts,タイプを使用することをお勧めしますが、動的テキストの場合は GlyphCacheis recommended.を使用することをお勧めします。
Please consider that onlyCandera::TextNode2Dには BitmapBrush type effects apply to a Candera::TextNode2D. In case other effects are used nothing will be rendered. The text appearance can be altered by the type of effect chosen, either by modifying the in-place effectsタイプのエフェクトのみが適用されることを考慮してください。他の効果が使用されている場合、何もレンダリングされません。テキストの外観は、インプレース効果 (color, mask, 色、マスク、HSL transformations,変換など) etc.) or by changing blending effects.を変更するか、ブレンド効果を変更することによって、選択した効果の種類によって変更できます。
List of使用できる BitmapBrush effects which can be used are described below:効果のリストを以下に示します。
- Candera::BitmapBrushBlend :
Outputsビットマップaイメージを出力し、ストアbitmap image, and blend it with the store buffer.バッファーとブレンドします。 - Candera::BitmapBrushColorBlend :
Outputビットマップaイメージを出力し、色を調整して、ストアbitmap image, modulate the color, and blend it with the store buffer.バッファーとブレンドします。 - Candera::BitmapBrushColorMaskBlend :
Outputビットマップaイメージを出力し、色を調整し、アルファbitmapマスクを適用して、ストアimage, modulate the color, apply an alpha mask, and blend it with the store buffer.バッファーとブレンドします。 - Candera::BitmapBrushHslBlend :
Outputビットマップa bitmap image, apply aイメージを出力し、HSLtransformation,変換を適用して、ストアand blend it with the store buffer.バッファーとブレンドします。 - Candera::BitmapBrushMaskBlend :
Outputビットマップaイメージを出力し、アルファbitmapマスクを適用して、ストアimage, apply an alpha mask, and blend it with the store buffer.バッファーとブレンドします。 - Candera::BlurBitmapBrushBlend :
Outputぼかしとアルファaブレンドのビットマップblurred and alpha blended bitmap image.イメージを出力します。 - Candera::MirrorBitmapBrushBlend :
Output出力にはビットマップincludes the bitmap image and it's reflection.イメージとその反射が含まれます。 - Candera::ShadowBitmapBrushBlend :
Outputシャドウ/グローとイメージaアルファshadowedブレンドの両方で、シャドウまたはグローorビットマップglowing bitmap image, both shadow/glow and image alpha blended.イメージを出力します。 - Candera::ShearBitmapBrushBlend :
Output a sheared image from the original one.元の画像からせん断された画像を出力します。
-
Not allすべての BitmapBrusheffects have the効果でColorproperty available. Default color for aプロパティを使用できるわけではありません。TextNode2Dis white.のデフォルトの色は白です。
Candera::TextNode2DLayouter は、 is responsible for arranging and truncating the text associated to a Candera::TextNode2D.に関連付けられたテキストの配置と切り詰めを担当します。Candera:: TextNode2DLayouter から派生した Candera::DefaultTextNode2DLayouter, derived from Candera::TextNode2DLayouter, is used for text truncation. More details are provided in the following section.DefaultTextNode2DLayouterは、テキストの切り捨てに使用されます。詳細については、次のセクションで説明します。
Candera::TextNode2D Guidelinesガイドライン
The minimum necessary steps needed in order to render a TextNode2D are:をレンダリングするために最低限必要な手順は次のとおりです。
Create aTextNode2Dinstanceインスタンスを作成するSet aText:Text to be rendered.レンダリングするテキストを設定します。Set aレンダリングに使用する Style: Styleobject to be used for rendering.オブジェクトを設定します。DefineTextNodeRenderera TextNodeRenderer:を定義します: TextNodeRendererused for generating the correct images from provided text.は、提供されたテキストから正しい画像を生成するために使用されます。AttachBitmapBrusha効果のアタッチ: 関連する BitmapBrusheffect: The associated BitmapBrush effect is responsible for rendering the generated images.効果は、生成された画像のレンダリングを担当します。
Define node and effectノードと効果を定義する
Define a Candera::TextNode2D and the associatedと関連する BitmapBrush effect:効果を定義します。
TextNode2D* m_textNode;
BitmapBrushColorBlend::SharedPointer m_textNodeEffect;
Create node and effectノードとエフェクトを作成する
Create an instance of Candera::TextNode2D class by using Candera::TextNode2D::Create()メソッドを使用して、Candera::TextNode2D method:クラスのインスタンスを作成します。
m_textNode = TextNode2D::Create();
In similar way create the同様の方法で BitmapBrush effect and add this effect to the newly created 効果を作成し、この効果を新しく作成したCandera::TextNode2D:に追加します。
m_textNodeEffect = BitmapBrushColorBlend::Create(); m_textNode->AddEffect(m_textNodeEffect.GetPointerToSharedInstance());
Use Candera::TextNode2D::SetText() to specify the text to be rendered:を使用して、レンダリングするテキストを指定します。
Use Candera::TextNode2D::SetStyle()を使用してスタイル to specify the style object:オブジェクトを指定します。
m_textNode->SetText("TextNode2D");
CreateCandera::TextNode2D and set a ::SetTextNodeRenderer()メソッドを使用して、Candera::TextNodeRendererを作成し、 to Candera::TextNode2D using Candera::TextNode2D::SetTextNodeRenderer() method:に設定します。
m_textNode->SetTextNodeRenderer(&GlyphCacheTextNodeRenderer::GetInstance());
Finally, add the最後に、 textNode directly to a をCandera::Scene2D or a またはCandera::Group2D:に直接追加します。
m_textNodeGroup->AddChild(m_textNode);
Candera::TextNode2D Propertiesプロパティ
Changing the color of a Candera::TextNode2D is done through the associatedの色の変更は、関連する BitmapBrush effect. Depending on the effect use, not all効果によって行われます。エフェクトの使用によっては、すべての BitmapBrush effectsエフェクトがカラー expose a color property. In this case, the rendered text will be white.プロパティを公開するわけではありません。この場合、レンダリングされたテキストは白になります。
m_textNodeEffect->GetColorEffect().Color().Set(Color(0.0f, 0.0f, 0.0f, 1.0f));
Textテキストの配置は、 alignment is realized through the layouter properties of the ,のレイアウター meaningプロパティによって実現されます。つまり、レイアウター内の位置と thatCandera the position inside a layouter, as well as text position inside the Candera:::TextNode2D will now be changed by the same内のテキストの位置は、同じ Candera::TextNode2DLayouter::SetHorizontalAlignment(SetHorizontalAlignment() andによって変更されます。 Candera::TextNode2DLayouter::SetHorizontalAlignment(SetHorizontalAlignment() methodsメソッドはレイアウタです。提供されたレイアウト theオプションとは異なるテキスト位置が必要な場合は、 layouter. In case it in necessary to have a different text position than the provided layouting options, it is possible to nest をネストして、内側の andTextNode set different alignment values for the inner TextNode.に異なる配置値を設定することができます。
TextNode2DLayouter::SetHorizontalAlignment(*m_textNode, Candera::HLeft);
TextNode2DLayouter::SetVerticalAlignment(*m_textNode, Candera::VTop);
Candera::TextNode2D が提供する切り捨てタイプは provides1 only one truncation type - in case truncation is needed, the text gets cut and trailing ellipsis are added to fit the space. Truncation is not supported by default. For this, theつだけです。切り捨てが必要な場合、テキストは切り取られ、スペースに合わせて末尾の省略記号が追加されます。デフォルトでは、切り捨てはサポートされていません。このためには、 Candera::DefaultTextNode2DLayouter needs to be attached to をCandera::TextNode2Dにアタッチする必要があり(以下のスニペットを参照)、テキストのサイズがCandera::TextNode2DTextNode2Dの指定された (see snippet below) and the text will be automatically truncated whenever the size of the text no longer fits in the specified Layout Size property of Candera::TextNode2D. Bounding rectangle size is not taken in account when performing text truncations.プロパティに収まらなくなると、テキストは自動的に切り捨てられます。テキストの切り捨てを実行するとき、境界四角形のサイズは考慮されません。
m_textNode->SetLayouter(&TextNode2DLayouter::GetDefault());
MultilineTextNode2D layouting is enabled by default for a TextNode2D. This property can be enabled/disabled using では、複数行のレイアウトがデフォルトで有効になっています。このプロパティは、Candera::TextNode2DLayouter::SetMultiLineEnabled() method.メソッドを使用して有効/無効にすることができます。
TextNode2D では、Wordwrap is not enabled by default for a TextNode2D. This property can be enabled/disabled using はデフォルトでは有効になっていません。このプロパティは、Candera::TextNode2DLayouter::SetWordWrapEnabled() method.メソッドを使用して有効/無効にすることができます。
Glyphグリフ based height computation is still done, but it is not used for layouting. The rectangle in which the text is layouted, if ベースの高さの計算は引き続き行われますが、レイアウトには使用されません。Size isが (-1;-1), will be the one measured with oldの場合、テキストが配置される四角形は、古い TextBrushConstantHeight option. The オプションで測定されたものになります。TextBrushActualHeight is always used for retrieving the bounding rectangle of the node, but it is also possible to retrieve the layout rectangle of the node tooは、ノードの境界矩形を取得するために常に使用されますが、ノードのレイアウト矩形を取得することもできます (see information about text length calculation below).以下のテキスト長の計算に関する情報を参照してください)。
The following methods are provided for retrieving the size of the rendered text:レンダリングされたテキストのサイズを取得するために、次のメソッドが提供されています。
Gettingレイアウトtheテキストlayouting text boxボックスの取得 (measured with constant height, cursor to cursor from left to right)一定の高さ、カーソルからカーソルへの左から右への測定):Getting境界テキストthe bounding text boxボックスの取得 (glyph limits vertically and horizontally)グリフの垂直方向と水平方向の制限):
Candera::SceneComposer の TextNode2D in SceneComposer
The new新しい TextNode2D isはツールボックス located in the Toolbox panel. In order to add a text to the scene, drag a パネルにあります。シーンにテキストを追加するには、TextNode from the panel to aをパネルから Scene2D node.ノードにドラッグします。

FromTextNode theの Properties[プロパティ] panelパネルから、レンダリングに必要なプロパティ of( theText、Style TextNode, configure the necessary properties for rendering: Text), Style.を構成します。

Candera::TextNodeRenderer TextNode2D typeの of can be changed using the TextNodeRendererタイプは、Renderer property. Default value in プロパティを使用して変更できます。SceneComposer isのデフォルト値は Bitmap.Bitmap です。

Candera::DefaultTextNode2DLayouter is attached by checking は、Enable Text Layouting.をチェックすることでアタッチされます。プロパティ Additionalパネルには、追加のレイアウタ layouter properties are exposed in the Properties Panel:プロパティが表示されます。
Multi line複数行 (enabled by default)デフォルトで有効)Word wrapワードラップ (disabled by default)デフォルトでは無効)
-
For切り捨てを行うには、[テキストtruncationレイアウトを有効にする]to occur,Enable Text Layoutingproperty needs to be enabled.プロパティを有効にする必要があります。

When a TextNode2D is created, a が作成されると、Candera::BitmapBrushColorBlendが自動的にノードに関連付けられ、テキストの色のみを変更するために使用されます。ツールボックス is automatically associated with the node, which is used for changing text color only. Anyパネルの効果のリストにある BitmapBrush effect present in the list of effects from Toolbox Panel can be used for text rendering. The visual appearance of the text will be affected depending on the type of effect chosen.効果は、テキストのレンダリングに使用できます。テキストの視覚的な外観は、選択した効果の種類に応じて影響を受けます。

TextEngine Renderレンダリング Interface インターフェイス
Overview:概要: Renderレンダリング Interfaceインターフェース
Theテキストをレンダリングするためのメイン main interface to render text is the methodインターフェイスは、メソッドです。
-
Compareこのインターフェイスを、this interface also with the functional steps introduced in chapter.の章で紹介した機能ステップとも比較してください。
Textテキスト Renderレンダリング Contextコンテキスト
ACandera Candera:::TextRendering::TextRenderContext は、テキスト is required to define a target for text rendering i.e. where to render the text to.レンダリングのターゲット、つまりテキストのレンダリング先を定義するために必要です。
Configureビットマップをテキスト Bitmap as Target for Text Renderingレンダリングのターゲットとして構成する
A Candera::TextRendering::BitmapTextRenderContext can be used to draw text into a bitmap. So first of all the bitmap which shall be drawn needs to be defined withを使用して、テキストをビットマップに描画できます。したがって、まず、描画されるビットマップを次のように定義する必要があります
theレンダリングするビットマップを割り当てる Candera::TextRendering::BitmapTextRenderContext::SetBitmap()method to assign a bitmap to render to,メソッド、theテキストの色を定義する Candera::TextRendering::BitmapTextRenderContext::SetPenColor()method to define the text colorメソッドtheCandera::TextRendering::BitmapTextRenderContext::SetClipRect()method to set a clipping rectangle for the text.メソッドを使用して、テキストのクリッピング四角形を設定します。
BitmapTextRenderContext bmpRenderContext;
static_cast<void>(bmpRenderContext.SetBitmap(m_bitmap));
bmpRenderContext.SetPenColor(m_color);
Layoutingレイアウト Optionsオプション
TheCandera Candera:::TextRendering::LayoutingOptions は define the layout of the rendered text withレンダリングされたテキストのレイアウトを定義します
theCanderaCandera:::TextRendering::LayoutingOptions::SetHorizontalAlignment(SetHorizontalAlignment()andおよびCandera::TextRendering::LayoutingOptions::SetVerticalAlignment()methods to specify the text alignment,メソッドでテキストの配置を指定します。the複数行レイアウトと単一行レイアウトを切り替えるCanderaCandera:::TextRendering::LayoutingOptions::SetMultilineTextEnabled()メソッド。method to toggle multi line and single line layout.theCanderaCandera:::TextRendering::LayoutingOptions::SetLineSpacing()method to modify the space between lines of multi line text.メソッドを使用して、複数行のテキストの行間のスペースを変更します。theCanderaCandera:::TextRendering::LayoutingOptions::SetWordWrapEnabled()メソッドを使用して、複数行のテキストの自動ワードmethod to enable automatic word wrap for multi line text.ラップを有効にします。
See also:以下も参照してください。- その他のオプションについては、 Candera::TextRendering::LayoutingOptions を参照してください
for further options.。
Shaping Options成形オプション
TheCandera Candera:::TextRendering::ShapingOptions は、テキストを論理からディスプレイ define how the text shall be transformed from logical to display presentation. The usage of one of the constructors is recommended:プレゼンテーションに変換する方法を定義します。コンストラクターのいずれかを使用することをお勧めします。
- Candera::TextRendering::ShapingOptions::ShapingOptions(const StylePtr &style)
- Candera::TextRendering::ShapingOptions::ShapingOptions(const StylePtr &style, const CulturePtr &culture)
Textテキスト Propertiesプロパティ
TheCandera Candera:::TextRendering::TextProperties は、 simply define the text itself which shall be rendered.レンダリングされるテキスト自体を定義するだけです。
See also:以下も参照してください。the constructorコンストラクタCandera::TextRendering::TextProperties::TextProperties(const TChar *text, TextLength length).。
Fontフォント Metricsメトリックとテキスト and Text Sizes サイズ
Font Sizeフォントサイズ
InCanderaでは、フォント Candera the font sizeサイズ (respectivelyそれぞれのフォントの高さ) theをピクセル font height) has to be provided in pixel size. Note that in several word processing programs, like サイズで指定する必要があります。Microsoft Word,などのいくつかのワープロ fontsプログラムでは、フォントはポイント areサイズで定義されていることに注意してください。ピクセル definedサイズとポイント in point size. The conversion between pixel size and point size is calculated as followsサイズの間の変換は、次のように計算されます (see FreeType Glyph Conventionsグリフ規則):を参照)。
pixel_sizeピクセル サイズ =point_sizeポイント サイズ *resolution解像度 / 72
たとえば、 Microsoft Windows では、 e.g. defines for historical reasons a default resolution of歴史的な理由から 96 PPI (DPI). A font in のデフォルト解像度を定義しています。Microsoft Wordで定義されたポイント with defined point sizeサイズ 18 hasのフォントは、Canderaで定義されたピクセル the same height as the font defined in Candera with pixel sizeサイズ 24 (24 = 18 * 96/72).のフォントと同じ高さになります。
Fontフォント Metricsメトリック
Forフォントの場合、フォント aアセンダー、デバイス font,ピクセル単位のディセンダー値、フォント行の高さ、およびフォント文字の最大垂直送り量を記述する静的フォント staticメトリックが提供されます。 font metrics are provided describing font ascender, descender values in device pixel, the font line height and the maximum vertical advance of a font character: Candera::TextRendering::Font:Font ::GetMetrics()
TextRendering::Metrics metrics;
if (!m_font.GetMetrics(metrics)) {
return false;
}
Text Boundsテキスト境界
Further, the text boundsさらに、指定された文字列のテキスト境界 (width,幅、高さなど) height, etc.) of a given string can be retrieved by calling GetTextRectangle method of は、Candera::TextRendering::GlyphTextMeasureContextまたはCandera::TextRendering::CursorTextMeasureContextのGetTextRectangleメソッドを呼び出すことによって取得できます。
Candera::TextRendering::GlyphTextMeasureContext は、すべてのグリフ ビットマップによってカバーされる最小の表面に対応する長方形を構築します。この長方形の位置 ((左、上) 座標で表される) は、テキスト位置からオフセットできます。したがって、テキストをレンダリングするときは、このオフセットの逆数を使用してレイアウト オプションを構築する必要があります。
Candera::TextRendering::CursorTextMeasureContext は、.
Candera::TextRendering::GlyphTextMeasureContext builds a rectangle corresponding to the smallest surface covered by all the glyph bitmaps. The position of this rectangle( represented by (left, top) coordinates) can be offset from the text position. Therefore, when rendering the text, the Layouting Options should be constructed using the inverse of this offset.
Candera::TextRendering::CursorTextMeasureContext builds a rectangle corresponding to the whole surface swept by the cursor when moving while processing the text. The cursor is considered to be a segment of length equal to the style height. This rectangle does not usually have an offset and it contains the final advancement of the cursor.テキストの処理中に移動するときにカーソルが掃引するサーフェス全体に対応する長方形を作成します。カーソルは、スタイルの高さと同じ長さのセグメントと見なされます。通常、この四角形にはオフセットがなく、カーソルの最終的な前進が含まれます。
GlyphTextMeasureContext glyphContext;
static_cast<void>(textRenderer.Render(glyphContext, LayoutingOptions(), ShapingOptions(m_style), TextProperties(m_text)));
TextRect textBound = glyphContext.GetTextRectangle();
mTextStartPos.SetX(-textBound.GetPosition().GetX());
mTextStartPos.SetY(-textBound.GetPosition().GetY());
Int16 textWidth = textBound.GetWidth();
Int16 textHeight = textBound.GetHeight();
static_cast<void>(textRenderer.Render(bmpRenderContext, LayoutingOptions(mTextStartPos), ShapingOptions(m_style), TextProperties(m_text)));
Theレイアウト Layouting Options describe the layout of the text. The Shaping Options define how the text is shapedオプションは、テキストのレイアウトを記述します。整形オプションは、テキストの整形方法 (ligatures,合字、テキストの方向など) text direction, ..) and they also contain the style.を定義し、スタイルも含みます。
Simple単純なテキスト Text Rendering レンダリング
Rendering Simple Textシンプルなテキストのレンダリング
TheCandera Candera:::TextRendering::TextRenderer は、 provides the core function to render text.テキストをレンダリングするコア関数を提供します。
For単純なテキスト simple text rendering the レンダリングの場合、Candera::TextRendering::TextRenderer::Render() method is called. Besides the actual textメソッドが呼び出されます。実際のテキスト (typeTChar* TChar*)型) and theとターゲットとしての BitmapTextRenderContext as target, layouting and shaping can be specified.に加えて、レイアウトと整形を指定できます。
static_cast<void>(textRenderer.Render(bmpRenderContext, LayoutingOptions(mTextStartPos), ShapingOptions(m_style), TextProperties(m_text)));
Finally the image has to be updated to apply the changes.最後に、変更を適用するためにイメージを更新する必要があります。
bool success = m_textureImage->Update();
Character-Glyph Position Mapping 文字とグリフの位置のマッピング
Overview概要
Canderaテキスト text engine provides an interface which allows to map positions in character string to positions in glyph string. This feature can be useful for applications and widgets in order to perform various operations depending on the character position like, for instance, highlighting text.エンジンは、文字列の位置をグリフ文字列の位置にマッピングできるインターフェイスを提供します。この機能は、テキストのハイライトなど、文字の位置に応じてさまざまな操作を実行するために、アプリケーションやウィジェットで役立ちます。
Example例
For the convenience, we choose to improve the便宜上、この強調表示機能を使用して TextTextureWidget with this highlighting feature. The widget will highlight the text by rendering in red all the glyphs corresponding to the characters having the index in the interval を改善することにしました。m_startウィジェットは、間隔m_start and とm_end.のインデックスを持つ文字に対応するすべてのグリフを赤でレンダリングすることにより、テキストを強調表示します。
The character position information is accessible in the文字位置情報は、Candera::BitmapTextRenderContextクラスの Blit method of the Candera::BitmapTextRenderContext class. Consequently, this class should be derived and the メソッドでアクセスできます。したがって、このクラスを派生させ、Blit method overwritten as follows:メソッドを次のように上書きする必要があります。
class BitmapTextRenderContextSelection : public BitmapTextRenderContext
{
public:
BitmapTextRenderContextSelection(Int selectionStart, Int selectionEnd, Color color) : m_start(selectionStart), m_end(selectionEnd), m_color(color) {}
virtual void Blit(Int16 x, Int16 y, const GlyphBitmap& glyph);
private:
typedef BitmapTextRenderContext Base;
Color ComputeColorForCharPosition(TextPosition position);
Int m_start;
Int m_end;
Color m_color;
};
void BitmapTextRenderContextSelection::Blit(Int16 x, Int16 y, const GlyphBitmap& glyph){
SetPenColor(ComputeColorForCharPosition(glyph.characterPosition));
Base::Blit(x, y, glyph);
}
Color BitmapTextRenderContextSelection::ComputeColorForCharPosition(TextPosition position){
if(position >= m_start && position <= m_end){
return Color(255,0,0);
} else {
return m_color;
}
}
In TextTextureWidget::UpdateTextureImage(), useで、 the newly created class instead of :の代わりに新しく作成したクラスを使用します。
BitmapTextRenderContextSelection bmpRenderContext(m_selectionStart, m_selectionEnd, GetTextColorPrv());
Shortening Support For Bidirectional Text 双方向テキストの短縮サポート
Feature Overview機能の概要
Thisこの機能により、指定された表示領域に収まらない場合はいつでも双方向テキストが短縮されます。短縮を行うアルゴリズムは、右から左へのテキストの左から右へのテキストへのさまざまなレベルの埋め込み、およびその逆の埋め込みを処理できます。最後のチャンクのテキストの方向に応じて、短縮文字列は最後のフィッティング featureテキスト ensures that the bidirectional text shall be shortened whenever it does not fit into its designated display area. The algorithm which does the shortening can deal with different levels of embedding of right-to-left text in left-to-right text and vice versa. Depending on the text direction of the last chunk, the shortening string is inserted after the last fitting text segment, on the left or on the right end.セグメントの左端または右端に挿入されます。
You can take advantage of this feature by using one of the following, depending on the type of scene being rendered:レンダリングされるシーンのタイプに応じて、次のいずれかを使用して、この機能を利用できます。
| Candera::TextNode2D | - | |
| 3D | - |
TruncationTextNode2D using TextNode2Dを使用した切り捨て
Thisこの機能は、ノード featureパラメータの is[テキスト activeレイアウトを有効にする] only when the node parameter が有効になっている場合にのみアクティブになります。テキストのサイズがノードの指定されたEnable Text LayoutSize is enabled. The text will be automatically truncated whenever its size no longer fits in the specified Size property of the node. プロパティに収まらなくなると、テキストは自動的に切り捨てられます。TextNode2D providesは、スペースに合わせてテキストを切り取り、末尾の省略記号を追加するという切り捨て方法を only1 one truncation method, by cutting text and adding trailing ellipsis to fit the space.つだけ提供します。
TruncationTextTextureWidget using TextTextureWidgetを使用した切り捨て
Thisこの機能は、ウィジェット feature is active only when the widget parameter パラメーターTruncation method が is set to the Text value. The character(s) used for visual feedback of text shortening is configurable by setting the Truncation text property of the 値に設定されている場合にのみアクティブになります。テキスト短縮の視覚的フィードバックに使用される文字は、3D widget.ウィジェットの切り捨てテキストプロパティを設定することで構成できます。
Examples例
The以下の画像は、3 image below exemplifies three scenarios :つのシナリオを例示しています。
Shortening of the right-to-left text右から左へのテキストの短縮 (Arabic)アラビア語)Shortening of the left-to-right text左から右へのテキストの短縮 (Latin)ラテン語)Shortening of right-to-left text embedded in left-to-right text左から右へのテキストに埋め込まれた右から左へのテキストの短縮 (left-to-right and right-to-left)左から右および右から左)

Font Hinting フォントヒンティング
Overview概要
Fontフォント hintingヒンティングは、数学的な命令を使用してアウトライン is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid. This is done by interpolating the pixels in order to more clearly render the font. At low screen resolutions, hinting is critical for producing clear, legible text. It can be accompanied by antialiasing andフォントの表示を調整し、ラスタライズされたグリッドに合わせます。これは、フォントをより明確にレンダリングするためにピクセルを補間することによって行われます。画面の解像度が低い場合、明確で読みやすいテキストを生成するには、ヒントが重要です。アンチエイリアシングと (on液晶ディスプレイの場合) liquidサブピクセル crystal displays) subpixel rendering for further clarity.レンダリングを併用して、さらに明瞭にすることができます。
-
Theヒンティングはアウトラインフォントにのみ適用されるため、ビットマップhintingフォントとストロークapplies only tooutlinefonts so the bitmap fonts and the stroke fonts will not be affected by this feature.フォントはこの機能の影響を受けません。
Hintsヒントは通常、書体のデザイン areプロセス中にフォント usuallyエディターで作成され、フォントに埋め込まれます。一般に、グリフにヒントを与えるには created3 in a font editor during the typeface design process and embedded in the font. In general, there are three possible ways to hint a glyph:つの方法があります。
Theフォントには、ラスタライザーをガイドするためのヒントが含まれており、グリフのどの形状に特別な考慮が必要かを伝えます。ヒンティングfont contains hints to guide the rasterizer, telling it which shapes of the glyphs need special consideration. The hinting logic is partly in the font and partly in the rasterizer.ロジックの一部はフォントにあり、一部はラスタライザーにあります。The font contains exact instructionsフォントには、出力デバイスの解像度に応じてアウトラインのポイントを移動する方法に関する正確な指示 (alsoバイトコードとも呼ばれる)calledが含まれており、(アウトライン)bytecode)形状を意図的に歪ませて、適切にラスタライズされた結果を生成します。ヒントon how to move the points of its outlines, depending on the resolution of the output device, and which intentionally distort the (outline) shape to produce a well-rasterized result. The hinting logic is in the font; ideally, all rasterizers simply process these instructions to get the same result on all platforms.ロジックはフォントにあります。理想的には、すべてのラスタライザがこれらの命令を単純に処理して、すべてのプラットフォームで同じ結果を得ることができます。The font gets auto-hintedフォントは (at実行時に)run-time).自動ヒントを取得します。ヒンティングThe hinting logic is completely in the rasterizer. No hints in the font are used or needed; instead, the rasterizer scans and analyzes the glyphs to apply corrections by itself.ロジックは完全にラスタライザーに含まれています。フォントのヒントは使用または必要ありません。代わりに、ラスタライザーはグリフをスキャンして分析し、それ自体で修正を適用します。
Enabling Hintingヒントを有効にする
The hinting can be enabled or disabled by the means of the method Candera:メソッドCandera::TextRendering::Font::SetHintingEnabled(). When hinting is disabled, the glyphs may appear blurred, as you can see below. The text was rendered with a small size fontを使用して、ヒンティングを有効または無効にすることができます。ヒンティングを無効にすると、以下に示すように、グリフがぼやけて表示される場合があります。テキストは小さなサイズのフォント (9px) and then zoomed in:でレンダリングされ、ズームインされました。

EnablingAutoHint AutoHintを有効にする
The usage of the automatic hinter of the font driver can be controlled by calling the method Candera::TextRendering::Font::SetAutohintEnabled().メソッドを呼び出すことで、フォント Whenドライバーの自動ヒンターの使用を制御できます。自動ヒンターを無効にすると、フォントのネイティブ the automatic hinter is disabled either the native hinter of the font is used either the hinting is disabledヒンターが使用されるか、ヒンティングが無効になります (zoomed in image):拡大画像)。

Enabling Force AutoHint を有効にする
If特定のフォント a given font driver doesn't provide its own hinter, the auto-hinter is used by default. If a format-specific hinter is provided, it is still possible to use the auto-hinter by enabling it using the method ドライバーが独自のヒントを提供しない場合、デフォルトで自動ヒントが使用されます。Candera:フォーマット固有のヒントが提供されている場合でも、メソッドCandera::TextRendering::Font::SetForceAutohintEnabled() を.使用して有効にすることで、自動ヒントを使用することができます。
Hinting Modeヒントモード
Theドライバーのオートヒンターは、次のパラメーター driver(ヒンティング autohinterアルゴリズム) can be configured by calling the のいずれかを指定してCandera::TextRendering::Font::SetHintingMode()メソッドを呼び出すことで構成できます。 method with one of the following parameters(hinting algorithms):
- GlyphHinter::Normal :
normal標準のグレーレベルhinting, optimized for standard gray-level renderingレンダリング用に最適化された通常のヒンティング

- GlyphHinter::Light :
applies less corrections than normal hinting for better performanceパフォーマンスを向上させるために、通常のヒンティングよりも少ない修正を適用します

- GlyphHinter::Monochrome :
appropriate for monochrome renderingモノクロのレンダリングに適しています

- GlyphHinter::Lcd :
appropriate for horizontally decimated水平方向にデシメートされた LCDdisplaysディスプレイに適しています

- GlyphHinter::VerticalLcd :
appropriate for vertically decimated垂直方向にデシメートされた LCDdisplaysディスプレイに適しています

-
All modes exceptGlyphHinter::Monochromeuseを除くすべてのモードは、256levels of opacity.レベルの不透明度を使用します。
Code Exampleコード例
m_font1.SetHintingMode(GlyphHinter::Monochrome);
m_font2.SetHintingMode(GlyphHinter::Light);
Glyphグリフ Bitmap Formatビットマップ形式
Theグリフ outputレンダリング type of the glyph rendering process can be configured by calling the method プロセスの出力タイプは、メソッドCandera::TextRendering::Font::SetRequestedGlyphFormat()を呼び出して、次のレンダリング with one of the following render modes as parameters:モードのいずれかをパラメータとして設定できます。
- GlyphBitmap::Unknown :
format is unspecified形式が指定されていません - GlyphBitmap::Monochrome :
correspond1to 1-bit bitmapsビットのビットマップに対応 (two2levels of opacity)レベルの不透明度) - GlyphBitmap::Lcd :
format use with horizontally decimated水平方向にデシメートされた RGBorまたは BGRsub-pixelサブピクセル LCDdisplaysディスプレイで使用する形式 - GlyphBitmap::VerticalLcd :
format use with vertically decimated垂直方向にデシメートされた LCDdisplaysディスプレイで使用するフォーマット - GlyphBitmap::Grayscale :
formatフォーマットはグレースケールで、1isピクセルあたりgrayscale,1oneバイトです。これがデフォルトのレンダリングbyte per pixel; this is the default render modeモードです
Each上記の各レンダリング of the render modes above correspond to a specific type of scanline conversion performed on the outline.モードは、アウトラインに対して実行される特定の種類のスキャンライン変換に対応しています。
Code Exampleコード例
m_font1.SetRequestedGlyphFormat(GlyphBitmap::VerticalLcd);
m_font2.SetRequestedGlyphFormat(GlyphBitmap::Grayscale);
Monochromeモノクロ Renderレンダー Modeモード
Theモノクロ monochromeレンダリング renderモードでは、2 mode removes anti-aliasing because it's using only two levels of opacity and gives clearer appearance for small size fontsレベルの不透明度しか使用しないため、アンチエイリアスが削除され、小さなサイズのフォントがより鮮明に表示されます (noぼかしなし)。モノクロ blurring).レンダリング Pleaseモードとグレースケール seeレンダリング below a comparison between monochrome and grayscale render modes:モードの比較を以下に示します。


Anこのレンダリング anotherモードを使用するもう advantage1 ofつの利点は、1 usingビット形式であるため、グリフのメモリ this render mode is the smaller memory footprint for glyphs because of 1bit format.フットプリントが小さいことです。