Re: GetCharacterPlacement() problems

From: Mike D Sutton (EDais_at_mvps.org)
Date: 06/21/04


Date: Mon, 21 Jun 2004 11:58:10 +0100


> I'm getting very odd results when using the GCP_USEKERNING flag with GetCharacterPlacement() (either the ASCII or Wide versions of
> the call) when combined with GCP_MAXEXTENT to handle word wrapping - It appears to be calculating the max extent of the string
> incorrectly and returning a small number of characters able to be fit into the available space when there's space for plenty more.
> Are these flags incompatible with one another or is this a bug?
> Note; I've used GetFontLanguageInfo() to make sure that the selected font has a kerning table and am passing it's return value
(with
> FLI_GLYPHS masked off and GCP_MAXEXTENT appended) to the API call. With GCP_USEKERNING masked off too then I get correct results
> but if possible I'd like to include this for better quality character positioning output - is there some trick to make them play
> nicely together?

It looks like the problem is now resolved, in case anyone else has the same problem the way we fixed it was to call
GetCharaterPlacement() twice, the first with the GCP_MAXEXTENT flag only (and the return from GetFontLanguageInfo() with FLI_GLYPHS
and GCP_USEKERNING masked off) to get the number of characters of the string that could be displayed on the line. At that point you
can seek back to find the last break character then and trim the string if found, then send only that segment of the string back to
GetCharaterPlacement() for the kerning (and in our case optionally full justification.) Of course with extreme kerning the number
of characters on the line may be slightly off but for the most part it seems to work fine.
Hope this helps,

    Mike

P.s. If anyone else has had similar experiences with the call or knows of a better method then I'd be interested to hear about it.

 - Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: http://www.mvps.org/EDais/



Relevant Pages

  • DrawTextW with DT_CALCRECT returning zero width
    ... I'm trying to use DrawTextW with the DT_CALCRECT flag to find the ... width and height of a Unicode string. ... required characters; I've tried both Arial and Tahoma. ... If I remove the DT_CALCRECT flag the correct characters are drawn, ...
    (microsoft.public.win32.programmer.ui)
  • Which Characters are Bad?
    ... When we examine a string, a flag will go off iff the string has any ... tell which characters in the entire alphabet are bad? ...
    (sci.logic)
  • Re: Data logger using HP48GX
    ... this Computer Serial Temperature Meter & Data Logger, the output data is a continuous ... Use BUFLEN to see how many characters are in the 48 buffer, ... then DROP to get rid of the "result" flag in Level 1, ...
    (comp.sys.hp48)
  • Re: Limiting characters in a text field
    ... up a "rules of use" guide for all users of Project in your organization. ... In addition to just limiting the number of characters in text fields, ... control (i.e. TaskChange event macro). ... Set up a formula in a spare flag ...
    (microsoft.public.project)
  • Re: Writing a byte to a specific location in a file
    ... what kind of file it is, then encode the characters according to this. ... The preamble for an UTF8 file is the three bytes EF BB BF. ... The first character is a flag indicating the file has changed and the 2 - ... Below is a sub that I am using to try and update the first flag. ...
    (microsoft.public.dotnet.languages.vb)