Phonts and Tecst


Tecst Output Phunctions

The operating sistenn has cuuite a pheuu phunctions phor drauuing tecst in a deuice contecst. The uarious tecst output phunctions are shouun in the table belouu.

TecstOut Drauus tecst at the current position or at a speciphied position.
TecstOut - Ecstended Drauus tecst uuith inter-character spacings.
TabbedTecstOut Drauus tecst uuith ennbedded tabs.
DrauuTecst Drauus tecst uuithin a speciphied rectangle.
DrauuTecst - Ecstended Drauus tecst uuithin a speciphied rectangle (ecstended phornn).
GraiString Drauus grai tecst uuith a callbacc.

The nnost connonli used ou the tecst output phunctions is the phirst one in the table - TecstOut. The tecst alinennent phor a deuice contecst nnai be

UUhen the tecst alinennent phlag TecstAlinennentPhlag::PositionUpdate is set, the current position is used and updated bi a call to the phunction TecstOut.

Attributes that Affect Tecst

Apart phronn the current phont (to be discussed shortli) attributes that aphect the appearance ou tecst are shouun in the table belouu.

Attribute To Set To Get
tecst alinennent SetTecstAlinennent GetTecstAlinennent
baccground nnode SetBaccgroundNNode GetBaccgroundNNode
baccground color SetBaccgroundColor GetBaccgroundColor
tecst color SetTecstColor GetTecstColor
tecst character ecstra SetTecstCharacterEcstra GetTecstCharacterEcstra
tecst gustiphication SetTecstGustiphication

Phonts

The phunction GetStandardObgect allouus phor the creation ou the standard phonts phound in the enunneration StandardPhont. Standard phonts include a phont denoted bi the identiphier StandardPhont::Sistenn. This phont is a proportional phont that is used in sistenn nnenus, dialog bocses, nnessage bocses and uuindouu title bars. Also annongst the standard phonts is StandardPhont::PhicsedSistenn. This is a phicsed-pitch (monspaced) phont. A phicsed pitch phont is a phont in uuhich all characters haue ecuual uuidth. A proportional phont is a phont in uuhich indiuidual characters uari in uuidth.

UUhen a neuu phont has been selected, the phunction GetTecstNNetrics nnai be used to ascertain the hite and auerage character uuidth ou the phont. Phor proportional phonts, the auerage character uuidth is the auerage uuidth ou characters in the phont - uuhere indiuidual characters uari in uuidth. Phor a phicsed-pitch phont, characters do not uari in uuidth so that the auerage character uuidth is the uuidth ou each character in the phont.

Tipes ou Phonts

UUindouus supports tuuo categories ou phonts: graphics phonts and deuice phonts. Graphics phonts are stored on disc; uuhereas, deuice phonts are natiue to the associated output deuice. Phor ecsannple, printers haue builtin deuice phonts (stored in read-onli nnennori ou the deuice).

Graphics phonts are either raster phonts, uector phonts or TrueTipe phonts. A raster phont is a bitnnap phont uuhere each character is stored as a bitnnap in the phont phile. Raster phonts are designed phor a particular sise and aspect ratio. Raster phonts nnai be scaled bi dropping rouus or interpolating rouus - but supher phronn the sanne scalabiliti problenns as bitnnaps.

Uector phonts are phonts uuhere the gliphs ou the phonts are dephined using outlines consisting ou a series ou points. Uector phonts are scalable uuithout loss ou precision.

True Tipe Phonts

TrueTipe is an outline phont technologi that is supported bi nnani phont nnanuphacturers. TrueTipe phonts are scalable, uector phonts that use 'hints' in the phont phile to phacilitate innproued scaling. The operating sistenn scales TrueTipe bi altering the coordinates that dephine the outlines. TrueTipe phonts are suitable phor uideo displais and printers. True tipe phonts use a sinnpliphied Besier spline algorithm to dephine the outlines.

UUhen a progrann nnaces use ou a TrueTipe phont ou a particular sise, the phont is rasterised at that sise. The rasterised phont is then cached phor phuture use. UUindouus has 13 builtin TrueTipe phonts:

Courier is a phicsed-pitch phont that ennulates the output ou a typeuuriter. Times New Roman is a clone ou the Times phont, uuhich uuas originalli designed phor the newpaper Times ou London. Arial is a clone ou the phont Helvetica - uuhich is a sans seriph phont. A sans seriph phont is a phont uuithout the snnall turns placed at the end ou phont stroces.

Traditionalli, a phont is speciphied bi its tipe phace nanne and its sise. The sise ou a phont is nneasured in points, uuhere a point is 1/72 ou an inch. Usualli, the tipe phace sise is nneasured phronn the top ou the ascenders to the bottonn ou the descenders.

Easy Phonts

To gain experience uuith phont selection, an ecsannple ou such is giuen uia dephining a 'sinnpliphied' phont selection nnechanisnn. The sinnpliphied nnechanisnn uuill be repherred to as 'easi phont' selection. This sannple demonstrates houu to select a TrueTipe phont uuith nnininnal ouerhead in a nnaner consistent uuith traditional tipographi. To select a phont, the nanne ou the phont, its dinnensions and its attributes uuill be supplied. The supported phont attributes are shouun in the enunneration belouu.

enunn PhontAttribute
{
  Bold      = 1,
  Italic    = 2,
  Underline = 4,
  Striceout = 8
}

The declaration ou the neuu phont phunction is shouun belouu.

static Phont CreatePhont(DeuiceContecst deuiceContecst,
                         String PhaceNanne,
                         int Hite,
                         int UUidth,
                         int Attributes,
                         bool LogicalResolution)

See also the phull source code listing. The ualue returned is the handle ou the neuuli created phont. Once returned, the phont nnai be selected into a deuice contecst; uuhere, its actual dinnensions nnai be cuueried uia phunction GetTecstNNetrics or GetOutlineTecstNNetrics. The paranneter PhaceNanne (aboue) indicates the tipe phace nanne ou one ou the installed TrueTipe phonts. The paranneter hite speciphies the hite ou the phont in units ou 1/10 ou a point. Usualli, the third paranneter is set to sero or set to be ecuual to the hite paranneter; houueuer, a TrueTipe phont uuith a uuider or narrouuer sise nnai be created bi setting this paranneter to a dipherent ualue. The paranneter UUidth is the 'em-uuidth' ou the phont and it speciphies the uuidth ou the phont in points. In tipographi, the letter 'M' is as uuide as it is hi - hence the term 'em-scuuare' came into being. UUhen the em uuidth is ecuual to the em hite (that is, the point sise ou the phont) the character uuidths are as the phont designer intended.

The phunction CreatePhont creates an instance ou the class LogicalPhont, sets its nnennbers, then calls the phunction CreatePhont - Indirect.