Abstract

The scientific document industry has undergone an important progress in all steps especially in processing and presentation. However, it is still confronted with major obstacles when it has to manipulate documents containing mathematical formulas which are based on dynamic or variable-sized mathematical symbols and taking care of optical scaling. Normally, in processing documents, the composition of mathematical formulas is based on static fonts. The support of dynamic mathematical symbols requires, in addition to the choice of adequate type of fonts and text formatting tools, the development of a mathematical model allowing parametrizing the symbols to support optical scaling. In this paper, we present a method to supply stretching of Bézier curves representing symbols without losing the aspect of similarity and the geometric characteristics of the concerned symbols. The curves of dynamic symbols to be parametrized are designed on the basis of a new method that allows measuring similarity. The model can be extended later for the development of dynamic fonts respecting the rules of Arabic calligraphy. The method to evaluate the similarity can also be easily adapted in other fields such as image processing.

1. Overview

In the digital document industry, the presentation of some mathematical symbols, in terms of printing on papers or displaying on monitor screens, has not yet reached the quality offered by metal typesetting (old printing works). The problem relates exactly to symbols qualified to be dynamic. The latter change in size and/or shape depending on the context. Document processing relies on the text formatting (processing) tools and fonts encoding the characters. It is at the level of the fonts that the insufficiency of the support of the dynamic mathematical symbols resides. Precisely, what is missing is a mathematical model that supports this dynamism and thus allows improving the design (engineering) of dynamic fonts.

In scientific documents, mathematical formulas are composed of static and/or dynamic symbols. Using a font in a given size, the dimensions and shape of a static symbol do not change throughout the document. The character and the operator + are some examples representing the static class of symbols. A dynamic or variable-sized symbol varies in terms of size and/or sometimes shape depending on the context. As example of dynamic symbols, we can cite the hat diacritic modeling angles: and can be considered examples.

The most interesting variable-sized symbols are the delimiters such as parentheses and braces. These symbols’ sizes vary according to the typesetting context to delimit a mathematical formula. In Figure 1, braces are used to delimit mathematical scripts in different contexts. Note that the braces are of different sizes without being bound by a linear magnification ratio. Indeed, in terms of height as well as in terms of thickness, the ratios are not the same. This concept is called optical scaling. It is used to apply scaling taking into account the satisfaction of the reader’s eye. That is why it is called “optical.” The content of Figure 1 has been taken from an old book of mathematics [1], while the latter has been produced through printing based on metal typesetting.

The difference between linear scaling and optical scaling can be clearly seen when we consider examples of mathematical formulas with delimiters using computer fonts (instead of metal ones). Samples illustrating the two types of scaling are presented in Figures 2 and 3.

The support of optical scaling requires the development of a dynamic font. In [2, 3], the type of the font and the way to supply the concept of optical scaling are studied. Even, a PostScript Type 3 mini-font and a mini-package have been implemented and tested. In the present paper, the mathematical formalization supporting the work in [2, 3] is communicated. In reality, the support of the optical scaling and therefore the ability of processing scientific documents with good quality of typesetting are more a problem of finding a supporting mathematical model than of the choice of the type of fonts and the document processing tools. The author of [2, 3], in developing the package, obtained the support of the optical scaling on the basis of two tasks. The first one consists of linear scaling to determine the basic thickness of the mathematical symbol and the second one concerns scaling (a stretching) keeping the thickness previously obtained unchanged. The two tasks are illustrated in Figures 4 and 5. Figure 4 shows an abstract mathematical formula modeled by a simple gray rectangle. This mathematical formula is to be delimited by a left parenthesis. First, the parenthesis is set to the convenient dimensions of the body size . The font size has not been produced anyhow. It has been specifically calculated (see [2, 3] to get the idea on the way to calculate ). Then, the size of the half of the parenthesis is determined, which then makes it possible to deduce , the necessary amount to extend the half of parenthesis.

Figure 5 highlights the following step to support the optical scaling. The parenthesis obtained previously is stretched vertically according to the amount without acting on the thickness to cover all the abstract mathematical formula. The way to supply a nonlinear stretching model keeping the same thickness is the goal of the paper.

Also, with reference to Figure 5, in order to accomplish this extension, our model should ensure the conservation of some properties characterizing curves as the thickness, the geometric characteristics, and the similarity. We can verify visually these things by considering the parenthesis in Figures 4 and 5. Indeed, the PostScript font developed to be the base to handle dynamic symbols is parametrized according to a stretching model conserving these three properties.

The curve matching deals with the study of similarity. The notion of similarity has been studied a great deal and applied in many fields such as computer vision [4, 5], pattern recognition [6], and speech recognition [7]. In computational geometry, the correspondence between curves has been often computed by considering the curves as polylines. This has a meaning, since any curve to be processed in a computer should ultimately be discretized into series of connected segments. However, techniques for studying the similarity of continuous curves have been developed. The Fréchet distance, by its definition [8], can be used as a discrete and continuous mean to study the similarity. Other techniques, originally created to be applied in the discrete domain as DTW (Data Time Warping), have undergone extensions to support the case of continuous curves [9].

Our need is particular. The main concern consists of comparing two cubic Bézier curves. This comparison would provide a way to support a stretching model keeping similarity. Similarity constraints are not very strong in our case. Visually, the extended mathematical symbols should look as they were in the initial state. We do not need a technique based on curvatures like the “Fast Marching Method” or other approaches based on the minimization of paths or parametrizing functions as in [8, 9]. We will develop a method for comparing cubic Bézier curves (parametric curves) and, in particular, curves that result from a transform of other curves by similitude or other transformations such as optical scaling (that is not a linear magnification). This method will help in evaluating the exact or approached similarity. Actually, when the curve is the transform of another one by similitude, the similarity equals zero (exact similarity); otherwise, the method gives an approximate value to compare with a threshold. Here, we can explain a detail that will help us to make the difference between linear scaling and optical one: a linear scaling occurs when a shape is scaled everywhere according to a given ratio, for example, when similitude of ratio is applied to a geometric shape. On the other hand, optical scaling occurs when the shape undergoes unbalanced homothety (dilation) or some transformations which are not affine mappings.

The paper is organized as follows. The second section describes briefly some technical and aesthetic motivations to design a new font supporting dynamic mathematical symbols. In the third section, we define a way for comparing two curves linked by isometric or homothetic transformations. This method allows checking the similarity of two curves in an exact way. In the following section, we give a method to calculate the similarity between two curves which are not equal with respect to direct similitude. Then we present a method to study approximate similarity or similarity according to a given threshold . In the fifth section, a stretching model of cubic Bézier curves is defined. This model acts with conservation of the similarity, geometric characteristics, and the thickness between the curve and its stretched form. The paper ends with some conclusions and perspectives.

2. Some Technical and Aesthetic Motivations

The main goal of this paper consists in presenting a mathematical model that allows developing fonts of dynamic mathematical symbols. Let us consider the parenthesis as example of a dynamic symbol to introduce the motivations of such a project. We need first to recall in an abstract way how documents are printed through (LA)TEX systems. When printing a document formatted with (LA)TEX, the bitmaps of the characters are used instead of the METAFONT language encoding. It is well known that applying some scaling operations to bitmaps diminishes the quality of the images. Consequently, the support of dynamic fonts based directly on bitmaps is not a feasible way to print documents in good quality. The problem has already been solved otherwise by D. E. Knuth. The approach is presented considering the parenthesis. D. E. Knuth has designed stand-alone parentheses (not composed from other characters) of different sizes as shown in Figure 6. When the height of a mathematical formula is less than the heights of these five parentheses (see Figure 6), the closest parenthesis in terms of size is used to delimit the formula.

The previous idea cannot be used to solve entirely the problem, since it is necessary to give a large number of parentheses in different sizes to cover all the needs. In addition, we cannot predict in a meaningful way a maximum size of mathematical formulas. When a parenthesis of a height exceeding the highest stand-alone parenthesis is needed, (LA)TEX uses a compound parenthesis based on three characters: and . The last one is repeated as many times as needed between the first and the second to optimally cover the formula to be delimited. A sample of a compound parenthesis is shown in Figure 7. Two important things are noted. The first one concerns the fact that the parenthesis used being stand-alone or compound will not be always exactly of the same height as the formula to delimit. The second one relates particularly to the compound parenthesis. In fact, the latter part differs from the first five ones in terms of shape. This leads therefore to a loss of uniformity. Let us notice that these are the symbols in Figure 6 which are true parentheses.

