中文字体乱码问题
上传了带有中文字体的dxf文件后,出现字体问题,我看到#85的Issues有相关的问题,需要设置编码格式为unicode,但是不知道是如何解决的,请指导以下,谢谢
const modelCfg: ModelConfig = {
modelId: "id_0",
name: "sample",
src: "http://www.abc.com/sample.dxf",
encoding: "gb2312",
}
已经解决了,谢谢
还有一个小问题: const modelUploader = new LocalDxfUploader(viewer); 通过LocalDxfUploader上传的dxf文件,该如何设置viewer的modelCfg呢?
以下是通过demo预览的效果
以下是通过CAD打开的效果,dxf文档中的图片在demo中不显示,是需要哪方面的设置吗?
补充CAD预览效果
This can be fixed, there is no image in the dxf file. When you process DWG file, you should put image somewhere, so you can access it with a url, then can be rendered properly,
谢谢,我是用libredwg做的转换,同样的dxf文件在AutoCad中是可以看到图片,在咱们的demo中是看不到的,上文说的图片路径是需要单独在demo工程设置吗?能否给一个示例性代码呢…… 再次谢谢。
const modelCfg: ModelConfig = { modelId: "id_0", name: "sample", src: "http://www.abc.com/sample.dxf", encoding: "gb2312", }
老哥 这个怎么使用的,求指导一下。我这个还是打开后显示的乱码
You need to find out your file's encoding, which can be gb231, etc. If you don't know, then probably need to try several common ones. Try different encodings here:
const viewerCfg: DxfViewerConfig = {
containerId: "myCanvas",
enableSpinner: true,
enableLayoutBar: true,
};
const modelCfg: ModelConfig = {
modelId: "id_0",
name: "sample",
src: "http://www.abc.com/sample.dxf",
encoding: "gb2312",
}
const fontFiles = ["http://www.abc.com/hztxt.shx", "http://www.abc.com/simplex.shx"];
const viewer = new DxfViewer(viewerCfg);
await viewer.setFont(fontFiles);
await viewer.loadModelAsync(modelCfg, (event) => {
const progress = (event.loaded * 100) / event.total;
console.log(`${event.type}: ${progress}%`);
});
You need to find out your file's encoding, which can be gb231, etc. If you don't know, then probably need to try several common ones. Try different encodings here:
const viewerCfg: DxfViewerConfig = { containerId: "myCanvas", enableSpinner: true, enableLayoutBar: true, }; const modelCfg: ModelConfig = { modelId: "id_0", name: "sample", src: "http://www.abc.com/sample.dxf", encoding: "gb2312", } const fontFiles = ["http://www.abc.com/hztxt.shx", "http://www.abc.com/simplex.shx"]; const viewer = new DxfViewer(viewerCfg); await viewer.setFont(fontFiles); await viewer.loadModelAsync(modelCfg, (event) => { const progress = (event.loaded * 100) / event.total; console.log(`${event.type}: ${progress}%`); });
OK thanks
谢谢楼上各位朋友呀,如果使用LocalDxfUploader组价, modelUploader.openFileBrowserToUpload()
该怎么传入modelConfig啊
可不一块自己动辨别utf8和gbk?
您好,您的来信已收到,我将会尽快给您回复,谢谢~~
我轮流试了下,utf8的时候有部分字体是乱码,gb2312时候都是乱码。。