当前位置: 首页 > news >正文

dwg2SVG 转化后文字丢失分析

        libredwg开源项目中的dwg2SVG命令可以将dwg文件转换成svg文件,实际使用发现转化后的svg相对于dwg存在mtext字段丢失问题,对代码进行分析发现代码中不处理DWG_TYPE_MTEXT字段,所以存在文字不显示的情况。

static int
output_object (Dwg_Object *obj)
{int num = 1;if (!obj){fprintf (stderr, "object is NULL\n");return 0;}switch (obj->fixedtype){case DWG_TYPE_INSERT:output_INSERT (obj);break;case DWG_TYPE_LINE:output_LINE (obj);break;case DWG_TYPE_CIRCLE:output_CIRCLE (obj);break;case DWG_TYPE_TEXT:output_TEXT (obj);break;case DWG_TYPE_ARC:output_ARC (obj);break;case DWG_TYPE_POINT:output_POINT (obj);break;case DWG_TYPE_ELLIPSE:output_ELLIPSE (obj);break;case DWG_TYPE_SOLID:output_SOLID (obj);break;case DWG_TYPE__3DFACE:output_3DFACE (obj);break;case DWG_TYPE_POLYLINE_2D:output_POLYLINE_2D (obj);break;case DWG_TYPE_LWPOLYLINE:output_LWPOLYLINE (obj);break;case DWG_TYPE_RAY:output_RAY (obj);break;case DWG_TYPE_XLINE:output_XLINE (obj);break;case DWG_TYPE_SEQEND:case DWG_TYPE_VIEWPORT:break;default:num = 0;if (obj->supertype == DWG_SUPERTYPE_ENTITY)fprintf (stderr, "%s ignored\n", obj->name);// all other non-graphical objects are silently ignoredbreak;}return num;
}
// TODO: MTEXT
static void
output_TEXT (Dwg_Object *obj)
{Dwg_Data *dwg = obj->parent;Dwg_Entity_TEXT *text = obj->tio.entity->tio.TEXT;char *escaped;const char *fontfamily;BITCODE_H style_ref = text->style;Dwg_Object *o = style_ref ? dwg_ref_object_silent (dwg, style_ref) : NULL;Dwg_Object_STYLE *style = o ? o->tio.object->tio.STYLE : NULL;BITCODE_2DPOINT pt;if (!text->text_value || entity_invisible (obj))return;if (isnan_2BD (text->ins_pt) || isnan_3BD (text->extrusion))return;if (dwg->header.version >= R_2007)escaped = htmlwescape ((BITCODE_TU)text->text_value);elseescaped = htmlescape (text->text_value, dwg->header.codepage);if (style && o->fixedtype == DWG_TYPE_STYLE && style->font_file&& *style->font_file
#ifdef HAVE_STRCASESTR&& strcasestr (style->font_file, ".ttf")
#else&& (strstr (style->font_file, ".ttf")|| strstr (style->font_file, ".TTF"))
#endif){
#ifdef HAVE_STRCASESTRif (strcasestr (style->font_file, "Arial"))
#elseif ((strstr (style->font_file, "arial"))|| strstr (style->font_file, "Arial"))
#endif{fontfamily = "Arial";}elsefontfamily = "Verdana";}elsefontfamily = "Courier";transform_OCS_2d (&pt, text->ins_pt, text->extrusion);printf ("\t<text id=\"dwg-object-%d\" x=\"%f\" y=\"%f\" ""font-family=\"%s\" font-size=\"%f\" fill=\"%s\">%s</text>\n",obj->index, transform_X (pt.x), transform_Y (pt.y), fontfamily,text->height /* fontsize */, entity_color (obj->tio.entity),escaped ? escaped : "");free (escaped);
}


http://www.mrgr.cn/news/23663.html

相关文章:

  • Linux /tmp/下的文件自动清理
  • IntelliJ IDEA 升级2024.2.1后,汉化设置
  • 区块链学习笔记1--比特币
  • okHttp下载文件到本地存储
  • Android V 广播注册和配置注意事项问题
  • ZCC6507高压、高频推挽变压器驱动器替代SN6507
  • 旋转目标检测对照实验-mmrotate基础教程
  • 全球视频云创新挑战赛算法赛道第一名比赛攻略
  • 智慧农业小型气象站
  • Java类和对象(详解)
  • Android - NDK: 在jni层生成java层对象,并调用java层的方法
  • 视频号黄金时间
  • JMeter做接口测试,如何提取登录Cookie
  • Unity Apple Vision Pro 开发(七):UI 交互 + 虚拟键盘
  • 数据结构应用实例(六)——最短路径
  • 2023下半年软考网络规划
  • Vue实现自定义进度条占比功能 Vue自定义进度条功能
  • excel无法保存文件
  • chapter08 面向对象编程高级 知识点总结Note
  • 源代码加密软件有哪些?10款常用的源代码加密软件分享!