DynMath, a package developed on the basis of the mathematical model presented in this article, allows managing parentheses in PostScript Type 3 of sizes satisfying exactly the needs of the formula. Even in the case of large formulas, the delimiter produced by DynMath retains the form of a parenthesis (see Figure 5).

It is very reasonable to consider motivations from an aesthetic point of view. First, we have to notice that the DynMath package comes to extend the formatting capabilities of (LA)TEX, concerning especially the aesthetic point of view. We can work with both in the same document. When it is to compare the mathematical delimiters of (LA)TEX and DynMath from the aesthetic point of view, people can have different opinions and this is natural. However, a kind of consecration of DynMath has already been done in the TUGboat 2016 conference held in Toronto, Canada [2, 3]. The work has been accepted and really appreciated.

A no less aesthetic motivation of the project is that the approach presented can be used to model the calligraphic stretchings of the characters of the Arabic script. The stretching of some letters can be accompanied by large deviations from the rules of Arabic calligraphy. An unacceptable writing through stretching some letters can rapidly be produced. The model can therefore help to prevent such uncomfortable situations.

3. Comparison of Bézier Curves Exactly Similar

The comparison of curves to supply the optical scaling is not a new idea. Actually, a work in mathematical formalization has been done as a mandatory part toward elaborating a dynamic font respecting the Arabic calligraphy [10, 11]. In that work, the stretching concerns only one curve and, in addition, the transformers of curves to compare are simply shifts. The content of this section and so, our method to study similarity, is based on some concepts developed in works such as [10, 11].

3.1. Comparison of Isometric Bézier Curves (Equality of Curves)

Definition 1 (equality of curves in plane). Let and be two cubic Bézier (parametrized) curves defined in . We define the equality relation:where and are centroids of control points of and , respectively.

Another way to write the equality of two curves is Then, the equality formula will be

The notion of direct orthogonal range is defined in [10]. Given a parametrized curve , the direct orthogonal range on with respect to a given vector is the amount , where . represents also a direct orthogonal range but relative to the vector and the centroid .

Let and be two cubic Bézier curves. We realize that if , then is the map of by an affine isometry. From this point of view, we will talk about or more precisely about isometric equality. We can say simply that the two curves are isometric.

3.2. Homothetic Based Comparison of Cubic Bézier Curves

In this part, we define an equality relation between curves with reference to homothetic transformations. This means that there is an isometric equality after applying homothety to one of the two curves.

Let us consider two Bézier curves and .

Definition 2 (homothetic equality). and are said to be in homothetic equality if and only if such that and are in isometric equality ().

Property 1. Let be a cubic Bézier (parametrized) curve; then the maps of by direct similitude are homothetically equal to .

Proof. By definition, a map of by an isometry is equal to and so the property is verified with .
Also for homothety of ratio , we will take .
Now, let us consider similitude .
Then, , where is an isometry and is homothety of ratio .It follows that .
But we have .
We get that and so .
From what comes, we get that .
So such that .

Now, it is time to define the notion of exact similarity (nonapproximative). The last will be used as a reference to define the similarity in an approximating way.

Definition 3 (exact similarity or 0-similarity). and are exactly similar or 0-similar if and only if such that . In other words,

4. Comparison of Cubic Bézier Curves Approximately Similar (-Similarity)

When two curves and are to be compared, suppose that is a map of by direct similitude; then there is an exact similarity between and , since we have

We have the equality of the direct orthogonal range for any . But, to get a similarity in the approximate sense, it is enough that the sum of modules of on approaches the value 0 or is less than (where ).

In addition to the almost null sum, to get the similarity, we add the fact that the two curves have the same geometric characteristics.

4.1. Summation of Squares of Orthogonal Range Differences

Consider the two curves and that are in Figures 8 and 9. is not obtained from by an affine mapping. There is no exact similarity between these two curves. However, they have the same geometric characteristics. Both are monotonic arches.

We aim at calculating the amount defined in the following equation:

is a coefficient allowing determining from , by homothety, a curve close, in terms of similarity, to . Let and be two curves to be compared; an important step consists in providing a way to determine a value of . For this, we need to define the notion of associated circle to a Bézier curve (Cf. Definition 4).

Definition 4 (associated circle). Consider a Bézier curve of control points , , , and . Let be the centroid of the points , , , and . This means that . Then, the circle associated with is the circle having as center and as a radius.

The two curves and are retaken in Figures 10 and 11 considering their associated circles. We notice that the two associated circles are not of the same dimensions.

Now, consider , where and are radii of circles associated, respectively, with and . Then the circle associated with has as radius. In other words, and have isometric associated circles and so they can be compared in terms of similarity. The curve is shown in Figure 12.

With a precision and the calculated , the value of defined in (5) is . The sum of squares of direct orthogonal range differences is less than ; let . We will simply say that and are -similar. One can have some criticisms on . In fact, what is a precision with value around a few thousands? We will understand that in the following and we will define, by the way, a method to study the similarity with acceptable precision around values close to zero.

Now, let one consider two curves and to be compared in terms of similarity relative to the same precision . Suppose that and verify and , where . Due to Definition 2, and are linked by an exact similarity. The same property is also satisfied between and . From the above, and are -similar. We can check that . We find that and then and are not -similar. So (5) does not allow the definition of an adequate method to study the similarity of curves.

The problem can be solved by comparing curves with passing to unit dimensions. The approach is presented considering the previous curves and . In order to compare these two curves in terms of similarity, it will be enough to compare and . We notice that the circles associated with these two curves have radii equal to 1. Then the value of the parameter will be one. Formula (5) becomeswhere and are radii of the circles associated with curves and , respectively.

An important property of the function can be stated.

Property 2. Consider two Bézier curves and . and are, respectively, radii of circles associated with and . Let and be two curves such that and . Then, we have

Proof. Let and be radii of the circles associated with and , respectively.
Since and , we have and
We get

With the comparison formula (6), we get

We notice that the value of similarity diminished comparatively to the obtained previously values.

The function can be written in another way that seems to be easier to link with defined in (5):

With , and are radii of circles associated with and .

The similarity measurement formula can be further improved by studying a set of properties to be verified by the sum of the squares of the orthogonal range differences when the curve is located in a given disc. This is the goal of the next section.

4.2. Some Properties on Discs (Unitary Discs) in and

We consider two sets and which are parts of the spaces and , respectively. is the disc, in the plane , centered at and is of radius . is the disc in (centered in ). The latter is the set of vectors in having norms at most equal to .

In comprehension, and are defined as follows:

Suppose that ; then

Two points and in the affine plane define a vector denoted as or simply . We adopt the last notation.

We can state a first property concerning the two parts.

Property 3. Let and . Then .

Proof. Let and and ; let us show that . We have So .
Consequently, .

Consider a Bézier curve of control points , , , and such that . The curve is of course a subset of , since is located into the convex hull defined by the four control points. This is one of the known properties of Bézier curves. Let us study the disc being able to contain the hodograph (the derivative of ). We can state the following property.

Property 4. Let be a Bézier curve of control points , , , and such that . Then we have the following:(i).(ii).

Proof. Let be the hodograph associated with () of control points , , and .From Property 3, .
So ( is contained in the convex hull defined through the control points , , and ).

In the sequel, we state a property that relates to cross product of a vector in disc and another in disc .

Property 5. Let and ; then .

Proof. Let and and , where .
We have and .
So .
We get that .
Consequently, .
Finally, we have

Property 6. We consider two Bézier curves and such that and . Let and be the centroids of control points of and , respectively. Then we have(1)(2)(3)

Proof. (1)We have , , , and .So and , got from Property 3.Also, we have and from Property 4.It follows that and according to Property 5.Consequently, we will get .(2)This point is a direct result of the previous one.(3)This point is a direct result of the previous one.

