简体   繁体   English

如何将使用 draw(rect:) 绘制的字符转换为字符串?

[英]How can i convert cahracters drawn with draw(rect:) into strings?

在此处输入图像描述 I am working on a project where I need to draw alphabetic characters using draw(rect:) method.我正在做一个项目,我需要使用 draw(rect:) 方法绘制字母字符。 Until now I am able to draw these hand-drawn characters but I am unable to export these characters as strings.到目前为止,我能够绘制这些手绘字符,但我无法将这些字符导出为字符串。 I tried to get the drawn alphabets using screenshots and OCR but all other algorithms just detect the test and resample the text to redefined shapes whereas, i need to convert the drawn character as it to the string or ".ttf".我尝试使用屏幕截图和 OCR 获取绘制的字母,但所有其他算法只是检测测试并将文本重新采样为重新定义的形状,而我需要将绘制的字符转换为字符串或“.ttf”。

If your goal is to have the user draw characters and turn their drawings into a font, you have your work cut out for you.如果您的目标是让用户绘制字符并将他们的绘图转换为字体,那么您的工作已经完成。

I suggest you have the user draw one character at a time.我建议您让用户一次绘制一个字符。 Since you know which one they are drawing, you know what character you're getting.既然你知道他们在画哪一个,你就知道你得到的是什么角色。

You'd then need to convert their raw gestures into a series of bezier curves.然后,您需要将他们的原始手势转换为一系列贝塞尔曲线。 Then you'd need to encode those bezier curves into a glyph in the font you are building.然后,您需要将这些贝塞尔曲线编码为您正在构建的字体中的字形。

I've never figured out how to generate Bezier curves from points along the curve, since the middle control points for a Bezier curve don't lie along the curve.我从来没有弄清楚如何从曲线上的点生成贝塞尔曲线,因为贝塞尔曲线的中间控制点并不沿着曲线。 I've read that it's possible however.我读过这是可能的。

As to encoding the curves into a glyph in TrueType font format, I got nuttin'.至于将曲线编码为 TrueType 字体格式的字形,我疯了。 I suggest googling it.我建议谷歌搜索它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获得将在其中绘制子字符串的绑定矩形? - How could I get the bound rect in which a substring will be drawn? iOS中的CoreGraphics:如何保存CGContext中绘制的路径并在下一个绘制调用中检索它们? - CoreGraphics in iOS: how can I save the paths drawn in a CGContext and retrieve them in the next draw call? 如何删除iOS中绘制的圆圈? - How can i remove the circle drawn in iOS? Swift 3-NSString.draw(in:rect,withAttributes :) —文本未在预期的位置绘制 - Swift 3 - NSString.draw(in: rect, withAttributes:) — Text not being drawn at expected point draw(_ rect:CGRect)实际如何工作? - How draw(_ rect: CGRect) actually work? 如何绘制聊天气泡的矩形 - How to draw rounded rect for chat bubble iOS如何将图像的一部分绘制到特定的矩形? - iOS how to draw a part of image to a specific rect? 如何在具有此阴影效果的UIImage中绘制矩形? - how to draw a rect in UIImage with this shadow effect? 如何以不同的分辨率计算UIImage的裁剪尺寸(rect) - How can I calculate the crop size (rect) of the UIImage with different resolution 如何检测对UITableViewCell的特定区域/区域的点击? - How can I detect taps to a specific area/rect of a UITableViewCell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM