8
Cornput. & Graphics, Vol. 21, No. 3, pp. 321-328, 1997 CJ 1997 Elsevier Science Ltd. All rights reserved Printed in Great Britain 0097~8493197 $17.00 + 0.00 PII: soo97-8493(97)00009-5 Computer Graphics in China CHINESE FONT COMPOSITION METHOD BASED ON ALGEBRAIC SYSTEM OF GEOMETRIC SHAPES ZHIGENG PAN+, XIAOHU MA, MINGMIN ZHANG and JIAOYING SHI State Key Laboratory of CAD&CC, Zhejiang University, Hangzhou 310027, China e-m&l: [email protected]. Abstract-Font Composition may be used to generate multiple kinds of Chinese font to satisfy the requirements of desktop publishing, advertising and graphics arts. In this paper, we employ shape operation in algebra of geometric shapes to combine the styles of multiple fonts. We decompose the Chinese characters into individual strokes and perform composition. With this method, the part number of corresponding character and the tracing direction of individual contours are the same. In addition, the start points in contours have consistent relation and the quality of composed characters is improved. This method may also be used to simulate handwritten characters, generate dynamic Chinese font and morph 2-D geometric shapes. cQ 1997 Elsevier Science Ltd 1. INTRODUCTION With the rapid development of electric publishing and the wide application of computers in advertisements in China, various Chinese fonts are required [l]. The number of Chinese fonts available in computers is by far less than the number of English fonts available in computers. A primary reason is that the number of characters in a particular English font is not large, and the structure of individual characters is simple. Compared with English fonts, the number of Chinese characters in Chinese fonts is very large, and the structure of Chinese characters are complex. Design- ing an outline library based on curve description is time consuming (the whole process is: calligraphers write Chinese character samples, scan them into computers, remove noise, convert dot-matrix infor- mation into outline description) and very costly [2]. Thus in China, many research works have been done on automatic generation of Chinese fonts with the aid of computers and some achievements have been obtained [l. 3-71. Existing research works solve the problem of creation of Chinese font in the following three aspects. The first method presents a generation method of Chinese fonts based on calligraphy rules [I]: make quantification of the traditional calligraphy rules, describe them with knowledge, test and evaluate them by computers, modify the character shape based on the evaluation result. The second method makes changes to the structure features of Chinese characters (such as stroke width, shape of stroke end) based on the specific typeface [3-61. For example, Songti may derive special Songti with ’ Author for correspondence. (1) The same character in two different fonts should various stroke widths, Heiti may derive Yuantouti and Denxianti [3]. Concerning the two methods mentioned above, the first method has high efficiency compared with the traditional method. But the workload is still consider- able according to the introduction of the paper [ 11. In addition, the system has strict requirement on users’ aesthetic judgment and calligraphy capability. Since the second method is only based on one typeface, the variation is limited and the style is unitary. As we know, each font (typeface) has its own specific style and writing feature. If we can mix together the styles of two or more existing Chinese typefaces, then we can generate various Chinese fonts automaticall:{. Based on this idea, the authors of this paper presented the third method [7], which combine the typeface styles of two or more fonts. For example, we can combine the writing styles of Kaiti and Lisuti, forming a composition font called Kaili font. And the features of Kaiti and Lisuti may have different weight, thus resulting in enormous variation. Furthermore, we may combine the features of Sonti into the Kaili font to get .Kailisong font. With this method, any number of Chinese typefaces may be generated. Figure 1 shows a simple example. In the third method presented in this paper. we decompose the Chinese character outline in fonts F, and Fz (we use the combination of two Chinese typefaces as an example) into multiple connected sub-outlines, the corresponding connected sub-out- lines are combined with shape composition opera- tions in an algebraic system of geometric shapes (See Section 2). Omur experimental results indicate that the following conditions must be satisfied to perform the composition operation correctly: 321

Chinese font composition method based on algebraic system of geometric shapes

Embed Size (px)

Citation preview

Cornput. & Graphics, Vol. 21, No. 3, pp. 321-328, 1997 CJ 1997 Elsevier Science Ltd. All rights reserved

Printed in Great Britain 0097~8493197 $17.00 + 0.00

PII: soo97-8493(97)00009-5 Computer Graphics in China

CHINESE FONT COMPOSITION METHOD BASED ON ALGEBRAIC SYSTEM OF GEOMETRIC SHAPES

ZHIGENG PAN+, XIAOHU MA, MINGMIN ZHANG and JIAOYING SHI

State Key Laboratory of CAD&CC, Zhejiang University, Hangzhou 310027, China e-m&l: [email protected].

Abstract-Font Composition may be used to generate multiple kinds of Chinese font to satisfy the requirements of desktop publishing, advertising and graphics arts. In this paper, we employ shape operation in algebra of geometric shapes to combine the styles of multiple fonts. We decompose the Chinese characters into individual strokes and perform composition. With this method, the part number of corresponding character and the tracing direction of individual contours are the same. In addition, the start points in contours have consistent relation and the quality of composed characters is improved. This method may also be used to simulate handwritten characters, generate dynamic Chinese font and morph 2-D geometric shapes. cQ 1997 Elsevier Science Ltd

1. INTRODUCTION

With the rapid development of electric publishing and the wide application of computers in advertisements in China, various Chinese fonts are required [l]. The number of Chinese fonts available in computers is by far less than the number of English fonts available in computers. A primary reason is that the number of characters in a particular English font is not large, and the structure of individual characters is simple. Compared with English fonts, the number of Chinese characters in Chinese fonts is very large, and the structure of Chinese characters are complex. Design- ing an outline library based on curve description is time consuming (the whole process is: calligraphers write Chinese character samples, scan them into computers, remove noise, convert dot-matrix infor- mation into outline description) and very costly [2]. Thus in China, many research works have been done on automatic generation of Chinese fonts with the aid of computers and some achievements have been obtained [l. 3-71.

Existing research works solve the problem of creation of Chinese font in the following three aspects. The first method presents a generation method of Chinese fonts based on calligraphy rules [I]: make quantification of the traditional calligraphy rules, describe them with knowledge, test and evaluate them by computers, modify the character shape based on the evaluation result. The second method makes changes to the structure features of Chinese characters (such as stroke width, shape of stroke end) based on the specific typeface [3-61. For example, Songti may derive special Songti with

’ Author for correspondence. (1) The same character in two different fonts should

various stroke widths, Heiti may derive Yuantouti and Denxianti [3].

Concerning the two methods mentioned above, the first method has high efficiency compared with the traditional method. But the workload is still consider- able according to the introduction of the paper [ 11. In addition, the system has strict requirement on users’ aesthetic judgment and calligraphy capability. Since the second method is only based on one typeface, the variation is limited and the style is unitary.

As we know, each font (typeface) has its own specific style and writing feature. If we can mix together the styles of two or more existing Chinese typefaces, then we can generate various Chinese fonts automaticall:{. Based on this idea, the authors of this paper presented the third method [7], which combine the typeface styles of two or more fonts. For example, we can combine the writing styles of Kaiti and Lisuti, forming a composition font called Kaili font. And the features of Kaiti and Lisuti may have different weight, thus resulting in enormous variation. Furthermore, we may combine the features of Sonti into the Kaili font to get .Kailisong font. With this method, any number of Chinese typefaces may be generated. Figure 1 shows a simple example.

In the third method presented in this paper. we decompose the Chinese character outline in fonts F, and Fz (we use the combination of two Chinese typefaces as an example) into multiple connected sub-outlines, the corresponding connected sub-out- lines are combined with shape composition opera- tions in an algebraic system of geometric shapes (See Section 2). Omur experimental results indicate that the following conditions must be satisfied to perform the composition operation correctly:

321

Z. Pan, X. Ma, M. Zhang and J. Shi

Fig. 1. Example of Chinese characters composition with different styles (the middle X columns are composition font of Heiti and Kaiti).

be decomposed into same number of connected sub-outlines.

(2) The ordering of connected sub-outlines of specific Chinese characters in two fonts must be the same (otherwise. the combination may result in an error [see Fig. 2(a)]

(3) The start points of corresponding connected sub- outlines should have similar positions (otherwise the result is not correct [see Fig. 2(b)]

studied and widely applied. We usually denote an algebraic system by (A,R), where A represents an element set, Q represent operations on the element set. The operations in !A are specialized to perform the composition of two or more elements of A. which leads to another element of A. Some well-known algebraic systems include group, ring, field, and linear/vector space.

(4) The tracing direction of points in two connected sub-outlines should be same [Fig. 2(c) shows the situation which does not satisfy this condition].

It is not simple to decompose Chinese characters in existed outline libraries into connected sub-outlines which have same number and ordering. Many interactive operations are required to get the correct result. The reason is that the same Chinese characters in different fonts may have different numbers of connected sub-areas. If the number is different, then the composition operation cannot be performed. To our knowledge, the ordering of connected sub-out- lines. the start points of connected sub-outlines, and the tracing direction of points depend on the scan mode used in creation of the outline library. Further- more. when the sub-outline of a Chinese character is a little too large, the feature of the Chinese character may not be reflected well and minor distortion may appear [see Fig. 2(d)].

P. K. Ghosh [8,9] has obtained some useful results on the algebraic system of geometric shapes. To define the algebraic system of polygons, he intro- duced the concept of “negative shape” [9]. In such a system, operations such as addition (Minkowski addition) and subtraction (Minkowski subtraction) may be applied on polygons, the result is also a polygon, just as the addition and subtraction operations in integer system. In general algebraic systems, element set G is a set of 2-D planar areas which may be described by I-D closed boundary curve. We can use a shape description model based on the Fourier descriptor to express closed curves [ 10, Ill. Shape composition operations are defined in this description model. They include Fourier addi- tion and Fourier multiplication. The whole algebraic system of geometric shapes is described by the following equation:

To solve these problems, we present a new method for Chinese typeface composition. The basic idea is: decompose Chinese characters into strokes and perform a composition operation on these individual strokes. The paper is organized as follows. In Section 2. we introduce the basic concepts in algebraic system of geometric shapes and the Chinese typeface composition operation. In Section 3. we present the algorithm and its implementation based on a stroke outline library. In Section 4, we give some output samples to indicate the efficiency of our algorithm. Finally. we draw a conclusion.

< G. o, iv > (1)

In the shape description model based on the Fourier descriptor. closed curves are described with spatial functions f’(t), that are periodic. single- variable functions. If we assume that the period of f7 t) is T [that is, ,f(t + 117+) =,f’( t) for any integer n and real variable t], then we can express such a function as the following trigonometric series, called the Fourier series of the function f’(t):

f(t) = au + c(a,? cos(hzt/T) + h,, sin(2xnt/T)) n-l

(2)

2. CHINESE TYPEFACE COMPOSITION METHOD The coordinates describing closed curves have two 2. I. Algebraic system qf’geontetric shapes components X and Y. Thus we can describe the

The properties of abstract systems are extensively curve with x(t) and y(t). Similarly. function -u(r) and

Chinese font composition method 323 (a)

E I 0))

E (cl

3% (d)

Fig. 2. Examples showing the shortcomings of Chinese typeface composition based on connected outline, (a) Inconsistent ordering of connected sub-outline. (b) No correspondence in the start points of connected sub-outline. (c) Inconsistency in the tracing direction of points in connected sub-outlines. (d) Minor

distortion caused by “big” connected sub-outline.

l>(t) may also be expressed as the following Fourier series:

Like S(t), C(t) describing a closed curve is also a periodic function. We assume that C(t) = (x(t),y(t)). By applying the Fourier addition and Fourier multiplication operations to the Chinese font defined in Ref. [7]. we have:

By introducing algebra of geometric shapes, we can perform some processing operations on geo- metric objects according to the method in the algebraic syfltem, or reveal new geometric relations. Below we discuss Chinese typeface composition in detail by using the algebraic system of geometric shapes.

324 Z. Pan, X. Ma, M. Zhang and J. Shi

2.2. Method for Chinese typeface composition In this paper, we denote Chinese typeface compo-

sition as the combination of styles of two or more Chinese typefaces. The combined Chinese character has a new typeface. As we know, in Chinese outline library descriptions, a Chinese character may be described by multiple closed curves (a typical example is Bezier curve) C’,(t),C’,(t), ,C,(t). Let us assume that F, and F2 denote two fonts, for a specific Chinese character in these fonts, say Ci. I f it can be described by C,(t),C,(t), . ,C,(t) (in F1) and C,‘(r). C~‘(t),...,Cn’(t) (in Fz), then C,(t) and C’,‘(t) can be combined by the following equation:

C?(t) = rC,(t) @(I - r)C,‘(t) (6)

The Chinese character defined by Cy(t), Cy(t)... and CT(t) has a new style. It synthesizes the typeface styles of Fi and Fz. The result may be different when r is assigned a different value. There- fore, Equation (6) may generate various typefaces. Similarly, we can synthesize the styles of three or more fonts.

3. CHINESE TYPEFACE COMPOSITION ALGORITHM BASED ON STROKE OUTLINE

Based on the introduction in Section 1, to over- come the shortcoming of Chinese typeface composi- tion based on connected sub-outline, we present the Chinese typeface composition method based on the stroke outline library.

3.1. The creation of the stroke outline library In modern Chinese character description methods,

high quality fonts are produced from outline defini- tions of their glyphs. These outline definitions are constructed using straight line segments, circular arcs. conic sections, and Bezier curves, or any combination of these.

To get outline description (store the control points instead of all points on the bitmap) of a character bitmap (also as glyphs), we need to obtain a set of line segments or curve segments which describe the outline. A Chinese character is composed of various strokes. The average stroke number is about 15, so it will probably occur that one stroke intersects or attaches to another stroke. The usual method for generating outline description is to treat the Chinese character just as a bitmap (ignoring the fact that the Chinese character consists of strokes), so one stroke may be divided into several curve segments. If characters are scaled up just by transforming the coordinates of all control points, an acute angle in the original font may result in a smooth angle. In addition. the up part and down part or the left part and the right part of one identical stroke may lack consistency [ 12. 131.

In an outline library based on stroke description, the outline contour of a Chinese character is decomposed into many strokes. This method has three advantages. First, the consistency of a stroke is

held; when a Chinese character is zoomed with a large factor, the method can preserve the original shape without distortion. Second, the outline font file needs less memory space to store control points. Third, the method lays the foundation for analyzing the characteristic and calligraphy rules of Chinese characters. The method consists of two major steps:

(1) Extract the stroke from the dot-matrix (2) Obtain the outline description of the strokes

The stroke extraction is based on concave point and convex point [12]. The whole process can be described with the following algorithm.

A,. For every Chinese character in the Chinese font library, do step A? to As. A*. Find a connected area. For every connected area, do step As. As. Extract contours of a connected area. A4. Search for endpoint of a stroke, if it fails to find any endpoint (indicating that it has finished extracting strokes from the connected area), go to step Abr otherwise, go to step As. As. Extract a stroke starting from the stroke endpoint, record the contour data of the extracted stroke, go to A4. Ag, Organize the stroke description information of all Chinese characters together. thus forming an outline library based on stroke description.

3.2. Approximate calculation of Fourier series Before describing the Chinese character composi-

tion algorithm based on the stroke outline. we give the approximate calculation of the Fourier series in Equation (3). We can rewrite Equation (3) in the following form [lo]:

(7)

where the amplitude (also called the Fourier spectrum of X(t)) is defined as

lA,,I’ = at + hi = 5: k2 + 9 9: k,,cos OLi (8) r=l j=l

where the terms kl, kz, k,, and Bli depend only on .Y, and ti and not on n. 40, is the phase angle whose value is defined as arctan (2). Since the term n4 appears in the denominator, the value of IA,/‘, in general, become smaller with higher value of n. Therefore, we may perform approximate calculation by lower N terms [ll]. A few low-order terms of boundary curve’s Fourier expansion typically de- scribe the general shape rather well (for example, when N is 30, the result is perfectly good). This partial sum approximates the original curve and can be written as:

Chinese font composition method 325

Fig. 3. Output sample 1. (a) Composition of Heiti and Kaiti (8 rows in middle). (b) Composition of Songti and Kaiti (3 rows in middle). (c) Creation of 80 fonts based on two fonts by changing N in horizontal

direction and r in vertical direction (N= 1,2,. _. , 10: v=O.1.0.2,. ., 0.8).

326 Z. Pan, X. Ma, M. Zhang and J. Shi

XN(~) = a0 +~(anCOs$J+bn n=l

sin? >

YN(~) = CO + c(c,, COS?+~, sin? >

(9)

?I=1

Since the Fourier series is truncated after N harmonics, there are differences between the value of X,v(t) and that of x(t), and differences between the value Yd(t) and that of Y(t). We may define the error, E, as

c = max[pPlx(r) - X~(t)l,y~ I( Y(t) - Y~(t)l] (10)

In Equation (lo), rpJX(f) -&(t) is defined as the maximum value of Ix(t)1 -Xiv(t)\, for all t. When N > 30, the value of E is near 0.

As we know, a Chinese character is composed of multiple stroke outlines, and each stroke outline is described by a closed curve. To derive the Fourier coefficients in Equation (9), we assume that the closed curve is represented through polygon repre- sentation. Polygons can approximate a closed curve to any desired accuracy. Furthermore, we assume that the polygon is described by vertexes P,,Pz, .PK(Pl = PK), the coordinate of Pi is (xi,yi). According to the deviation in Ref. [7] and Equation (3), the coefficients of the Fourier expansion series are evaluated by the following formula.

L = 2 Al;. i=l

3.3. Chinese font composition algorithm Below we give the Chinese font composition

algorithm which uses two fonts. For the composition of three or more Chinese fonts, some minor modifications should be made to the algorithm. Let us assume that Chinese characters ch, and chz are from two stroke-based outline libraries correspond- ing to fonts FI and F,. The composition algorithm of Chinese characters chl and chz is described as:

A,. For each stroke outline si and si/ in Chinese characters chl and chz, do Steps ATA7 A2. Approximate si and s: with polygons, respec- tively. We assume that the vertexes of polygon corresponding to si are P,, P2, ,PK,, and vertexes of polygon corresponding to si are P,‘, Pz’, . . . . P*’ A3. Compute auxiliary parameters corresponding to s; and si/(Axi, AJ+, AI,, &, L)

(12)

where L is the perimeter of an outline, and we have:

Axi = X;+I - .xi,

AYE = yi+ I - l’i >

Ali = JG,

1, = 2 Ali, ,=I Fig

university name “**$J*$$?. 4. Output sample 2: varia ltion of our

Chinese font composition method 321

Fig. 5. Output sample 3. (a) Composition of 3 fonts (Heiti, Kaiti, Songti). (b) Composition of 4 fonts (Heiti, Kaiti, Songti, Yuantouti‘l.

A4. Compute the coefficients of Fourier expansion series (a”, a,, h,, co, c,, d,) by Equations (11) and 112). As. According to given N value and Equation (9). compute XN(~), YN(~), XN’(~) and Y,v’(t) corre- sponding to si and si’. Ah. For a given r, evaluate composite stroke description data, which is composed of a series of points. based on Equations (6) and (4). A7. Fit the obtained points with Bezier curve segment and line segment, thus regenerate the curve description of strokes.

3.4. Algorithm implementation The algorithm is implemented on a Sun SPARC

workstation with programming language C. The screen output capability is supported by a PostScript Level 2 library called PSLib [14], and the output samples is rendered with the Chinese version of PostScript Level 2 Interpreter called ZuPS. New fonts generated with our method may be down- loaded into ZuPS.

In implementing the algorithm, we also developed an ancillary font editor to do some necessary editing operations to Chinese characters in the stroke based outline library. Editing operations such as modifying the position of the start point of the stroke outline, changing the tracing direction and the order of

stroke outline are very important, since these error conditions unavoidably occur.

4. EXPERIMENTAL RESULTS AND CONCLUSION

Figures :I-5 show some experimental results rendered with the method presented in this paper. The Chinese characters in Figs 3 and 5 are selected randomly. Figure 4 shows the dynamic Chinese characters Iof our university name “$&~IA+?’ (Zhejiang University).

In this paper, we present a new method for combining Chinese typefaces based on algebra of geometric shapes. The Chinese outline font based on stroke description is used during the composing operation. Experiment results show that the method is effective and high quality fonts may be obtained (comparing l.he Chinese character “x1’ in Figs 1 and 3). The Fo-lrier multiplication introduced in this paper may be used to morph existing Chinese characters. In fact, the typeface combining operation in this context is an example of font morphing (for example, a Chinese character is changed from Kaiti to Sonti), which is very useful in advertisements. In addition, the method described here may be used to simulate handwritten Chinese characters and gener- ate dynamic Chinese fonts [15].

328 Z. Pan, X. Ma, M. Zhang and J. Shi

Acknowledgements-This research work is supported by the Nature Science Foundation of China and the Nature Science Foundation of Zhejiang Province. The authors are very grateful to Professor S. J. Cai, the Vice Director of the Computer Science Department at Nanjing University in China, for his providing Chinese character samples, and to Professor F. Y. Zhang, the Director of the Multimedia Research Institute at Nanjing University in China, for his advice and encouragement during the work.

REFERENCES

1. Jianping, F., Intelligent font design technique and an experimental system. Journal of Chinese Information, 1990, 4(3), l-11.

2. Xiaohu, M. and Zhigeng, P., The automatic generation algorithm of high quality outline font based on Bezier curve description. Acta Automation, Sinica, 1994. 20, 122-125 (in Chinese).

3. Weirong, Y. and Shijie, C., The derivation method of SongTi typeface based on stroke feature. Computer Engineering, 1994, 19, 692-699 (in Chinese).

4. Hua, Y. and Shijie, C., The design and implementation of a font generation system for variation of Heiti. Journal of Chinese Information, 1996, 8(3). 1422 (in Chinese).

5. Xiao, G. and Shijie, C., An automatic method for changing Heiti to Lisuti. Journal of Software, 1996, 6, 342-350 (in Chinese).

6. Bo, L., Shijie, C. and Jin, G., An automatic generation

method for Chinese font Hupo. Journal of Software, 1996, 6, 712-718 (in Chinese).

7. Zhigeng, P., Xiaohu, M., Mingmin, Z. and Jiaoying, S.. A generation system for multiple Chinese fonts based on Fourier descriptor. Journal of Software, 1996, 6, 486491 (in Chinese).

8. Ghosh, P. K., An algebra of polygons through the notion of negative shapes. CVGIP, 1991, 54, 119-144.

9. Ghosh, P. K. and Jain, P. K., An algebra of geometric shapes. IEEE Computer Graphics & Application, 1993, 13(9), 50-59.

10. Zahn, T.. Fourier descriptors for plane closed curves. IEEE Transactions on Computers, 1971, C-21,269-272.

11. Kubl, F. P. and Grardina, C. R., Elliptic Fourier features of a closed contour. Computer Graphics and Image Processing, 1982, 18, 236258.

12. Xiaohu. M., The study of fitting Chinese font using Bezier curve. Master Thesis, Nanjing University, 1991.

13. Xiaohu, M., Zhigeng. P. and Fuyan, Z., The automatic generation of Chinese outline font based on stroke extraction. Journal of Computer Science & Technology, 1995, 10,42-52.

14. Mingmin, Z., Xiaohu, M., Zhigeng, P. and Jiaying, S., ZuPS: a Chinese PostScript Level 2 Interpreter. In Proceedings of CAD/Graphics ‘95, Wuhan, China. October 1995, pp. 1297-1302.

15. Zhigeng, P., Xiaohu, M. and Jiaoying, S.. The automatic generation algorithm for dynamic Chinese font. Acta Automation, Sinica, 1996, 22, 591-596 (in Chinese).