Raunarska grafika GDI Graphics Device Interface Plus Fonts

  • Slides: 19
Download presentation
Računarska grafika GDI+ (Graphics Device Interface Plus)

Računarska grafika GDI+ (Graphics Device Interface Plus)

Fonts glyph – an individual mark on a written medium that contributes to the

Fonts glyph – an individual mark on a written medium that contributes to the meaning of what is written. font – a complete character set of a single size and style of a particular typeface font family – set of fonts that share the same basicdesign typeface –design of fonts (line width, serif, . . . ) pitch – width of individual characters – fixed pitch – all characters have the same width – variable pitch – some characters are wider and some narrower serif – semi-structural details on the ends of some of the strokes that make up letters and symbols. (sans-serif -> not serif)

Font types Bitmap fonts - consist of a matrix of dots or pixels representing

Font types Bitmap fonts - consist of a matrix of dots or pixels representing the image of each glyph in each face and size. Outline fonts - (also called vector fonts) use Bézier curves, drawing instructions and mathematical formulae to describe each glyph, which make the character outlines scalable to any size. Stroke fonts - use a series of specified lines and additional information to define the profile, or size and shape of the line in a specific face, which together describe the appearance of the glyph.

Font formats True. Type – flexible, composed of lines and curves and additional information

Font formats True. Type – flexible, composed of lines and curves and additional information on each character (. FON and / or. TTF) Open. Type – extension of True. Type fonts, so that Adobe Post. Script support Compact File Format Clear. Type – Clear. Type is a software technology developed by Microsoft that improves the readability of text on existing LCDs

Font metric

Font metric

Draw. String • Draw. String(String s, Font font, Brush brush, Point. F point) •

Draw. String • Draw. String(String s, Font font, Brush brush, Point. F point) • Draw. String(String s, Font font, Brush brush, Point. F point, String. Format format) • Draw. String(String s, Font font, Brush brush, Rectangle. F layout) • s ▫ String to draw. • font ▫ Font that defines the text format of the string. • brush ▫ Brush that determines the color and texture of the drawn text. • point ▫ Point. F structure that specifies the upper-left corner of the drawn text. • format ▫ String. Format that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text. • layout ▫ Rectangle. F structure that specifies the location of the drawn text.

