The generation method of industrial marking machine character library under the Windows environmentTechnical field
The present invention relates to the generation method of industrial marking machine character library under a kind of Windows environment
Background technology
Character library under the Windows environment is hollow character library, and then there is the low problem of printing effect in the stroke beautiful design of various character libraries but be used for industrial marking machine, and industrial marking machine also needs to develop single line body character library except that using hollow character library.The method that current Windows environment is created down single line voxel vector character library has: 1) use the mapping software exploitation, this method development efficiency is low, and is difficult for creating standard compliant type matrix and track, needs that difficulty more just of character library of exploitation multiple font.2) use a series of mathematical methods hollow character library is carried out the profile extraction and followed the tracks of, more hollow profile is handled, thereby generated uniline message.This method development difficulty is big, needs to drop into more fund and long time.3) utilize the dot matrix word library under the DOS environment to generate single line voxel vector character library, the defective of this method is that font is insufficient.4) the binary vector Chinese character shape file that utilizes Large-scale CAD software to provide converts thereof into the text of the output that can be used to draw.The existing at present people of this method can not make the degree that numerical control is exported in research but also reach on industrial marking machine.This patent independent research transfer algorithm, and the text after the conversion done effective simplification, optimization and transformation, and developed multiple application interface, reached practical journey
The summary of the invention goal of the invention
This technology can be developed more single line body character library in the short time under less investment, can make full use of the resource of Windows operating system and CAD software, and the single line body character library user who develops can also revise and add voluntarily.This technology combines with Numeric Control Technology, directly applies to the generation of Chinese-character stroke digital controlled tracing, can be used for industrial mark printer, laser stamp, industrial embroidery machine etc.To the update of industrial marking machine, change inconvenient, the ropy backwardness of mark of present industrial marking machine Chinese character input, will play great impetus, the practical background in fabulous economic results in society and market is arranged.
(1) outline letters mark track vector data obtains
What the TureType character library under the Windows was preserved is the hollow information of literal, according to character library information hollow literal is drawn earlier during use, fills as required then.Windows provides a series of api function can obtain a series of data of hollow word vector track, and concrete steps are as follows:
1) uses the CreateFontIndirect function, create logical font according to the attribute of appointment;
2) start a path branches with the BeginPath function;
3) with Line, Cricle, Arc, Rectangle function representation current path;
4) stop path definition with the EndPath function;
5) all convert all curves in the path to straight-line segment with the FlattenPath function;
6) obtain the outline letters stroke vectors data that current path is defined with the GetPath function.
(2) vector data of skeleton word obtains
Do not have single line body character library under the Windows, industrial marking machine can't directly be printed single line body literal with any character library that windows provides.But contain some single line body character library in number of C AD software, they exist with binary shape file form, and the stroke track that how to utilize this resource to produce numerical control industrial marking machine single line body literal is the key to the issue place.Our way is:
1) the skeleton Chinese character base that exists with scale-of-two shape file form that contains in the softwares such as CAD is converted to the glyph definition file of text formatting.A glyph definition file is made up of a plurality of glyph definition descriptors, and each glyph definition descriptor comprises a header line and several description row.See embodiment 1 about the data structure of glyph definition file.
2) the glyph definition file is done to simplify and optimization process.Simplification work is, remove use in the mark machine less than the shape attribute, to improve print speed; Optimization work is to increase non-circular curve and describe attribute, to improve print quality.Simplifying optimized Algorithm sees
Embodiment 2.
3) recall precision in order to improve character library and to use changes into font data library file (i.e. the font file that finally can use) to the shape defined file after optimizing and simplifying again in industrial marking machine.Utilize data base management system (DBMS) that font file is done various maintenances and visit, effectively raise the service efficiency of character library.The table name of database is exactly a font name, and structure of data table is as shown in the table;
| Field name | Coding | Font description is capable |
| Type | ????Text | ????Text |
| Length | ????4 | ????255 |
4) the complete Chinese character editor and the various software interface that uses this character library of design.
The Chinese character index interface: import the various font font Chinese characters of wanting mark output as the Word word processing under the Windows environment easily, the application data base technology finds font attribute in the single line body font data library file of appointment.The statement form that Chinese character index calls is " the SELECT glyph definition is described row FROM fontname WHERE coding=literal code ".
The Chinese character image Processing Interface: according to the font attribute data that find, the Graphics Application treatment technology generates the Chinese-character stroke shape, and obtains the feature discrete point coordinate of stroke curve.
The modification interface of word string: word string is modified and is comprised processing such as arch, inclination, convergent-divergent, translation, rotation, and respective algorithms is encapsulated in the generic module, realizes the rhetorical function of word string.The modification interface of word string is seen embodiment 3.
The mixing interface of text strings and figure:, can increase figure, symbol commonly used in some industrial marking easily because character library is self-defining font data storehouse.Remove figure, outer symbol that the developer increases, the user also can increase new graphical symbol at any time.These figures are the same with lexigraphy in database, can image mixed character typeset, and to increase the mark effect.
The coinage interface: place name, name and the trade mark etc. that often occur in the mark machine usually are not contained among 6 763 Chinese characters and 682 graphical symbols of standard GB 2312-80 regulation.Extremely low for these frequencies of utilization, but literal and the symbol used always in the mark machine as long as perform font description according to form and the predetermined data structure of embodiment 11, just can be realized the function of creating characters of literal.The invention effect
(1) Chinese character input efficiency height
Can use the various input method of Chinese character of Windows, compare with the Chinese character input of mark machine under the DOS environment, input efficiency improves more than 10 times.
(2) Chinese character index efficient height
The glyph definition file is after optimizing simplification and changing into database file, and Chinese character index efficient has improved 10 times, because the raising of recall precision, the configuration of control computer can reduce, and the cost of total system has also reduced, and can improve the competitiveness of product in market.
(3) print quality improves
Increased after the attribute of non-circular curve, even the broken line sense of curve also can not appear in special big character, the stroke degree of distortion descends, and print quality improves.
(4) font variation
As long as can find new scale-of-two Chinese character shape file, just can generate one's own font data library file, thereby be single line body character library of system's increase with this patent.Mark machine under the Windows environment on the market nearly all has only one or both single line body character libraries at present, and reason is will create to generate a single line body character library, and the expense of time and fund is too big.
(5) character library maintainability, extensibility are good
Data structure in accordance with regulations increases record in the font data library file or amendment record has just been finished the task of the expansion and the modification of character library.
(6) realize image mixed character typeset
The DXF form is a kind of method for expressing of the marker graphic data in the AutoCAD graphic file.All user appointed information can both be represented with the DXF file layout in the graphic file.We have developed the interface with DXF, can realize image mixed character typeset easily.
Description of drawings
Fig. 1 font description direction code
The rotational transform of Fig. 2 word string
The conversion of Fig. 3 word string arch
Fig. 4 word string is amplified conversion
Embodiment embodiment 1 glyph definition file layout
Define the shape of descriptive text with straight line, circular arc and nurbs curve, shape definition is formed by describing first trip and descriptor string.
Shape first trip definition has following content:
shapenumber,defbytes
Wherein:
Shapenumber is literal code, with the ASCH representation;
Difbytes is a descriptor string byte number.
The descriptor string is made up of basic descriptor and private code descriptor, does not have between descriptor to separate with comma.Basic descriptor comprises two parts: long amount of vector and direction code, form is three characters of " 0XX ".First two characters incharacter 0 expression back are hexadecimal value, the length of second character specifies vector, and the direction of the 3rd character specifies vector, direction and direction code are provided by accompanying drawing 1.
Private code is described the membrane inside the rush stalk and is defined as follows shown in the table.
| Coding (sexadecimal) | The font description explanation |
| 000 | Definition finishes |
| 001 | Start to write |
| 002 | Start writing |
| 003 | Remove vector length with next byte |
| 004 | Take advantage of vector length with next byte |
| 005 | Current location is pressed into storehouse |
| 006 | From storehouse, eject current location |
| 007 | Nurbs curve |
| 008 | The X-Y relative displacement that provides by following two bytes |
| 009 | Finish a plurality of X-Y relative displacements by (0,0) |
| 00A | Octant arc by following two bytes definition |
| 00B | Segment by following five bytes definition |
| 00C | Arc according to X-Y displacement and convexity definition |
| 00D | The arc of a plurality of appointment convexitys |
Embodiment 2 character library optimized Algorithm
This character library is described the database file that membrane inside the rush stalk record is formed by font attribute in essence, and the user can revise and optimization being defined as of font attribute at any time.Certainly, after attribute definition was revised, the graphics process branched program also will be made corresponding modification.The method of simplifying, optimizing is a lot.Wherein increasing nurbs curve (non-uniform rational B-spline) attribute is that this patent aims at the font attribute that super-huge Chinese character is set up.The handling procedure of this attribute is as follows: 1, when the increment of coordinate of a stroke during greater than specified value, enter this program.2, at first by nurbs curve of former discrete data point definition.WhereinRI, 3 (u)---3 rational basis functions; Pi---feature polygon reference mark; Wi---the weight factor at reference mark.3, according to the stroke needs on-line setup W of special big characteriParameter.
Wi=0 o'clock, the position, reference mark there was not influence, W to fontiIncrease, local line segment will be to PiApproaching, WiDuring → ∞, what be pulled names a person for a particular job and PiOverlap.Revise the local shape of stroke easily by weight factor.Nurbs curve more can be represented free curve accurately than general Bezier.
On adjusted nurbs curve, make linear interpolation, remake linear interpolation output.
Modification 1. translation algorithms of embodiment 3 word strings:
If any point P in the track (X, Y), translation Δ X is P ' (X ', Y ') behind the Δ Y, then:
X′=X+ΔX
;
Y′=Y+ΔY
Use translation algorithm, realize the alignment function of each print object.2. rotation algorithm:
With reference to the accompanying drawings 2, the definition screen object lower left corner is O (XMin, YMax), arbitrary coordinate points P in the track (X, phasing degree Y) is θ, rotates coordinate points behind the given corner Δ θ and be P ' (X ', Y '), then: (1) radius of turn R and phasing degree θ are:(2) rotation back angle θ '=θ+Δ θ; (3) coordinate of rotation back P ' (X ', Y ') is:
X′=Xmin+Rcosθ′
Y '=YMax+ Rsin θ ' is the arch algorithm 3.:
With reference to the accompanying drawings 3, the point coordinate after four angular coordinates, arch transformation parameter and the arch conversion of definition arch object.
(1) establishes arch centre coordinate O (X0, Y0), arch initial angle θ1, end angle θ2, R1, R2Be screen after the arch
The radius up and down of object, R
3Be middle footpath (being arch radius) that the pass between them is:
Can get R
1, R
2, R
3(2) (θ is R) (with O (X for any 1 P ' in the word vector path0, Y0) be the utmost point heart), according to angle than=wide
Degree ratio, radius ratio=aspect ratio have relational expression:
Can get antipode coordinate R, θ after the arch;
(3) (θ R) is converted into (X with O polar coordinates to be put P '0, Y0) be true origin rectangular coordinate point P ' (X, Y):
X=Rcosθ
Y=Rsinθ
(4), finally try to achieve coordinate P ' after the arch (X ', Y ') by translation algorithm
X′=X0+X=X0+Rcosθ
Y '=Y0+ Y=Y0+ Rsin θ 4. interpolator arithmetics: with reference to the accompanying drawings 4, definition screen lower left corner coordinate points is O (XMin, YMax), arbitrary coordinate points P in the track (X, Y), the convergent-divergent multiple is K, then: the polar angle that (1) P is ordered is:
The utmost point directly is:(2) amplify the back to P ' (X ', Y ') point,
P ' polar angle is: θ, the utmost point directly are R1=KR; (3) rectangular coordinate that amplifies back literal vector path P ' (X ', Y ') point is:
X′=Xmin+R1cosθ
Y′=Ymax+R1sinθ