Summary of the invention
In view of this, it is necessary in view of the above-mentioned problems, providing mechanical engineering character vector font in a kind of desktop operating system
Body output method and system make corresponding font for specific industry, and the sector personnel is facilitated to use.
To achieve the goals above, technical scheme is as follows:
Mechanical engineering character vector fonts output method in a kind of desktop operating system, comprising the following steps:
S1, abstract processing is carried out to mechanical engineering character, according to the complexity of symbol, the feature of common property, to corresponding
Character induction and conclusion is divided into conventional characters and splicing character;
S2, to splicing character take out initial basic element collection, successively according to initial basic element whether can merge with
Meet memory space it is lesser require, algorithm realize character splicing complexity and basic element institute energy use scope it is big
It is small, determine the basic element collection of final character element;
S3, determine that corresponding basic element in the position of font file, and draws corresponding character element symbol;For commonly used word
It accords with and the splicing character without rule voluntarily selects suitable continuum position, draw character;Complete the system of font file
Make, save and installs;
S4, judge whether target output character is conventional characters, if conventional characters, then extract corresponding font file simultaneously
Output then decomposes target splicing character, determines basic element, select joining method, splice target character if splicing character
And it exports.
Preferably, according to encirclement ocra font ocr, upper subscript ocra font ocr, denominator molecule ocra font ocr, being answered in the step S2
Direct type character and conventional characters are merged to split mechanical engineering character and extract basic element.
Preferably, in step s3, the conventional characters include mechanical conventional characters, including roughnessEntirely
BounceCylindricitySymmetry
Preferably, in step s 4, the joining method for surrounding ocra font ocr includes:
Spliced using add operation, when using round, square add operation splicing target character, no matter unit,
Or dibit needs one space of each addition, is shown centered on character in graphical symbol before and after character, using positive triangle, falls
When target character is spliced in triangle add operation, no matter single, double position needs two spaces of each addition, is scheming character before and after character
It is shown centered in pictograph number.
Preferably, in step s 4, the joining method of the upper subscript ocra font ocr includes: to be carried out using add operation
Splicing;Upper subscript ocra font ocr, which is divided into subscript, type, only subscript type and only subscript type three types;
There is ocra font ocr for upper subscript, obtains subscript length and subscript length and correlation first, then first export
Radix exports a character by subscript, and subscript exports the part that subscript is isometric on the Sequential output of a character, if subscript length
Less than subscript length, then the remaining part of subscript is individually exported, if subscript length is equal to subscript length, output character terminates, if
Subscript length is greater than subscript length, then by output one subscript, one character, then exports the sequence in a space, output is all
Subscript residue character.
Preferably, in step s 4, the joining method of the molecule denominator ocra font ocr include: calculate first molecule,
The length of denominator, then longer string length is subtracted compared with short character strings length in molecule denominator, then divided by 2 be rounded obtain it is shorter
The initial position that character string is shown centered on;
It exports in longer character string, it is one longer according to exporting when positioned at the character string being shown centered on before initial position
Then character in character string exports the Sequential output of a horizontal line compared in the longer character string before short character strings initial position
Character;
According to first exporting compared with a character in short character strings, the character in longer character string is then exported, then export cross
The sequence of line, until being exported completely compared with short character strings;
According to a character for first exporting remaining character string in longer character string, the sequence of horizontal line is then exported, until compared with
Long character string exports completely.
Preferably, in step s 4, for compound splicing ocra font ocr, meeting character string using add operation splicing.
Preferably, further including that the type described in character element address and character calculates in the step S4;Root
According to character locating formula P=(176+H) * 256+161+ (A-48), ASCII character value find it in font file it is corresponding
Position, in formula, P indicates the position in font file character area, is indicated with 10 hex values;176 16 systems are expressed as B0, are
The mark that Chinese character area starts in font file, BO are a high position for GBK coding;The weight of H expression character;256 be Chinese character be double word
Section, a high position account for a byte;48 be the ASCII character value of " 0 ";A is the number 0~9 or capitalization A~Z or small of input
It writes the ASCII character value of female a~z.
Mechanical engineering character vector fonts output system in a kind of desktop operating system according to the above method, including data
Library module, character locating module, font make module, character output module;
The database module is used to store basic element collection, conventional characters and the spcial character element of splicing character;
The character locating module determines the ASCII of weight H and character element for the classification according to belonging to character element
Value, and by character locating formula, address of the calculating character element in font file;
The font production module is for judging that target output character is to splice for conventional characters or splicing character to target
Character decomposes, and determines basic element, and splice target character;
The character output module is used to that splicing character, conventional characters and spcial character element to be carried out output and be shown.
Compared with prior art, the beneficial effects of the present invention are:
1, font can directly export in MSOE, be easy to use;
2, the font made is convenient for organization and management, and when needing corresponding font, installation be can be used;
3, it can be directed to specific industry, make corresponding font, the sector personnel is facilitated to use;
4, the character exported in technology document or report, printing is clear, and quality is high.
Specific embodiment
With reference to the accompanying drawings and examples to mechanical engineering character vector in a kind of desktop operating system of the present invention
Font output method and system are described further.
It is mechanical engineering character vector fonts output method and system in desktop operating system of the present invention below
Therefore preferred example does not limit the scope of protection of the present invention.
Figures 1 and 2 show that mechanical engineering character vector fonts output method in a kind of desktop operating system, including it is following
Step:
S1, abstract processing is carried out to mechanical engineering character, according to the complexity of symbol, the feature of common property, to corresponding
Character induction and conclusion is divided into conventional characters and splicing character;
S2, to splicing character take out initial basic element collection, successively according to initial basic element whether can merge with
Meet memory space it is lesser require, algorithm realize character splicing complexity and basic element institute energy use scope it is big
It is small, determine the basic element collection of final character element;
S3, determine that corresponding basic element in the position of font file, and draws corresponding character element symbol;For commonly used word
It accords with and the splicing character without rule voluntarily selects suitable continuum position, draw character;Complete the system of font file
Make, save and installs;
S4, judge whether target output character is conventional characters, if conventional characters, then extract corresponding font file simultaneously
Output then decomposes target splicing character, determines basic element, select joining method, splice target character if splicing character
And it exports.
Preferably, according to encirclement ocra font ocr, upper subscript ocra font ocr, denominator molecule ocra font ocr, being answered in the step S2
Direct type character and conventional characters are merged to split mechanical engineering character and extract basic element.
Preferably, in step s3, the conventional characters include mechanical conventional characters, including roughnessEntirely
BounceCylindricitySymmetry
In the present embodimentIt is exactly mechanical Deng encirclement ocra font ocr
The character that industry is in daily use is made of other characters such as number, letter, Chinese character and graphical symbol.For graphical symbol, such asDeng discrete straight line originally can be split as basic element.And the most base taken out in this way
This element, although the range for the additional character that can splice is wide, the type and quantity for the most basic element that can make increase severely, and increase
Big memory space increases the difficulty of splicing.If by pictureIt, can be big as a basic element etc. simple symbol
The big memory space for reducing character, and convenient for splicing, and (cursor is not in graphical symbol for occupy-place when the output of this kind of graphical symbol
Before).Unit refers to that containing only a character in graphical symbol, dibit refers in graphical symbol containing there are two characters.
It surrounds ocra font ocr and target character can be obtained using " addition " operation splicing, as follows:
When using round (Pian Zhongqu), square (Pian Zhongqu) " addition " operation splicing target character, no matter unit or
Dibit needs one space of each addition, so that character is shown centered in graphical symbol before and after character.It is as follows:
(character n belongs to unit character in partially)
(character A belongs to dibit word in partially
Symbol)
(character d belongs to unit character in partially)
(character a, B belong to dibit in partially
Character)
It is no matter single, double when using positive triangle (area on the lower side), inverted triangle (area on the upper side) " addition " operation splicing target character
Position needs two spaces of each addition, so that character is shown centered in graphical symbol before and after character.It is as follows:
(character M belongs to unit character on the upper side)
(character A, 1 belong to dibit on the lower side
Character)
In the present embodiment,7+0.452、5-0.291Deng upper subscript ocra font ocr, being divided into subscript has type, only has
Subscript type and only subscript type three types.This kind of character is very common in component of machine table, drawing, by number,
Adding, minus sign and point composition, basic element is simpler, when output, subscript not occupy-place, subscript occupy-place.Also " addition " operation can be used,
It is as follows:
1) subscript has type on, such asWhen " addition " operation, program obtains subscript length and subscript length first
And correlation, radix 4 is then first exported, exports a character by subscript, subscript exports the Sequential output of a character or more
Isometric part is marked, then:
If a) subscript length is less than subscript length, the remaining part of subscript is individually exported.
If b) subscript length is equal to subscript length, output character terminates.
If c) subscript length is greater than subscript length, by output one subscript, one character, a space is then exported
Sequentially, all subscript residue characters are exported.
2) there was only subscript type, such as 5-0.291.Radix 5 is then first exported, then exports all subscript characters in order.
3) there was only subscript type, such as 7+0.452.Radix 7 is then first exported, then by one superscript character(SPS) of output, exports a sky
The sequence of lattice, until exporting all superscript character(SPS)s.
In the present embodiment, molecule denominator ocra font ocr, such asDeng being common character.By
Upper and lower case letter, number and horizontal line-composition basic element, when carrying out character splicing " addition " operation, molecule character and denominator
Character not occupy-place, but horizontal line occupy-place.When character output display, program calculates the length of molecule, denominator first, then molecule point
Longer string length is subtracted compared with short character strings length in mother, then divided by 2 be rounded obtain being shown centered on compared with short character strings it is initial
Position, then:
1) export in longer character string, when positioned at the character string being shown centered on before initial position, according to output one compared with
Then character in long character string exports the Sequential output of a horizontal line compared with the longer character string before short character strings initial position
In character.
2) according to first exporting compared with a character in short character strings, the character in longer character string is then exported, then export
The sequence of horizontal line, until being exported completely compared with short character strings.
3) according to a character for first exporting remaining character string in longer character string, the sequence of horizontal line is then exported, until
Longer character string exports completely.
In the present embodiment, precomposed character splice type, such asAnd Tolerance Symbols in Shape and Relative Position etc., for machinery
Drawing, byEqual composite components and Etc. shapes
Bit sign and Chinese character, letter composition.Composite component not occupy-place, morpheme symbol, Chinese character, the equal occupy-place of letter, is also transported using " addition "
Splicing precomposed character string is calculated, as follows:
(additional character, circle not occupy-place, square occupy-place.)
In the present embodiment, conventional characters, such asIso-scallop symbol, Deng mechanical additional character,Deng customization symbol and the symbol of other forms, without splicing, directly
It uses, it is very easy, efficiently.
As shown in Fig. 2, superscript notation in font file, subfix, single dibit symbol on the upper side, partially in single dibit symbol,
English alphabets and the numerical chracters such as list dibit symbol on the lower side, are all regular symbols, and needs and circle, square, positive three
The graphical symbols such as angle, lower triangle are combined.In order to realize efficient character stitching algorithm, it is desirable to be able to use the English alphabet
Its position corresponding in font file is found with the ASCII character value of numerical character itself, provides a character locating here
Formula (can deform as needed to meet particular demands the formula):
P=(176+H) * 256+161+ (A-48)
In formula:
P:P indicates the position in font file character area, is indicated with 10 hex values.As font file GBK encodes B1A1
Position represented by (16 system), decimal representation 45473.
16 systems of 176:176 are expressed as B0, this is the mark that Chinese character area starts in font file, and BO is GBK coding
A high position, such as first Chinese character " " in Chinese character area, corresponding position is B0A1.
H: weight, according to the value that character feature is manually set, the weight of kinds of characters is as follows:
Superscript character(SPS): 1;
Subscript character: 2;
Unit character on the upper side: 3;
Dibit character on the upper side: 4;
Partially middle unit character: 5;
Partially middle dibit character: 6;
Unit character on the lower side: 7;
Dibit character on the lower side: 8;
256: Chinese character is double byte, and a high position accounts for a byte, i.e., 28 powers are 256.
161: for offset, B000~B0A1 is 161 blank areas.
A: the number 0~9 or capitalization A~Z of input or the ASCII character value of lowercase a~z such as input " A
ASCII character value 64.
48: for the ASCII character value of " 0 ", why being so arranged, be capitalization A~Z, lowercase a because 0~9
ASCII character value corresponding to~z be one relatively continuous region (0~9 with separated 7 of A~Z, A~Z and a~z it
Separated 6), the ASCII character value of small letter z is up to 122, and subtracting 48 is 74.There are 96 positions between B0 to B1, so will not
Go beyond the scope, and 0~9, A~Z, a~z also can in font file code area relatively continuous position.
As shown in Figures 3 to 5, in the present embodiment, machine in a kind of desktop operating system according to the above method is additionally provided
Tool engineering character vector fonts output system, including database module, character locating module, font production module, character output
Module;
The database module is used to store basic element collection, conventional characters and the spcial character element of splicing character;
The character locating module determines the ASCII of weight H and character element for the classification according to belonging to character element
Value, and by character locating formula, address of the calculating character element in font file;
The font production module is for judging that target output character is to splice for conventional characters or splicing character to target
Character decomposes, and determines basic element, and splice target character;
The character output module is used to that splicing character, conventional characters and spcial character element to be carried out output and be shown.
As shown in figure 5, the key step of character output module are as follows:
1, judge whether target output character is conventional characters, if conventional characters, into character locating module, execute step
Rapid 3.
2, target splicing character is decomposed, determines basic element, into character locating module, then determine that target splices word
The type of symbol.
If 1) surround ocra font ocr, further determine which belongs in area's character on the upper side, the area Pian Zhong character and area's character on the lower side
It is a kind of.Belonging to the character element address of the basic element, the output of character locating module that are decomposed according to target splicing character and character
The stitching algorithm in area splices target character.
If 2) upper subscript ocra font ocr, further determine that belonging to subscript has type, there was only subscript type, where there was only subscript type
It is a kind of.Belonging to the character element address of the basic element, the output of character locating module that are decomposed according to target splicing character and character
The stitching algorithm of type splices target character.
If 3) molecule denominator ocra font ocr, basic element, the molecule denominator ocra font ocr that character decomposes are spliced according to target
The character element address of output rule and the output of character locating module, splices target character.
If 4) compound splicing ocra font ocr, the basic element of character is spliced according to target, in conjunction with basic in font file
The character element address of characteristic element and the output of character locating module selects suitable joining method (not unique), quickly, efficiently
Splice target character.
Compared with prior art, the beneficial effects of the present invention are:
1, font can directly export in MSOE, be easy to use;
2, the font made is convenient for organization and management, and when needing corresponding font, installation be can be used;
3, it can be directed to specific industry, make corresponding font, the sector personnel is facilitated to use;
4, the character exported in technology document or report, printing is clear, and quality is high.
The embodiments described above only express several embodiments of the present invention, and the description thereof is more specific and detailed, but simultaneously
Limitations on the scope of the patent of the present invention therefore cannot be interpreted as.It should be pointed out that for those of ordinary skill in the art
For, without departing from the inventive concept of the premise, various modifications and improvements can be made, these belong to guarantor of the invention
Protect range.Therefore, the scope of protection of the patent of the invention shall be subject to the appended claims.