CN114021220A - Method for embedding CAD font file into DWG document and automatically installing same - Google Patents
Method for embedding CAD font file into DWG document and automatically installing same Download PDFInfo
- Publication number
- CN114021220A CN114021220A CN202111277529.4A CN202111277529A CN114021220A CN 114021220 A CN114021220 A CN 114021220A CN 202111277529 A CN202111277529 A CN 202111277529A CN 114021220 A CN114021220 A CN 114021220A
- Authority
- CN
- China
- Prior art keywords
- font
- file
- shx
- dwg
- embedding
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/10—Geometric CAD
- G06F30/12—Geometric CAD characterised by design entry means specially adapted for CAD, e.g. graphical user interfaces [GUI] specially adapted for CAD
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/103—Formatting, i.e. changing of presentation of documents
- G06F40/109—Font handling; Temporal or kinetic typography
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/60—Editing figures and text; Combining figures or text
Abstract
The invention discloses a method for embedding a CAD font file into a DWG document and automatically installing the same, which comprises the following steps: step S1: embedding a font; embedding two font files of an SHX format and a TTF format into a named object dictionary NOD of the DWG file; step S2: restoring and installing fonts; when the DWG graphic file is opened, the missing font files are automatically restored from the named object dictionary NOD of the DWG file and are respectively installed in the corresponding directories. The invention has the advantages of simple principle, easy realization, high automation degree, realization of accurate reduction and the like.
Description
Technical Field
The invention mainly relates to the technical field of computer aided design, in particular to a method for embedding a CAD font file into a DWG document and automatically installing the CAD font file.
Background
Cad (computer Aided design) is an important application field of computer technology as computer Aided design. AutoCAD is interactive drawing software developed by Autodesk company in America, and is a system tool for two-dimensional and three-dimensional design and drawing; it can be used by users to create, browse, manage, print, export, share information rich design graphics. As general drawing software, AutoCAD is widely used for design work in various industries.
At present, in the practical application process, the characters displayed by the AutoCAD graph come from two types of font files: a suffix SHX file and a suffix TTF file. Wherein:
the SHX file is developed by Autodesk and listed in the compiled file type of AutoCAD and classified into a CAD file, the font file is usually saved in the Fonts folder under the AutoCAD installation directory at the client, and the SHX file can only be referred by the specific AutoCAD program storing the font.
TTF files are a font file format created by apple inc, but are available on both Macintosh and Windows platforms and can be referenced by all programs within the system, including AutoCAD programs. TTF files are saved in a folder of 'system installation disk \ Windows \ Fonts \'.
Because the file format saved by the AutoCAD is DWG and only contains vector image data and metadata of loading drawing, the SHX and TTF font files can not be transmitted and installed along with the DWG file, so that when the DWG file is opened and the editing environment is changed, the abnormal display conditions that the character content of the CAD graph cannot be displayed or messy codes, deformation and the like can occur because the corresponding SHX and TTF font is not installed in the system.
In order to repair such abnormal situations, it is usually necessary for the AutoCAD software operator to manually search for the missing font information and find out that the corresponding SHX font file is copied into the Fonts folder under the AutoCAD installation directory or the corresponding TTF file is to be installed.
Therefore, although some practitioners have also proposed attempts to substitute for the missing font, there have been problems with the character style, character height, character width, and abnormal display of special characters, and the original drawing contents of DWG cannot be restored sufficiently.
In addition, Autodesk provides an electronic transfer tool, and can pack a printing style sheet, an SHX font file, a data link file and the like linked to a DWG document with the DWG document into a compressed file; however, SHX files need to be manually installed after decompression, and for TTF files, Autodesk does not provide the function of transmission with DWG files.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: aiming at the technical problems in the prior art, the invention provides the CAD font file embedded DWG document and the automatic installation method which have the advantages of simple principle, easy realization and high automation degree.
In order to solve the technical problems, the invention adopts the following technical scheme:
a CAD font file embedding DWG document and automatic installation method comprises the following steps:
step S1: embedding a font; embedding two font files of an SHX format and a TTF format into a named object dictionary NOD of the DWG file;
step S2: restoring and installing fonts; when the DWG graphic file is opened, the missing font files are automatically restored from the named object dictionary NOD of the DWG file and are respectively installed in the corresponding directories.
As a further improvement of the invention: the process of step S1 includes:
step S11: opening an AutoCAD program, and reading a DWG or DXF document;
step S12: reading each style TextStyleTableRecord in a font style table TextStyleTable of the current document through an API of AutoCAD;
step S13: judging whether the font style adopts an SHX font file or a TTF font file for each style TextStyleTableRecord;
step S14: the SHX font file or TTF font file is stored in the named object dictionary NOD.
As a further improvement of the invention: in step S13, the font file name FileName and the large font file name BigFontFileName of the TextStyleTableRecord are obtained, and if the FileName string contains "SHX", it indicates that the font style adopts the SHX font file.
As a further improvement of the invention: if it is determined that the font style employs the SHX font file, in step S14, the following flow is performed:
if a dictionary named FileName or BigFontFileName is already contained in the named object dictionary NOD, then jump to the next TextStyleTableRecord;
newly establishing a dictionary Dict with the name FileName or BigFontFileName in the named object dictionary NOD;
reading the FileName or BigFontFileName content in the Fonts folder under the AutoCAD installation directory, and storing the Dict content.
As a further improvement of the invention: in step S13, if the FileName string does not contain "shx", it indicates that the font style uses a TTF font file.
As a further improvement of the invention: if it is determined that the font style employs the TTF font file, in step S14, the following procedure is performed:
if a dictionary named FileName is already contained in the named object dictionary NOD, then jump to the next TextStyleTableRecord;
newly building a dictionary Dict with the name FileName in a named object dictionary NOD;
reading the contents of the system installation disk, Windows, Fonts and FileName and storing the contents into the Dict.
As a further improvement of the invention: until all the TextStyleTableRecord is traversed, the DWG file is finally saved.
As a further improvement of the invention: the process of step S2 includes:
step S21: opening an AutoCAD to read in file data of a drawing file with a supported format;
step S22: traversing Fonts folders under an AutoCAD installation directory to obtain file names with all suffixes SHX, and storing the file names into a variable ShxFonts;
step S23: calling a system API (application program interface), obtaining the name of the installed font of the system, and storing the name in a variable Ttfonts;
step S24: reading each dictionary Dict in the named object dictionary NOD of the current document through an API of AutoCAD;
step S25: judging whether each dictionary Dict contains an SHX font file or a TTF font file;
step S26: completing the installation of the SHX font file or the TTF font file;
step S27: and restarting the AutoCAD and opening the original document until all Dicts are traversed.
As a further improvement of the invention: in step S25, obtaining a font name DName of dit, where a DName string contains ". SHX" indicating that the font style adopts an SHX font file; in step S26, the following flow is executed:
if the font named DName is not contained in the AutoCAD installed SHX font list ShxFonts, outputting the content of Dict as a file SFile named DName;
and moving the file SFile to a Fonts folder under the AutoCAD installation directory to complete the installation of the SHX font.
As a further improvement of the invention: in step S25, if the FileName string does not contain "shx", it indicates that the font style uses a TTF font file; in the step S26, the following flow is executed:
if the TTF font list Ttffont of the system installed does not contain the font named DName, outputting the content of Dict as a file TFile named DName;
and moving the file TFile to a folder of' system installation disk \ Windows \ Fonts \ to complete the installation of the TTF font.
Compared with the prior art, the invention has the advantages that:
the method for embedding the CAD font file into the DWG document and automatically installing the same has the advantages of simple principle, easy realization, high automation degree and capability of realizing accurate reduction, realizes the embedding of two font files in an SHX format and a TTF format by utilizing the AutoCAD secondary development API and the Named Object Dictionary (NOD Named Object Dictionary) of the DWG document, and can spread the font files along with the DWG graphic file so as to avoid information loss. When the DWG graphic file is read or edited in a new environment, the missing font file is automatically identified, the missing font file is automatically restored from the NOD and is respectively installed in the corresponding directories, the automatic identification and installation of the missing font file are realized, and the frequent problem that the graphic cannot be normally analyzed due to the missing font file is solved.
Drawings
FIG. 1 is a schematic flow diagram of the process of the present invention.
FIG. 2 is a flow chart of the invention for embedding fonts in a specific application example.
FIG. 3 is a flow chart illustrating the process of restoring fonts in a specific application example of the present invention.
Detailed Description
The invention will be described in further detail below with reference to the drawings and specific examples.
As shown in fig. 1, a method for embedding a CAD font file into a DWG document and automatically installing the same according to the present invention includes:
step S1: embedding a font; embedding the SHX format font file and the TTF format font file into a named Object dictionary NOD (named Object dictionary) of the DWG file;
step S2: restoring and installing fonts; when the DWG graphic file is opened, the missing font files are automatically restored from the named object dictionary NOD of the DWG file and are respectively installed in the corresponding directories.
Referring to fig. 2, in a specific application example, the process of step S1 includes:
step S11: opening the AutoCAD program and reading in DWG or DXF documents.
Step S12: reading each style TextStyleTableRecord in a font style table TextStyleTable of the current document through an API of AutoCAD;
step S13: judging whether the font style adopts an SHX font file or a TTF font file for each style TextStyleTableRecord;
step S14: the SHX font file or TTF font file is stored in the named object dictionary NOD.
In a specific application example, in step S13, the font file name FileName and the large font file name BigFontFileName of the TextStyleTableRecord are obtained, and if the FileName string contains "SHX", it indicates that the font style adopts an SHX font file.
In a specific application example, if it is determined that the font style uses the SHX font file, in step S14, the following process is performed:
if a dictionary named FileName or BigFontFileName is already contained in the named object dictionary NOD, then the next TextStyleTableRecord is skipped.
A new dictionary Dict named FileName or BigFontFileName is created in the named object dictionary NOD.
Reading the FileName or BigFontFileName content in the Fonts folder under the AutoCAD installation directory, and storing the Dict content.
In a specific application example, in step S13, if the FileName string does not contain "shx", it indicates that the font style uses a TTF font file.
In a specific application example, if it is determined that the font style uses the TTF font file, in step S14, the following process is performed:
if a dictionary named FileName is already contained in the named object dictionary NOD, then the next TextStyleTableRecord is skipped.
A dictionary Dict named FileName is newly built in the named object dictionary NOD.
Reading the contents of the system installation disk, Windows, Fonts and FileName and storing the contents into the Dict.
In a specific application example, since each style TextStyleTableRecord needs to be operated, the DWG file is saved until all the textstyletablerecords are traversed.
Referring to fig. 3, in a specific application example, the process of step S2 includes:
step S21: and opening the AutoCAD to read in the file data of the drawing file in the supported format.
Step S22: and traversing Fonts folders under the AutoCAD installation directory to obtain all file names with SHX suffixes, and storing the file names into a variable ShxFonts.
Step S23: and calling a system API (application program interface), obtaining the name of the installed font of the system, and storing the name in a variable Ttfonts.
Step S24: reading each dictionary Dict in the named object dictionary NOD of the current document through an API of AutoCAD;
step S25: judging whether each dictionary Dict contains an SHX font file or a TTF font file;
step S26: the installation of the SHX font file or the TTF font file is completed.
Step S27: and restarting the AutoCAD and opening the original document until all Dicts are traversed.
In the specific application example, in step S25, a font name DName of Dict is obtained, such as that "SHX" is included in the DName string, indicating that the font style employs an SHX font file.
In a specific application example, if it is determined that the font style uses the SHX font file, in step S26, the following process is performed:
if the AutoCAD installed SHX font list ShxFonts does not contain the font named DName, the content of Dict is output as the file SFile named DName.
And moving the file SFile to a Fonts folder under the AutoCAD installation directory to complete the installation of the SHX font.
In a specific application example, in step S25, if the FileName string does not contain "shx", it indicates that the font style uses a TTF font file.
In a specific application example, if it is determined that the font style uses the TTF font file, in step S26, the following process is performed:
if the system installed TTF font list ttfffonts does not contain the font named DName, the content of dit is output as file TFile named DName.
And moving the file TFile to a folder of' system installation disk \ Windows \ Fonts \ to complete the installation of the TTF font.
By adopting the method of the invention, accurate restoration can be realized, embedding of two font files of SHX format and TTF format is realized by using Named Object Dictionary (NOD) of DWG file, the font files can be transmitted along with DWG graphic file, and information loss is avoided. When the DWG graphic file is read or edited in a new environment, the missing font file is automatically identified, the missing font file is automatically restored from the NOD and is respectively installed in the corresponding directories, the automatic identification and installation of the missing font file are realized, and the frequent problem that the graphic cannot be normally analyzed due to the missing font file is solved.
The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above-mentioned embodiments, and all technical solutions belonging to the idea of the present invention belong to the protection scope of the present invention. It should be noted that modifications and embellishments within the scope of the invention may be made by those skilled in the art without departing from the principle of the invention.
Claims (10)
1. A method for embedding a CAD font file into a DWG document and automatically installing the same is characterized by comprising the following steps:
step S1: embedding a font; embedding two font files of an SHX format and a TTF format into a named object dictionary NOD of the DWG file;
step S2: restoring and installing fonts; when the DWG graphic file is opened, the missing font files are automatically restored from the named object dictionary NOD of the DWG file and are respectively installed in the corresponding directories.
2. The method for embedding a CAD font file into a DWG document and automatically installing the same as claimed in claim 1, wherein the process of step S1 includes:
step S11: opening an AutoCAD program, and reading a DWG or DXF document;
step S12: reading each style TextStyleTableRecord in a font style table TextStyleTable of the current document through an API of AutoCAD;
step S13: judging whether the font style adopts an SHX font file or a TTF font file for each style TextStyleTableRecord;
step S14: the SHX font file or TTF font file is stored in the named object dictionary NOD.
3. The method for embedding a CAD font file into a DWG document and automatically installing the same as claimed in claim 2, wherein in step S13, a font file name FileName and a large font file name BigFontFileName of the TextStyleTableRecord are obtained, and if the FileName string contains "SHX", it indicates that the font style is an SHX font file.
4. The CAD font file embedded DWG document and automatic installation method as claimed in claim 3, wherein if it is determined that the font style employs the SHX font file, then in step S14, the following procedure is performed:
if a dictionary named FileName or BigFontFileName is already contained in the named object dictionary NOD, then jump to the next TextStyleTableRecord;
newly establishing a dictionary Dict with the name FileName or BigFontFileName in the named object dictionary NOD;
reading the FileName or BigFontFileName content in the Fonts folder under the AutoCAD installation directory, and storing the Dict content.
5. The method for embedding a CAD font file into a DWG document and automatically installing the same as claimed in claim 2, wherein in step S13, if the FileName string does not contain "shx", it indicates that the font style is the TTF font file.
6. The CAD font file embedding DWG document and automatic installation method of claim 5, wherein if the font style is judged to be TTF font file, then in step S14, the following procedures are executed:
if a dictionary named FileName is already contained in the named object dictionary NOD, then jump to the next TextStyleTableRecord;
newly building a dictionary Dict with the name FileName in a named object dictionary NOD;
reading the contents of the system installation disk, Windows, Fonts and FileName and storing the contents into the Dict.
7. The CAD font file embedding DWG document and automatic installation method of claim 2, wherein, the DWG file is saved finally until all the TextStyleTableRecord is traversed.
8. The method for embedding a CAD font file into a DWG document and automatically installing the same according to any of claims 1-7, wherein the flow of the step S2 comprises:
step S21: opening an AutoCAD to read in file data of a drawing file with a supported format;
step S22: traversing Fonts folders under an AutoCAD installation directory to obtain file names with all suffixes SHX, and storing the file names into a variable ShxFonts;
step S23: calling a system API (application program interface), obtaining the name of the installed font of the system, and storing the name in a variable Ttfonts;
step S24: reading each dictionary Dict in the named object dictionary NOD of the current document through an API of AutoCAD;
step S25: judging whether each dictionary Dict contains an SHX font file or a TTF font file;
step S26: completing the installation of the SHX font file or the TTF font file;
step S27: and restarting the AutoCAD and opening the original document until all Dicts are traversed.
9. The method for embedding a CAD font file into a DWG document and automatically installing the same as in claim 8, wherein in the step S25, a font name DName of dit is obtained, such as containing ". SHX" in a DName string, indicating that the font style is an SHX font file; in step S26, the following flow is executed:
if the font named DName is not contained in the AutoCAD installed SHX font list ShxFonts, outputting the content of Dict as a file SFile named DName;
and moving the file SFile to a Fonts folder under the AutoCAD installation directory to complete the installation of the SHX font.
10. The method for embedding a CAD font file into a DWG document and automatically installing the same as in claim 8, wherein in the step S25, if the FileName string does not contain "shx", it indicates that the font style is the TTF font file; in the step S26, the following flow is executed:
if the TTF font list Ttffont of the system installed does not contain the font named DName, outputting the content of Dict as a file TFile named DName;
and moving the file TFile to a folder of' system installation disk \ Windows \ Fonts \ to complete the installation of the TTF font.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111277529.4A CN114021220B (en) | 2021-10-29 | 2021-10-29 | Method for embedding CAD font file into DWG document and automatically installing same |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111277529.4A CN114021220B (en) | 2021-10-29 | 2021-10-29 | Method for embedding CAD font file into DWG document and automatically installing same |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114021220A true CN114021220A (en) | 2022-02-08 |
CN114021220B CN114021220B (en) | 2022-08-30 |
Family
ID=80059064
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111277529.4A Active CN114021220B (en) | 2021-10-29 | 2021-10-29 | Method for embedding CAD font file into DWG document and automatically installing same |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114021220B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5528742A (en) * | 1993-04-09 | 1996-06-18 | Microsoft Corporation | Method and system for processing documents with embedded fonts |
CN101008940A (en) * | 2006-01-27 | 2007-08-01 | 北京书生国际信息技术有限公司 | Method and device for automatic processing font missing |
CN104217396A (en) * | 2014-09-11 | 2014-12-17 | 广西桂能软件有限公司 | DWG (drawing) file format conversion method |
CN112101239A (en) * | 2020-09-17 | 2020-12-18 | 中国建设银行股份有限公司 | Method, device and system for searching missing characters in PDF file |
CN112214813A (en) * | 2020-10-26 | 2021-01-12 | 常熟理工学院 | Method for converting SolidWorks diagrams into AutoCAD diagrams in batches |
CN113505569A (en) * | 2021-06-07 | 2021-10-15 | 深圳市华阳国际工程设计股份有限公司 | DWG drawing font adapting method and device, terminal equipment and storage medium |
-
2021
- 2021-10-29 CN CN202111277529.4A patent/CN114021220B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5528742A (en) * | 1993-04-09 | 1996-06-18 | Microsoft Corporation | Method and system for processing documents with embedded fonts |
CN101008940A (en) * | 2006-01-27 | 2007-08-01 | 北京书生国际信息技术有限公司 | Method and device for automatic processing font missing |
CN104217396A (en) * | 2014-09-11 | 2014-12-17 | 广西桂能软件有限公司 | DWG (drawing) file format conversion method |
CN112101239A (en) * | 2020-09-17 | 2020-12-18 | 中国建设银行股份有限公司 | Method, device and system for searching missing characters in PDF file |
CN112214813A (en) * | 2020-10-26 | 2021-01-12 | 常熟理工学院 | Method for converting SolidWorks diagrams into AutoCAD diagrams in batches |
CN113505569A (en) * | 2021-06-07 | 2021-10-15 | 深圳市华阳国际工程设计股份有限公司 | DWG drawing font adapting method and device, terminal equipment and storage medium |
Non-Patent Citations (11)
Title |
---|
于世艳: "AutoCAD的DWG数据转为MicroStation的DGN数据可行性研究", 《测绘与空间地理信息》 * |
冯国利: "AutoCAD图形中字体乱码问题浅谈", 《当代经理人(中旬刊)》 * |
刘剑等: "基于TTF技术的UG刻字工具开发", 《模具制造》 * |
原创力文档: "CAD快速替换不存在/缺少的字体", 《URL:HTTP://MAX.BOOK118.COM/HTML/2018/1214/5142241202001340.SHTM》 * |
周春波 等: "基于AutoCAD 的地下管网图形属性一体化方案", 《城市勘测》 * |
廖东杰: "基于ObjectARX的交通工程绘图系统的研究与开发", 《数字技术与应用》 * |
张建桃等: "软件安装测试的内容和方法", 《计算机与现代化》 * |
张日飞: "浅谈Auto CAD中文字处理", 《电脑开发与应用》 * |
曾定洲等: "基于AutoCAD .NET的参数化汽车焊装夹具二维图库开发", 《机械》 * |
李保风: "基于.NET访问AutoCAD数据库探讨", 《制造业自动化》 * |
汪瑷珍: "AUTOCAD统一字体解决方案", 《电脑知识与技术》 * |
Also Published As
Publication number | Publication date |
---|---|
CN114021220B (en) | 2022-08-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7478170B2 (en) | Generic infrastructure for converting documents between formats with merge capabilities | |
US7200668B2 (en) | Document conversion with merging | |
US7340534B2 (en) | Synchronization of documents between a server and small devices | |
CN101957730B (en) | Messaging device and information processing method | |
US6708189B1 (en) | Computer file transfer system | |
US7627592B2 (en) | Systems and methods for converting a formatted document to a web page | |
EP1672473A2 (en) | Stamp sheet | |
US7171614B2 (en) | Displaying plug-in derived content in an application's browser-embedded window with callbacks | |
US6351741B1 (en) | Method of locating a file linked to a document in a relocated document directory structure | |
EP1486874A1 (en) | Document file read system using network | |
CN105824788A (en) | Method and system for converting PowerPoint file into word file | |
CN116579295B (en) | Method for dynamically inserting pages, moving bits and hiding and displaying multi-format file subscription | |
CN100585561C (en) | Method for clipping relocatable ELF files in embedded system | |
US7453594B2 (en) | Document filing apparatus for storing information added to a document file | |
US20030222916A1 (en) | Object-oriented processing of tab text | |
CN114021220B (en) | Method for embedding CAD font file into DWG document and automatically installing same | |
US20060095838A1 (en) | Object-oriented processing of tab text | |
CN109918346A (en) | A kind of creation method and device of file | |
CN110232047B (en) | Time line management system, method, computer readable storage medium and computer terminal for CAD file | |
US20020038322A1 (en) | Information processing apparatus, method therefor,and computer-readable memory | |
US20100042640A1 (en) | Migration Apparatus Which Convert SAM/VSAM Files of Mainframe System into SAM/VSAM Files of Open System and Method for Thereof | |
JP2006343976A (en) | Method for providing electronic form and electronic form server device | |
JP6881920B2 (en) | Information processing equipment, control methods, and programs | |
CN114021221A (en) | CAD font file cloud storage and file missing font automatic installation method | |
JPH07334528A (en) | Term dictionary management device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |