Article View: borland.public.cppbuilder.nativeapi
Article #4444Re: Problem about Text Metrics (tmInternalLeading)
From: Eyyub Volkan �ektimur
Date: Wed, 25 Jan 2006 10:13
Date: Wed, 25 Jan 2006 10:13
104 lines
4627 bytes
4627 bytes
Hi,
thx for youyr effort. i got your point and tried to get metrics without
rotation. it seems it's working (with TA_BASELINE). i want to ask that are
your sure about is bounding box always as the same with non-rotated one ? i
tried with Arial & Verdana fonts and seems that they are same. as you said
windows fudges text height when the font rotated.
thx again so much. that really helped me...
P.S. : sorry , my first post gone wrong to your personal mail addr...
--
________________________________________
Eyyub Volkan �ektimur
Proya Software & Trade Inc.
Head of Core Development Department
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message
news:jijdt1du2lvrtfp5rd0m79m4qkn0d37far@4ax.com...
>
> Ok, here's what I found.
> MS fudges the text height when rotated.
> The rotated text height on screen is actually the same as non-rotated.
> So get the non-rotated height, and adjust the box.
> This is complicated by you using TA_TOP because you need to adjust the
> start location of the box. If you used TA_BOTTOM, you'd just need to
> use the correct height I think (and change the box calc for negative
> Y).
> This isn't perfect, but seems to be pretty close, at least at normal
> font sizes. Change Dy,Dx to 50,50, and it's off.
>
> POINT BoundingPoints[5] = {0};
> POINT P;
>
> HFONT Font = CreateFont(
> 0,0,//Dy,Dx,
> RotAngle*10, // angle of escapement
> RotAngle*10, // base-line orientation angle
> FW_NORMAL, // font weight
> FALSE, // italic attribute flag
> FALSE, // underline attribute flag
> FALSE, // strikeout attribute flag
> DEFAULT_CHARSET, // character set identifier
> OUT_DEVICE_PRECIS, // output precision
> CLIP_DEFAULT_PRECIS, // clipping precision
> PROOF_QUALITY, // output quality
> VARIABLE_PITCH+FF_DONTCARE, // pitch and family
> "Arial" // typeface name string
> );
> SelectObject(hdc,(HGDIOBJ)Font);
> SetTextAlign( hdc, TA_TOP );
> SetBkMode( hdc, OPAQUE ); /* shows full size of text field */
> TextOut( hdc, Org.x, Org.y, Text, lstrlen(Text) );
>
> SIZE lpSize;
> GetTextExtentPoint32( hdc, Text, lstrlen(Text), &lpSize );
> TextWidth = lpSize.cx;
>
> GetTextMetrics( hdc, &tm );
>
> switch( type )
> {case 0: // non-rotated
> TextHeight = lpSize.cy;
> OldTextHeight = TextHeight;
> OldAscent = tm.tmAscent;
> break;
> case 2: // 135 degrees
> TextHeight = OldTextHeight;
> Org.x += (tm.tmAscent - OldAscent);
> Org.y -= (tm.tmAscent - OldAscent);
> break;
> case 1: // 45 degrees
> TextHeight = OldTextHeight;
> Org.x += (tm.tmAscent - OldAscent);
> Org.y += (tm.tmAscent - OldAscent);
> break;
> case other:
> write the code for 225 and 315
> };
>
> BoundingPoints[1].x = TextWidth;
> BoundingPoints[2].x = TextWidth;
> BoundingPoints[2].y = TextHeight;
> BoundingPoints[3].y = TextHeight;
>
> // Apply Rotation Matrix to Points
> for( cx=0; cx<4; ++cx)
> {
> P=BoundingPoints[cx];
> BoundingPoints[cx].x = Org.x + (RotMatrix[0] * P.x) +
> (RotMatrix[1] * P.y);
> BoundingPoints[cx].y = Org.y + (RotMatrix[2] * P.x) +
> (RotMatrix[3] * P.y);
> };
> BoundingPoints[4] = BoundingPoints[0]; //Close the poly
>
> // Draw Boundary
> Polyline( hdc, BoundingPoints, 5 );
>
>
> Entire test code available if you need it.
>
>
>
Technical Details
Message-ID:
<43d74e24@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!feeder1.cambrium.nl!feed.tweaknews.nl!feeder.xsnews.nl!216.196.110.148.MISMATCH!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<43d0b85b$1@newsgroups.borland.com> <kr72t1lqf9lrur0iar1ob0kh4ftr56fn41@4ax.com> <43d49f33$1@newsgroups.borland.com> <851at1p99do8ies9ecclhq8augl9t26cnh@4ax.com> <43d641c4$1@newsgroups.borland.com> <8a1dt19a0kbk35sqtoq6sqdl5a2hn68u9i@4ax.com> <jijdt1du2lvrtfp5rd0m79m4qkn0d37far@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4faceab9e12cf298 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII From: "Eyyub Volkan �ektimur" <evcektimur@prokon.com.tr> Newsgroups: borland.public.cppbuilder.nativeapi References: <43d0b85b$1@newsgroups.borland.com> <kr72t1lqf9lrur0iar1ob0kh4ftr56fn41@4ax.com> <43d49f33$1@newsgroups.borland.com> <851at1p99do8ies9ecclhq8augl9t26cnh@4ax.com> <43d641c4$1@newsgroups.borland.com> <8a1dt19a0kbk35sqtoq6sqdl5a2hn68u9i@4ax.com> <jijdt1du2lvrtfp5rd0m79m4qkn0d37far@4ax.com> Subject: Re: Problem about Text Metrics (tmInternalLeading) Date: Wed, 25 Jan 2006 12:13:03 +0200 Lines: 106 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 85.100.115.217 Message-ID: <43d74e24@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1138183716 85.100.115.217 (25 Jan 2006 02:08:36 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!feeder1.cambrium.nl!feed.tweaknews.nl!feeder.xsnews.nl!216.196.110.148.MISMATCH!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail