Path: utzoo!attcan!uunet!samsung!usc!apple!netcom!mcmahan From: mcmahan@netcom.UUCP (Dave Mc Mahan) Newsgroups: comp.sys.amiga.tech Subject: Re: How find width of prop. Font character? Message-ID: <14720@netcom.UUCP> Date: 14 Oct 90 04:43:44 GMT References: <34830@cup.portal.com> Organization: Dave McMahan @ NetCom Services Lines: 29 In a previous article, Lee_Robert_Willis@cup.portal.com writes: > > >Does anyone know how to find the width of a single character within >a proportional font, without using 'TextLength()'? (The font/character >pair may not be the current font of the RastPort.) > >Using the RKM section on Text (1.3 Chapter 24), I constructed the >following function. It checks if the font is proportional or not, >If it is, it then returns the sum of 'tf_CharSpace' + 'tf_CharKern' >for the supplied character 'c'. > >Unfortunately, this does not appear to be correct. It comes close, >but I appear to be short a pixel or two with each character. I'm stuck. Have you thought about using the function called IntuiTextLength() with the IntuiText string equal to the character you wish to know the width of? I would guess that all you need to do is declare an IntuiText structure, put the desired character in a NULL terminated string of length 1, set the IntuiText.IText field to the address of the string, and set the ITextFont to the proper font. This function would (I assume) give you what you want. Of couse, I have never tried it with proportional fonts, so you just never know, do you? :-) > Lee > (Lee_Robert_Willis@cup.portal.com) -dave