vagran / dxf-viewer-example-src

Source for dxf-viewer-example GitHub pages repository
MIT License
46 stars 24 forks source link

How to add fonts #7

Open gaoxingzaq opened 3 years ago

gaoxingzaq commented 3 years ago

How to add fonts

gaoxingzaq commented 3 years ago

ditu.zip

vagran commented 3 years ago

Hello, Do you know which language is it? Actually you need a font file (ttf) which contains glyphs for that language.

vagran commented 3 years ago

Seems it is from CJK Unified Ideographs unicode block. Font with these glyphs should be added here: https://github.com/vagran/dxf-viewer-example-src/blob/0b16e6fa5365b4896e0c03e26ed428fa27b4b91c/src/components/ViewerPage.vue#L19 https://github.com/vagran/dxf-viewer-example-src/blob/0b16e6fa5365b4896e0c03e26ed428fa27b4b91c/src/components/ViewerPage.vue#L68 I will add one in this example if I find one with permissive license.

vagran commented 3 years ago

After a bit more of investigation I have these points:

  1. I made one bug fix in font processing code. It might affect text rendering correctness for Unicode code points above BMP (not sure if any characters from this example are affected).
  2. I added HanMin font to this example, it should cover all CJK glyphs.
  3. I figured out that DXF file may have encoding other than UTF-8. Most of files created by a new software should have UTF-8 encoding, Versions of R2004 and prior may have ANSI encoding specified in $DWGCODEPAGE parameter. Unfortunately, such files currently are not supported (I added corresponding note in the readme). Your file does have such encoding (ANSI_936). However it can be trivially converted to UTF-8 in any text editor. Here is your file converted: ditu-utf-8.dxf.zip It seems to be displayed correctly on the updated demo page.
gaoxingzaq commented 3 years ago

OK, thanks. I've solved the font problem. Now I want to ask that it doesn't support mobile mode. It can't be scaled when accessing in mobile mode

vagran commented 3 years ago

I will keep this issue open, until some kind of input file encoding handling is implemented. Proper processing of such files is not trivial with current parser implementation, but at least some warning message can be introduced.

I will look later at the problem with mobile browsers support.