1: 2015-05-21 (木) 13:34:36 njf[4] [5] [6] | 現: 2015-05-22 (金) 00:24:43 njf[4] [7] [8] | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | test | + | 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); |
(This host) = https://njf.jp