ActionScriptで縦書きする場合、CPUレンダリングではTextBlock
クラスで可能です。
FeathersではTextBlockTextRendererクラスでTextBlock
をGPUレンダリングしてくれるのですが、2015年5月現在、まだ縦書きには対応していないようです。
しかし、Feathersのソースコードを一部変更すれば簡単に縦書き表示が可能となります。
大きく分けて3カ所修正が必要です。TextRotation.ROTATE_90が指定されているときは
- 行の幅を高さに修正
- 行のx座標を少し左に(そのままでは描画領域からはみ出すので)
- 中心寄せ、右寄せ、左寄せの計算をxからy、widthからheightに変更
です。
Feathers ver 2.1.1でその変更を行ったTextBlockTextRenderer.asは以下の添付ファイルで
使うときは以下のような感じで。
var textRenderer:TextBlockTextRenderer = new TextBlockTextRenderer(); var fontDescription:FontDescription = new FontDescription( MY_MAIN_FONT_NAME, FontWeight.NORMAL, FontPosture.NORMAL, FontLookup.EMBEDDED_CFF, RenderingMode.CFF, CFFHinting.NONE ); var ef:ElementFormat = new ElementFormat( fontDescription,fontSize, color ); ef.locale = "ja"; textRenderer.elementFormat = ef; textRenderer.width = width; textRenderer.height = height; textRenderer.wordWrap = true; textRenderer.lineRotation = TextRotation.ROTATE_90; textRenderer.text = "いろはにほへと ちりぬるを"; addChild(textRenderer);
Page Info | |
---|---|
Page Name : | Starling+Feathersで縦書き |
Page aliases : | None |
Page owner : | njf |
Can Read | |
Groups : | All visitors |
Users : | All visitors |
Can Edit | |
Groups : | All visitors |
Users : | All visitors |
Counter: 1551,
today: 1,
yesterday: 2
Princeps date: 2015-05-21 (Thu) 13:34:36
Last-modified: 2015-05-21 (Thu) 16:24:43 (JST) (2646d) by njf