在 Direct3D 中填充文本轮廓
我很惊讶谷歌并没有对此做出太多说明。
我正在使用 Direct3D 创建一个简单的 CAD 查看器。由于其本质(缩放功能等),文本元素必须是矢量文本;我不能使用带纹理的聚合物。
我已经调用 gdi32.dll 来获取字形并从直线和贝塞尔曲线创建相当合理的文本轮廓,但是文本不是实心的,并且点不一定以任何方式规则。封闭字符(b、p、o、A 等)实际上具有多个单独的轮廓。
因此,我不能只是将点射入顶点缓冲区并指定原始类型。
目前我所能做的就是将轮廓渲染为线条,从而产生空心文本。
谁能建议一个用轮廓渲染固体矢量文本的好策略?
请注意,我将贝塞尔曲线插入点列表中(很多人使用着色器/巫术)。
I'm suprised that Google doesn't shed much light on this.
I'm creating a simple CAD viewer using Direct3D. Because of it's nature (zoom functionality etc) text elements must be vector text; I can't use textured polys.
I've called into gdi32.dll to get the glyphs and create quite reasonable text outlines from straight lines and bezier curves, however the text isn't solid and the points aren't necessarily regular in any way. Enclosing characters (b, p, o, A, etc) actually have more than one seperate outline.
As a consequence, I can't just shoot the points into a vertex buffer and specify a primitive type.
All I can do at the moment is render the outlines as line strips, resulting in hallow text.
Can anyone suggest a good strategy for rendering solid vector text with their outlines?
Note that I interpolate the bezier curves into point lists (A lot of people use shaders/witchcraft).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有提及您正在使用的 DirectX 版本,而是提及了实用程序函数 D3DXCreateText 将为任何 TrueType 字体的给定文本创建 3D 网格。如果您想要 2D 版本,只需使用无挤压或最少挤压以及直线正交投影即可。
如果您需要明确的轮廓,则可以 (a) 将此方法与已有的轮廓结合起来,(b) 以稍微不同的比例绘制文本两次(取决于当前缩放级别)或 (c) 使用着色器绘制像素完美的轮廓。
您所追求的确切外观和感觉的屏幕截图可能会有所帮助。我的 CAD 图纸都是纯文本,没有轮廓。
You don't mention what version of DirectX you are using, but the utility function D3DXCreateText will create a 3D mesh for a given text in any TrueType font. If you want a 2D version, simply use no or minimal extrusion, and straight-on orthogonal projection.
If you need explicit outlines, you might be able to either (a) combine this approach with the Outline you already have, (b) draw the text twice at a slightly different scale (depending on current zoom level) or (c) use shaders to draw a pixel-perfect outline.
A screenshot of the exact look-and-feel you are after might help. My CAD drawings all have solid text, no outlines.
我正在使用 D3DXCreateText(Win32、DX9)创建文本网格。它们旋转得很好。然而,无论 DC 中选择的字体高度如何,它们似乎总是具有相同的大小。
较小字符中的网格线会出现锯齿,并且在没有多重采样的情况下在视频卡上看起来不太好。
I am creating text meshes with D3DXCreateText (Win32, DX9). They rotate nicely. However, they always seem to be the same size regardless of the height of the font that has been selected in the DC.
The mesh lines in smaller characters are aliased and don't look good on video cards without multisampling.