windows programming

Post on 28-Jan-2016

71 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during your presentation In Slide Show, click on the right mouse button Select “Meeting Minder” Select the “Action Items” tab - PowerPoint PPT Presentation

TRANSCRIPT

Windows Programming

Text and Fonts

Presented By:-Anchal Sharma

2

Introduction

Text FontsGDI (Graphics Device Interface)Drawing and FillingWindows APIs

3

Text Basics (Requirements)

Text Tradition Art Technology

Soft proofing

4

Fonts Basics

Family (Roman)Style (Italicize condense etc.)Size (Point 1/72“)

5

Font Families

A font family is a set of fonts having common stroke width and serif characteristics. There are five font families. A sixth family allows an application to use the default font.

6

Font family Description

Decorative Specifies a novelty font. An example is Old English.

Dontcare Specifies a generic family name. This name is used when information about a font does not exist or does not matter. The default font is used.

Modern Specifies a monospace font with or without serifs. Monospace fonts are usually modern; examples include Pica, Elite, and Courier New.

Roman Specifies a proportional font with serifs. An example is Times New Roman.

Script Specifies a font that is designed to look like handwriting; examples include Script and Cursive.

Swiss Specifies a proportional font without serifs. An example is Arial.

7

Font Size

8

GDI

Abstraction Device Independence Responsibility of the programmer

Parts Text Filled Areas Lines and curves Bitmaps

9

GDI Objects

Class Windows handle type

CPen HPEN

CBrush HBRUSH

CFont HFONT

CBitmap HBITMAP

CPalette HPALETTE

CRgn HRGN

10

Device Context

BeginPaintGetDC / ReleaseDC NULL param gives screen Hwnd param gives client

CreateDC(“DISPLAY”,…);GetWindowDC

11

Fonts (Windows)

GDI Fonts / Device Fonts Raster(nonscaleable) : SYSTEM_FONT,

SYSTEM_FIXED_FONT, OEM_FIXED_FONT, Courier, Ms Serif, MS Sans Serif, Small Fonts

stroke : Connect the dots (Modern Roman Script) Plotter fonts

True Type / OpenType

GetStockObject Cannot be specific about selection DEFAULT_GUI_FONT: MS Sans Serif

12

Font Consistency

Embedding: GetOutlineTextMetrics() otmfsType=1

OUTLINETEXTMETRIC structure

System FontsUsing of Fonts Enumeration User Choice Fixed type (sys fonts)

13

Font Storages (Windows)

Historically, font sizes were large to fit standard disks.Just like .dllRaster/Vector: .fon file contains dataOpenType/TrueType: .fon file is header and .ttf file contains the data

14

Character Set

Encoding scheme Unicode (multi-byte codes) OEM Windows Vendor (external like EBCDIC)

15

GDI (Co-ordinates/Mapping)

Mapping mode does not change messagesScreen Coordinates/Client CordinatesSetViewPortOrgEx: DeviceSetWindowOrgEx: Logical

16

Mapping Mode Logical Unit x-axis y-axis

MM_TEXT Pixel Right Down

MM_LOMETRIC 0.1 mm Right Up

MM_HIMETRIC 0.01 mm Right Up

MM_LOENGLISH 0.01 in. Right Up

MM_HIENGLISH 0.001 in. Right Up

MM_TWIPS 1/1440 in. Right Up

MM_ISOTROPIC Arbitrary (x = y) Selectable Selectable

MM_ANISOTROPIC Arbitrary (x !=y) Selectable Selectable

Mapping Modes

17

Logical Inches

Size of inch is larger on displaySize of inch is same on printer

18

Drawing

Lines MoveTo LineTo

Bezier PolyBezier PolyBezierTo

Arcs AngleArc Arc, ArcTo

19

Creating Paths / Regions

ClippingFillingDrawingFunctions BeginPath(hdc) draw lines etc.

connected and then EndPath(hdc) CreateRectRgn, CreateRoundRectRgn

20

Shapes

Ellipse Pie Rectangle

ChordPolygon

Shapes

21

Styling the Shapes

Fill BrushSetROP2 : Raster OperationsSetFillPoly Winding Alternate

FillRect, FillRoundRect

22

Text APIs

TextOut(hdc,ystart,pString,iCount) Does not recognize null character

strings GDI function

TabbedTextOut(hdc,xStart,yStart,pString, iCount, iNumTabs, piTabStops, xTabOrigin); iNumTabs=NULL (def 8) iNumTabs=1 (piTabStops repeated arg.)

23

Text API s Cont…

ExtTextOut(hdc,xSt,ySt,iOpt, &rect,pString, iCount, pxDistance); ETO_CLIPPED , ETO_OPAQUE, pxDistance=spacings,

null for def.

DrawText(hdc,pString,iCount, &rect,iFormat); Recognize null terminated Strings. Also \n \r \t For \t use DT_EXPANDTABS If TA_CENTER then ½ text DT_TABSTOP

DrawTextEx(hdc,pString,iCount,&rect, iFormat,&drawtextparams); Works on avg character increments

24

Text API’s Cont…

SetTextCharacterExtra(hdc, iExtra); iExtra cannot be –ve (absolute value

taken)

TEXTMETRICS tm.Hieght is not font size it includes

internal leading.

25

tagTEXTMETRIC Structure

TEXTMETRIC tmHeight tmAscent tmDescent tmInternalLeading tmExternalLeading tmAveCharWidth tmMaxCharWidth tmOverhang tmDigitizedAspectX tmDigitizedAspectY

tmFirstChartmLastChartmDefaultChar tmBreakChar tmItalic tmUnderlined tmStruckOut tmPitchAndFamily tmCharSet

26

Pitch & Family

TMPF_FIXED_PITCH

TMPF_VECTOR

TMPF_TRUETYPE

TMPF_DEVICE

0X01

0X02

0X03

0X04

27

Font API’s

CreateFont, CreateFontIndirect, GetTextFace, GetTextMetrics.lfCharSet : only value with default 1Struct: LOGFONT,CHOOSEFONT,PANOSEGetOutlineTextMetrics: PANOSE

28

WinNT/Win98

SetGraphicsMode(GM_ADVANCED) WinNt: escapement, orientations.

SetWorldTransform Mode should be advanced

29

Kerning/Antialiasing

DWORD GetKerningPairs( HDC hdc, DWORD nNumPairs, LPKERNINGPAIR lpkrnpair);Anti – aliasing: GetDeviceCaps

30

References

Charles Petzold, Programming Windows, 5th EditionText and Fonts, Msdn LibraryLines and Curves, Msdn LibraryK.P. Rao, Printing classes

31

Thank You

Questions?

top related