Property 7. Consider two Bézier curves and . Let and be radii of the circles associated with and . Then, we have

Proof. We have and .
So and .
Applying Property 6-(), we get Let

From this property, we notice that, for all Bézier curves and , the value would never exceed 576. This allows us to provide the final formula of the way to calculate the similarity between two curves relative to precision close to zero. We thus give the definition of the similarity with respect to a precision just after defining such that

Definition 5 (-similarity). We consider two cubic Bézier curves and . The numbers and represent the radii of the circles associated with these curves. Let and be the centroids of control points of and . Then and are -similar if and only if(1) and have the same geometric characterization,(2).

5. A Nonlinear Stretching Model Respecting Similarity

In this section, we will show how to define a nonlinear model for stretching of cubic Bézier curves respecting similarity and geometric characterization properties. For simplicity, a Bézier curve of control points , , , and will be simply denoted as (in particular, if the Bézier curve is of the first degree, this notation coincides exactly with the one adopted for a line segment).

5.1. Stretching Transformation

Let be a Bézier curve and is the Bézier curve obtained from via affine stretching (it can be linear). Then has the form with the following constraints:(i).(ii); this is the stretching Vector. and are stretching amounts in horizontal and vertical directions, respectively.Let be an affine transformation such that . is built to be most of the time a nonbalanced homothety or dilation (see next) (otherwise, we will have linear scaling). The matrix associated with and the map of are as follows:

Under constraints and , knowing that and , we will get(1),(2),(3),(4).Here, we notice that if , then we have an unbalanced dilation or homothety.

is an affine mapping. We know that, for every Bézier curve , and have the same geometric characteristics. What remains is to study the similarity of a curve and its stretched curve by such a transformation.

5.2. The Similarity and the Stretching Vector

To study the relationship between the similarity and the stretching vector ,  let us consider the case concerning the stretching of the parenthesis delimiting a mathematical formula. We present the concept for the top part of the left parenthesis only. It will be the same for the bottom part, since the parenthesis has a symmetric shape with respect to a horizontal axis. The study of the stretching of parenthesis reveals the following rule: to any vertical stretching amount corresponds a horizontal amount such that . To present the paragraph better, we will give details on the encoding of the top part of the parenthesis. This part of the parenthesis is encoded with two cubic Bézier curves and connected by two straight line segments at the top and bottom (see Figure 13). The parenthesis will be shown in 500 body size (half the effective encoding size in the font, 1000 body size). For the study of the relationship between the similarity and the stretching vector, we use only one of the curves, or . We choose to be used. Concretely,

Some stretchings of , with and taking values in the set , are done. However, the display of that in figures is given only in 128 body size so that the illustrations can fit into the page (in body size 128, it is similar to stretch the top part with respect to and ). Three of these stretching operations are shown in Figure 14(b), where , , and . The curve in its initial size is in Figure 14(a) to well situate the comparison states.

We can notice that, for a constant amount of the vertical extension , as the horizontal stretching increases to , the similarity between the curve and its stretched curve is more and more improved. Samples of this evolution are presented in Table 1.

As for horizontal variations, the similarity also loses its quality when increases. To give an illustration of this fact, some extracts of similarity values for varying from 0 to 2000 are presented in Table 2. For all values of , the considered amount of horizontal stretching is . We can see that the similarity becomes bad more and more as the value of increases.

5.3. Similarity and Bézier Curve Refinement

This section deals with the relationship between the similarity of curves and the decomposition of Bézier curves. Let us consider once again the two curves considered in the beginning (Figures 8 and 9) to study the effect of Bézier decomposition on them. Concretely, and are as follows:

The value of similarity between these two curves is . If we process a multiple Bézier’s decomposition of and and try to compare the similarity between the obtained subcurves of the same decomposition range, we can remark that the values of similarity diminish. Table 3 shows the values of similarity for the multiple decomposition of orders 0, 4, 9, 12, 13, and 19. Generally, from a decomposition of order , we get subcurves. Beyond order 13, the similarity of the decomposition segments becomes better than the similarity of the two curves without decomposition

To show the role of Bézier’s decomposition in similarity and extension, let us consider the curves defining the upper part of the left parenthesis together. The extension values used to highlight the problems are very large.

The height of the half-parenthesis is 490.27809 in the PostScript unit (see the concrete coordinates above). This height is given in 1000 body size (1000 is the base size for specifying a PostScript font). The notion of “body size” in PostScript is equivalent to “font size.” The height of paper is 421. We want to write the half-parenthesis in body 96. What value of must be used to stretch the half-parenthesis in 1000 body size so that it occupies the half of paper in 96 body size? The value of should be “3895.13857.” In fact:(i): global height of the stretched half parenthesis in 96 body size. .(ii): height of half parenthesis in 1000 body size 1000. .(iii): The stretching amount in 1000 body size (to determine).Then   and so .

Let .

The horizontal amount of stretching adopted to study the effect of decomposition is .

We saw in Section 5.1 how to stretch a Bézier curve with respect to an extension vector . How do we proceed in terms of extension if we decompose the curve into Bézier subcurves? Let be the sequence of the obtained curves by multidecomposition (the order of decomposition is ).

Let us consider the following items:(i): the Bézier curve to decompose and stretch(ii): the curve segment number obtained by decomposition, (iii), The curve would be stretched with respect to vector , where and . The transformation is defined by referring to Section 5.1. Some shift transformations are mandatory to connect the segments after the stretching operations.

We chose to give a concrete example, the parenthesis symbol. We worked with the 96 body size so that the concepts to be highlighted are more clear. The shape is delimited by two curves to be extended, namely, and . In fact, we must stretch and of the same vector . As we will see in the following, the simple stretching does not allow a global similarity of the parenthesis. This problem is solved by the Bézier multiple decomposition of the curves and . Suppose that we have to perform a decomposition of order in order to get Bézier subcurves. Let us consider the following items:(i).(ii) is the sequence obtained by the Bézier decomposition of to order .(iii)(iv) is the sequence obtained by the Bézier decomposition of to order .The stretching fractions of decomposition segments are determined relative to the curve and they are used also in the case of (nothing prevents the reverse). The goal of this is to obtain after extension a parenthesis having the same thickness as the initial one. Let .

Let and be the curves obtained by stretching of and , respectively, according to vector . The study of the relationship of Bézier decomposition and similarity is done by measuring the similarity values and . Some extracts are in Table 4.

The left half parenthesis (to stretch) is given in 96 body size in Figure 15(a). In Figure 15(b), the graphical shape is stretched without any Bézier decomposition. We can notice that, in this case, the delimiting curves on the top part overlap a little bit and therefore the overall similarity is not good. This problem is partially removed in Figure 15(c) and is further improved in Figure 15(d).

Table 4 shows the evolution of the similarities of the curves obtained by decomposition for the case of the vertical stretching and the horizontal one . For each case, the average of the similarities of the cubic Bézier segments obtained by decomposition is calculated. This average improves as the number of decompositions increases.

As an application of the stretching model, a dynamic mini-font and a mini-package called DynMath were designed and presented at TUG 2016. The illustration is interesting when considering the dynamic symbols such as delimiters, namely, the parentheses and the braces. These two symbols represent very well the class of dynamic mathematical symbols. Indeed, the parenthesis contains curves (not lines) without inflection, while the braces present inflections. With this model, one can now compose, for example, large parentheses and braces like those of the metal age printing (what is not possible with (LA)TEX). In Figures 16(a), 16(b), 17(a), and 17(b), a set of extensible symbols in normal (LA)TEX [12, 13] and their correspondents obtained when using DynMath are presented.

6. Conclusions

We have developed a basic formal approach to design a dynamic font that supports extensible mathematical symbols. This was used to develop a mini-font of four symbols, namely, parentheses and braces. The result is very satisfactory and ensures the good model for the development of other dynamic mathematical symbols. Our work will be extended in terms of the stretching model and the method to calculate the similarity in order to allow the development of dynamic fonts supporting the rules of Arabic calligraphy.

Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.