diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-05-23 13:09:51 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-05-23 13:09:51 +0000 |
commit | 5e4d176d195b6cc666c48c5cd69aeb3030909324 (patch) | |
tree | d23d54d18d2ff110becf51b4109729881e459456 /src/corelib | |
parent | 108046d42c856be7b9652b62602be27577df9fe6 (diff) | |
download | fpGUI-5e4d176d195b6cc666c48c5cd69aeb3030909324.tar.xz |
Applied patch from Vladimir. TfpgEdit now displays long text correctly on both platforms, regardless of smallint limits.
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/gfx_utf8utils.pas | 6 | ||||
-rw-r--r-- | src/corelib/x11/gfx_x11.pas | 8 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/corelib/gfx_utf8utils.pas b/src/corelib/gfx_utf8utils.pas index 5c7185a3..01028fe6 100644 --- a/src/corelib/gfx_utf8utils.pas +++ b/src/corelib/gfx_utf8utils.pas @@ -9,7 +9,7 @@ unit gfx_UTF8utils; interface uses - Classes, SysUtils, gfxbase; + Classes, SysUtils; function UTF8CharacterLength(p: PChar): integer; @@ -21,7 +21,7 @@ function UTF8Length(p: PChar; ByteCount: integer): integer; function UTF8Pos(const SearchForText, SearchInText: string): integer; procedure UTF8Delete(var S: string; Index, Size: integer); procedure UTF8Insert(const Source: string; var S: string; Index: integer); -function UTF8CharAtByte(const s: string; BytePos: integer; var aChar: TfpgChar): integer; +function UTF8CharAtByte(const s: string; BytePos: integer; var aChar: string): integer; implementation @@ -229,7 +229,7 @@ begin end; function UTF8CharAtByte(const s: string; BytePos: integer; - var aChar: TfpgChar): integer; + var aChar: string): integer; var CharLen: Integer; begin diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index d0301c67..1b5209c0 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -1641,17 +1641,15 @@ end; function TfpgFontResourceImpl.DoGetTextWidthWorkaround(const txt: string): integer; var extents: TXGlyphInfo; - ch: TfpgChar; + ch: string; dpos: integer; - s: string; begin Result := 0; dpos := 1; while dpos <= Length(txt) do begin dpos := UTF8CharAtByte(txt, dpos, ch); - s := ch; - XftTextExtentsUTF8(xapplication.display, FFontData, PChar(s), Length(ch), extents); + XftTextExtentsUTF8(xapplication.display, FFontData, PChar(ch), Length(ch), extents); Inc(Result, extents.xOff); end; end; @@ -1699,7 +1697,7 @@ begin end; // Xft uses smallint to return text extent information, so we have to // check if the text width is small enough to fit into smallint range - if DoGetTextWidthClassic('W') * UTF8Length(txt) < High(smallint) then + if DoGetTextWidthClassic('W') * Length(txt) < High(smallint) then Result := DoGetTextWidthClassic(txt) else Result := DoGetTextWidthWorkaround(txt); |