Draw. String g. Draw. String("Računarska grafika, I. Sarajevo", new Font("Arial", 26), new Solid. Brush(Color.

Draw. String g. Draw. String("Računarska grafika, I. Sarajevo", new Font("Arial", 26), new Solid. Brush(Color. Blue), new Point. F(100, 100));

Font • Font(String family, Single em. Size) • Font(String family, Single em. Size, Font.

Font • Font(String family, Single em. Size) • Font(String family, Single em. Size, Font. Style style, Graphics. Unit unit, Byte gdi. Char. Set) • family ▫ A string representation of the Font. Family for the new. Font. • em. Size ▫ The em-size of the new font in the units specified by the unit parameter. • style ▫ The Font. Style of the new font. • unit ▫ The Graphics. Unit of the new font. • gdi. Char. Set ▫ A Byte that specifies a GDI character set to use for this font.

Font. Style Name Description Regular Normal text. Bold text. Italic text. Underlined text. Strikeout

Font. Style Name Description Regular Normal text. Bold text. Italic text. Underlined text. Strikeout Text with a line through the middle. Font. Style stilic; stilic = Font. Style. Bold | Font. Style. Underline;

Font & Font. Style Solid. Brush cetkica = new Solid. Brush(Color. Blue); Font. Style

Font & Font. Style Solid. Brush cetkica = new Solid. Brush(Color. Blue); Font. Style stilic; stilic = Font. Style. Bold | Font. Style. Underline; Font fontic = new Font("Times New Roman", 26); g. Draw. String("Računarska grafika, I. Sarajevo", fontic, cetkica, new Point. F(100, 100)); fontic = new Font("Times New Roman", 26, stilic); g. Draw. String("Računarska grafika, I. Sarajevo", fontic, cetkica, new Point. F(100, 150));

Font & Font. Style

Font & Font. Style

String. Format • String. Format() • String. Format(String. Format. Flags options) ▫ Alignment ▫

String. Format • String. Format() • String. Format(String. Format. Flags options) ▫ Alignment ▫ Format. Flags ▫ Line. Alignment options ▫ The String. Format. Flags enumeration for the new. String. Format object.

String. Format. Flags Member name Direction. Right. To. Left Description Text is displayed from

String. Format. Flags Member name Direction. Right. To. Left Description Text is displayed from right to left. Direction. Vertical Fit. Black. Box Text is vertically aligned. Parts of characters are allowed to overhang the string's layout rectangle. By default, characters are repositioned to avoid any overhang. Display. Format. Control characters such as the left-to-right mark are shown in the output with a representative glyph. No. Font. Fallback to alternate fonts for characters not supported in the requested font is disabled. Any missing characters are displayed with the fonts missing glyph, usually an open square. Includes the trailing space at the end of each line. By default the boundary rectangle returned by the Measure. String method excludes the space at the end of each line. Set this flag to include that space in measurement. Text wrapping between lines when formatting within a rectangle is disabled. This flag is implied when a point is passed instead of a rectangle, or when the specified rectangle has a zero line length. Measure. Trailing. Spaces No. Wrap Line. Limit Only entire lines are laid out in the formatting rectangle. By default layout continues until the end of the text, or until no more lines are visible as a result of clipping, whichever comes first. Note that the default settings allow the last line to be partially obscured by a formatting rectangle that is not a whole multiple of the line height. To ensure that only whole lines are seen, specify this value and be careful to provide a formatting rectangle at least as tall as the height of one line. No. Clip Overhanging parts of glyphs, and unwrapped text reaching outside the formatting rectangle are allowed to show. By default all text and glyph parts reaching outside the formatting rectangle are clipped.

Font & Font. Style & String. Format format = new String. Format(); format. Alignment

Font & Font. Style & String. Format format = new String. Format(); format. Alignment = String. Alignment. Near; format. Flags = String. Format. Flags. Direction. Vertical; format. Line. Alignment = String. Alignment. Far; Solid. Brush cetkica = new Solid. Brush(Color. Blue); Font. Style stilic; stilic = Font. Style. Bold | Font. Style. Underline; fontic = new Font("Times New Roman", 26, stilic); g. Draw. String("Računarska grafika, I. Sarajevo", fontic, cetkica, new Point. F(100, 150), format);

Measure. String • Measure. String(String text, Font font) • Measure. String(String text, Font font,

Measure. String • Measure. String(String text, Font font) • Measure. String(String text, Font font, Size. F layout, String. Format string. Format) text ▫ String to measure. font ▫ Font defines the text format of the string. layout ▫ Size. F structure that specifies the maximum layout area for the text. string. Format ▫ String. Format that represents formatting information, such as line spacing, for the string.

Example Matrix matrica. Transformacija = new Matrix(); matrica. Transformacija. Translate(this. Client. Rectangle. Wid th/2,

Example Matrix matrica. Transformacija = new Matrix(); matrica. Transformacija. Translate(this. Client. Rectangle. Wid th/2, this. Client. Rectangle. Height/2); g. Transform = matrica. Transformacija; Brush cetkica = new Solid. Brush(Color. Black); Font fontic = new Font("Arial", 40); float x, y; const int Broj. Sati = 12; const int Stepeni. Izmedju. Dva. Broja = 360 / Broj. Sati; const int Poluprecnik. Sata = 300;

Example for (int i = 1; i <= Broj. Sati; i++) { x =

Example for (int i = 1; i <= Broj. Sati; i++) { x = Get. Cos(i * Stepeni. Izmedju. Dva. Broja + 90) * Poluprecnik. Sata; y = Get. Sin(i * Stepeni. Izmedju. Dva. Broja + 90) * Poluprecnik. Sata; String. Format format = new String. Format(); format. Alignment = String. Alignment. Center; format. Line. Alignment = String. Alignment. Center; g. Draw. String(i. To. String(), fontic, cetkica, -x, -y, format); }

Example for (int i = 1; i <= Broj. Sati; i++) { Size. F

Example for (int i = 1; i <= Broj. Sati; i++) { Size. F string. Size = g. Measure. String(i. To. String(), fontic); x = Get. Cos(i * Stepeni. Izmedju. Dva. Broja + 90) * Poluprecnik. Sata; x += string. Size. Width / 2; y = Get. Sin(i * Stepeni. Izmedju. Dva. Broja + 90) * Poluprecnik. Sata; y += string. Size. Height / 2; } g. Draw. String(i. To. String(), fontic, cetkica, -x, -y);

Example float Get. Sin(float Ugao. UStep) { return (float)Math. Sin(Math. PI * Ugao. UStep

Example float Get. Sin(float Ugao. UStep) { return (float)Math. Sin(Math. PI * Ugao. UStep / 180 f); } float Get. Cos(float Ugao. UStep) { return (float)Math. Cos(Math. PI * Ugao. UStep / 180 f); }