310 likes | 489 Views
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
E N D
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 • Type in action items as they come up • Click OK to dismiss this box • This will automatically create an Action Item slide at the end of your presentation with your points entered. Windows Programming Text and Fonts Presented By:- Anchal Sharma
Introduction • Text • Fonts • GDI (Graphics Device Interface) • Drawing and Filling • Windows APIs
Text Basics (Requirements) • Text • Tradition • Art • Technology • Soft proofing
Fonts Basics • Family (Roman) • Style (Italicize condense etc.) • Size (Point 1/72“)
Font Families A fontfamily 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.
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.
GDI • Abstraction • Device Independence • Responsibility of the programmer • Parts • Text • Filled Areas • Lines and curves • Bitmaps
Class Windows handle type CPen HPEN CBrush HBRUSH CFont HFONT CBitmap HBITMAP CPalette HPALETTE CRgn HRGN GDI Objects
Device Context • BeginPaint • GetDC / ReleaseDC • NULL param gives screen • Hwnd param gives client • CreateDC(“DISPLAY”,…); • GetWindowDC
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
Font Consistency • Embedding: • GetOutlineTextMetrics() otmfsType=1 OUTLINETEXTMETRIC structure • System Fonts • Using of Fonts • Enumeration • User Choice • Fixed type (sys fonts)
Font Storages (Windows) • Historically, font sizes were large to fit standard disks. • Just like .dll • Raster/Vector: .fon file contains data • OpenType/TrueType: .fon file is header and .ttf file contains the data
Character Set • Encoding scheme • Unicode (multi-byte codes) • OEM • Windows • Vendor (external like EBCDIC)
GDI (Co-ordinates/Mapping) • Mapping mode does not change messages • Screen Coordinates/Client Cordinates • SetViewPortOrgEx: Device • SetWindowOrgEx: Logical
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
Logical Inches • Size of inch is larger on display • Size of inch is same on printer
Drawing • Lines • MoveTo • LineTo • Bezier • PolyBezier • PolyBezierTo • Arcs • AngleArc • Arc, ArcTo
Creating Paths / Regions • Clipping • Filling • Drawing • Functions • BeginPath(hdc) draw lines etc. connected and then EndPath(hdc) • CreateRectRgn, CreateRoundRectRgn
Shapes Shapes Ellipse Pie Polygon Chord Rectangle
Styling the Shapes • Fill Brush • SetROP2 : Raster Operations • SetFillPoly • Winding • Alternate • FillRect, FillRoundRect
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.)
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
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.
tagTEXTMETRIC Structure • TEXTMETRIC • tmHeight • tmAscent • tmDescent • tmInternalLeading • tmExternalLeading • tmAveCharWidth • tmMaxCharWidth • tmOverhang • tmDigitizedAspectX • tmDigitizedAspectY • tmFirstChar • tmLastChar • tmDefaultChar • tmBreakChar • tmItalic • tmUnderlined • tmStruckOut • tmPitchAndFamily • tmCharSet
TMPF_FIXED_PITCH TMPF_VECTOR TMPF_TRUETYPE TMPF_DEVICE Pitch & Family 0X01 0X02 0X03 0X04
Font API’s • CreateFont, CreateFontIndirect, GetTextFace, GetTextMetrics. • lfCharSet : only value with default 1 • Struct: LOGFONT,CHOOSEFONT,PANOSE • GetOutlineTextMetrics: • PANOSE
WinNT/Win98 • SetGraphicsMode(GM_ADVANCED) • WinNt: escapement, orientations. • SetWorldTransform • Mode should be advanced
Kerning/Antialiasing • DWORD GetKerningPairs( HDC hdc, DWORD nNumPairs, LPKERNINGPAIR lpkrnpair); • Anti – aliasing: GetDeviceCaps
References • Charles Petzold, Programming Windows, 5th Edition • Text and Fonts, Msdn Library • Lines and Curves, Msdn Library • K.P. Rao, Printing classes
Thank You Questions?