如何在Flex Text Layout Framework ContainerController中只显示一个字母?
我正在尝试在我的 Flex 应用程序中实现删除缩写功能。由于文本布局框架不支持浮动,唯一已知的解决方案是创建链接在一起的附加容器,显示相同的文本流。这些容器的宽度和位置必须以这样的方式设置,使其假装是浮动的。
我对删除的首字母使用相同的解决方案。基本上,我正在创建三个容器,一个用于首字母(文本流中的第一个字母),另一个用于浮动文本,第三个用于在这两个容器下方显示文本。所有这些容器共享一个文本流。
我在强制控制器仅显示文本流中的一个字母并相应地调整其大小方面遇到了很大的问题,这样它就不会占用任何不必要的额外空间,也不会再添加任何文本。
使用 ContainerController.getContentBounds() 返回字母的整个精灵的大小(带有上升/下降的空白部分),而不是实际渲染字母的高度/宽度。我正在使用 textFlow.flowComposer.getLineAt(0).getTextLine().getAtomBounds(0),但我认为它仍然不对。另外,即使我为此尺寸设置容器,它有时也会在其中显示附加文本,尤其是对于较大的字体。请参阅屏幕:
替代文本 http://img97.imageshack.us/img97/6105/tlfissue .png
另外,如果我将宽度设置为比 contentBounds 少 1px,事情就会变得疯狂,容器会四处移动,定位时边距较大,等等。
我应该如何解决这个问题?这是 TLF/Player 中的错误吗?我能以某种方式修复它吗? 我可以检测字母的大小,或者使容器控制器自动调整大小以仅适合一个字母吗?
I'm trying to implement dropped initials feature into my Flex application. Since Text Layout Framework does not support floating, the only known solution is to create additional containers that will be linked together, displaying the same textflow. Width and positioning of these containers has to be set in such a way that it will pretend that it's float.
I'm using the same solution for dropped initials. Basically, I'm creating three containers, one for the initial letter (first letter in text flow), the other for text floating around, and the 3rd one to display text below these two. All these containers share one textflow.
I have big issues with forcing controller to display only one letter from the text flow, and size it accordingly, so that it wont take any unnecessary aditional space and won't get any more text into it.
Using ContainerController.getContentBounds() returns me size of whole sprite of the letter (with ascent/descent empty parts), not the height/width of the actual rendered letter. I'm using textFlow.flowComposer.getLineAt(0).getTextLine().getAtomBounds(0), but i think it's still not right. Also, even if I set container for this dimensions, it sometimes display additional text in it, especially for bigger fonts. See screen :
alt text http://img97.imageshack.us/img97/6105/tlfissue.png
Also, if I set width to just 1px less that contentBounds, things are going crazy, containers are moved around, positioned with big margins, etc.
How should I solve this? Is it a bug in TLF / Player? Can I fix it somehow?
Can I detect the size of the letter, or make containercontroller autosize to fit just one letter only?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要做的是将columnBreakAfter 设置为BreakStyle.ALWAYS。这意味着您的单个字母需要位于 ParagraphElement 内其自己的 SpanElement 中。
例子:
What you need to do is to set columnBreakAfter to BreakStyle.ALWAYS. This would mean that your single letter would need to be in its own SpanElement inside of of a ParagraphElement.
Example: