View Issue Details

IDProjectCategoryView StatusLast Update
0002011JEDI VCL00 JVCL Componentspublic2004-08-20 14:06
ReporterglchapmanAssigned ToAHUser 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0002011: Make TJvUnicodeCanvas uses unicode text measures
DescriptionTJvUnicodeCanvas calls TextWidth and TextExtent (rather than TextWidthW and TextExtentW) in a couple of places. Attached is a diff to correct this.
TagsNo tags attached.

Activities

2004-07-28 17:42

 

JvUnicodeCanvas.pas.diff (1,234 bytes)
*** JvUnicodeCanvas.pas.orig	Sat Jul 24 22:42:27 2004
--- JvUnicodeCanvas.pas	Wed Jul 28 17:38:10 2004
***************
*** 90,96 ****
    W: Integer;
  begin
    Changing;
!   W := TextWidth(Text);
    if CanvasOrientation = coRightToLeft then
      Inc(X, W + 1);
    Windows.ExtTextOutW(Handle, X, Y, TextFlags, nil, PWideChar(Text), Length(Text), nil);
--- 90,96 ----
    W: Integer;
  begin
    Changing;
!   W := TextWidthW(Text);
    if CanvasOrientation = coRightToLeft then
      Inc(X, W + 1);
    Windows.ExtTextOutW(Handle, X, Y, TextFlags, nil, PWideChar(Text), Length(Text), nil);
***************
*** 114,125 ****
  
  function TJvUnicodeCanvas.TextWidthW(const Text: WideString): Integer;
  begin
!   Result := TextExtent(Text).cx;
  end;
  
  function TJvUnicodeCanvas.TextHeightW(const Text: WideString): Integer;
  begin
!   Result := TextExtent(Text).cy;
  end;
  
  {$ENDIF VCL}
--- 114,125 ----
  
  function TJvUnicodeCanvas.TextWidthW(const Text: WideString): Integer;
  begin
!   Result := TextExtentW(Text).cx;
  end;
  
  function TJvUnicodeCanvas.TextHeightW(const Text: WideString): Integer;
  begin
!   Result := TextExtentW(Text).cy;
  end;
  
  {$ENDIF VCL}
JvUnicodeCanvas.pas.diff (1,234 bytes)

2004-07-28 18:05

 

JvUnicodeCanvas.pas.diff.2 (1,871 bytes)

glchapman

2004-07-28 18:06

reporter   ~0004853

I missed one use of TextWidth; the newly attached file (*diff.2) adds this correction.

user72

2004-07-29 06:11

  ~0004856

Are these functions available in Win9X?

anonymous

2004-07-29 08:53

viewer   ~0004857

The methods in question (TextExtentW and TextWidthW) are methods of TJvUnicodeCanvas, so they are available. Both methods ultimately end up with a call to GetTextExtentPoint32W, and, according to my SDK documentation, that function is implemented as both ANSI and Unicode on all platforms.

glchapman

2004-07-29 08:54

reporter   ~0004858

that was me above (I forgot to log in).

AHUser

2004-08-20 14:06

developer   ~0005054

Fixed in CVS.

Histroy:
The first implementation used overloaded methods so the function calls without the "W" were correct. But then a test run with Delphi 5 showed that D5 does not differ between AnsiString and WideString as parameter types. So the overloaded methods got a "W" and the code was not updated.

Issue History

Date Modified Username Field Change
2004-07-28 17:42 glchapman New Issue
2004-07-28 17:42 glchapman File Added: JvUnicodeCanvas.pas.diff
2004-07-28 18:05 glchapman File Added: JvUnicodeCanvas.pas.diff.2
2004-07-28 18:06 glchapman Note Added: 0004853
2004-07-29 06:11 user72 Note Added: 0004856
2004-07-29 08:53 anonymous Note Added: 0004857
2004-07-29 08:54 glchapman Note Added: 0004858
2004-08-20 14:06 AHUser Status new => resolved
2004-08-20 14:06 AHUser Resolution open => fixed
2004-08-20 14:06 AHUser Assigned To => AHUser
2004-08-20 14:06 AHUser Note Added: 0005054