The information in this article applies to:
SUMMARY
This article defines the term "path" for the purposes of this article, and
it explains how you can get sample code (provided in TEXTFX.EXE, a self-
extracting file) that shows by example how to use paths to draw text at
varying angles, orientations, and sizes. In addition, the sample code gives
useful routines for displaying path data.
Textfx.exeFor more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. MORE INFORMATION
A path is one or more figures (or shapes) that are filled, outlined, or
both filled and outlined. Computer-aided design (CAD) applications use
paths to create unique clipping regions, to draw outlines of irregular
shapes, and to fill the interiors of irregular shapes.
Functions not supported under Windows 95:
Functions not supported in a path under Windows 95:
The following path functions are used in the TextFX sample:
To use TextFX, run it, and then draw two lines into the client area (they
don't have to be straight). The first line appears as blue and the second
appears as red. These lines serve as guides for how the text will be
rendered. After completing the second line, the text "This is a test" will
be drawn so that it appears between the two guide lines.
To remap the text so that it appears between the two lines, TextFX first breaks down the guide lines (which are composed of line segments) into distinct adjacent points. The result is that the x,y position of each point in the lines is adjacent to its neighboring points x,y position. Next, the text "This is a test" is drawn into a device context as a path. The points that make up the lines and curves in this path are then retrieved from the device context by using the GetPath() function. To reposition the points in the path data, the code must establish a relationship between the relative position of the points in the original text and the position defined by the guide lines. To establish this relationship, the code calculates the x and y positions of each point in the path data relative to the overall extent of the text string. The relative x position is used to calculate a corresponding point on each of the two the guide lines, while the relative y value is used as a weight to determine how far along on a line between the two guide-line points the remapped position should be. For example, if the point in the upper left corner of the "T" in the string "This is a test" is 2% of the total x extent of the string and 10% of the total y extent, then TextFX would find the point in each guide line that corresponds to 2% of the total number of points in that guide line. Then TextFX would reposition the point in the path data representing the upper left corner of the "T" so that it would be 10% of the way along an imaginary line extending from the point on the top guide line to the point on the bottom guide line. Two different methods can be selected for drawing the remapped data, one draws just the outline of the characters, while the other fills in the characters. To draw the outline of the characters, TextFX converts the remapped data back into a path and uses StrokePath() to display the outlines. To do the conversion, TextFX begins a new path, and then loops through the remapped data and uses the vertex types returned from GetPath() to determine how to draw the points. After drawing all the data, TextFX ends the path and calls StrokePath(). To draw the solid characters, instead of using StrokePath(), TextFX uses FillPath(). However, in order to get the interior areas of characters like "O", "A", "D", and so on, TextFX sets the ROP2 code to R2_MERGEPENNOT before calling FillPath(). This is done so that characters like "O" that consist of two separate polygons (one representing the outer perimeter and one representing the inner perimeter) will not be drawn as a solid blob. By drawing the polygons with the R2_MERGEPENNOT code, the code ensures that the second polygon will cancel the effects of the first in the area of the inner polygon. REFERENCESFor additional information on paths, please see the PATHS sample included with the Win32 SDK. Additional query words: stones effects effect font fx
Keywords : kbcode kbfile kbsample kbNTOS350 kbNTOS351 kbNTOS400 kbWinOS2000 kbSDKWin32 kbWinOS95 kbGDIFAQ |
Last Reviewed: December 15, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |