 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Paul Nicholls Guest
|
Posted: Tue Feb 08, 2005 4:26 am Post subject: Finding non-blank chars in a true type font? |
|
|
Hi all,
I want to be able to pick out N non-blank symbols (if possible) from a
true type font...
In order to do this, I need a way of detecting if a particular character in
a font is non-blank.
Any ideas?
--
Cheers,
Paul.
"The plastic veneer of civilization is easily melted in the heat of the
moment" - Paul Nicholls.
[email]paul_nicholls (AT) hotmail (DOT) NOSPAM.com[/email]
Remove ".NOSPAM" to reply.
|
|
| Back to top |
|
 |
Soeren Muehlbauer Guest
|
Posted: Tue Feb 08, 2005 6:19 am Post subject: Re: Finding non-blank chars in a true type font? |
|
|
Hi,
| Quote: | I want to be able to pick out N non-blank symbols (if possible) from a
true type font...
In order to do this, I need a way of detecting if a particular character in
a font is non-blank.
|
You could try GetGlyphOutline from Win32API with the Parameter
GGO_NATIVE. The Result will be a series of contours. If there are no
contours then the glyph is blank.
HTH, Soeren
|
|
| Back to top |
|
 |
Paul Nicholls Guest
|
Posted: Tue Feb 08, 2005 10:09 pm Post subject: Re: Finding non-blank chars in a true type font? |
|
|
"Soeren Muehlbauer" <soeren.dd (AT) gmx (DOT) de> wrote
| Quote: | Hi,
I want to be able to pick out N non-blank symbols (if possible) from
a true type font...
In order to do this, I need a way of detecting if a particular character
in a font is non-blank.
You could try GetGlyphOutline from Win32API with the Parameter GGO_NATIVE.
The Result will be a series of contours. If there are no contours then the
glyph is blank.
HTH, Soeren
|
Thanks Soeren, I will try this :-)
cheers,
Paul.
|
|
| Back to top |
|
 |
Paul Nicholls Guest
|
Posted: Tue Feb 08, 2005 10:30 pm Post subject: Re: Finding non-blank chars in a true type font? |
|
|
"Soeren Muehlbauer" <soeren.dd (AT) gmx (DOT) de> wrote
| Quote: | Hi,
I want to be able to pick out N non-blank symbols (if possible) from
a true type font...
In order to do this, I need a way of detecting if a particular character
in a font is non-blank.
You could try GetGlyphOutline from Win32API with the Parameter GGO_NATIVE.
The Result will be a series of contours. If there are no contours then the
glyph is blank.
HTH, Soeren
|
I have tried this code:
function FontCharIsEmpty(h: HDC; c: Word): Boolean;
var
gm: _GLYPHMETRICS;
m: _MAT2;
begin
Result := GetGlyphOutline(h,c,GGO_NATIVE,gm,0,nil,m) = 0;
end;
where I am passing in the Canvas.Handle for h from a TPaintBox component
which has a font, and c is the character value...
I have looked at the result for c being both 32 (space) and 65 ('A') and
both times it returns false :(
I have tried various control Handles, but to no avail...
What am I doing wrong?
cheers,
Paul.
|
|
| Back to top |
|
 |
Soeren Muehlbauer Guest
|
Posted: Wed Feb 09, 2005 7:08 am Post subject: Re: Finding non-blank chars in a true type font? |
|
|
Hi,
| Quote: |
function FontCharIsEmpty(h: HDC; c: Word): Boolean;
var
gm: _GLYPHMETRICS;
m: _MAT2;
begin
Result := GetGlyphOutline(h,c,GGO_NATIVE,gm,0,nil,m) = 0;
end;
where I am passing in the Canvas.Handle for h from a TPaintBox component
which has a font, and c is the character value...
I have looked at the result for c being both 32 (space) and 65 ('A') and
both times it returns false :(
What am I doing wrong?
|
First: You have to initialize the _MAT2:
function FontCharIsEmpty(h: HDC; c: Word): Boolean;
var
gm: _GLYPHMETRICS;
m: _MAT2;
ReqSize: DWORD;
P: Pointer;
Head: ^TTPOLYGONHEADER;
begin
M.eM11.Value := 1;
M.eM11.fract := 0;
M.eM12.Value := 0;
M.eM12.fract := 0;
M.eM21.Value := 0;
M.eM21.fract := 0;
M.eM22.Value := 1;
M.eM22.fract := 0;
ReqSize := GetGlyphOutline(h,c,GGO_NATIVE,gm,0,nil,m);
if ReqSize > 0 then
begin
GetMem(P, ReqSize);
try
if GetGlyphOutline(h,c,GGO_NATIVE,gm,ReqSize,P,m) > 0 then
begin
Head := P;
//[..Test here..]
end;
finally
FreeMem(P);
end;
end;
end;
HTH, Soeren
|
|
| Back to top |
|
 |
Paul Nicholls Guest
|
Posted: Wed Feb 09, 2005 10:26 pm Post subject: Re: Finding non-blank chars in a true type font? |
|
|
"Soeren Muehlbauer" <soeren.dd (AT) gmx (DOT) de> wrote
<SNIP>
| Quote: | First: You have to initialize the _MAT2:
function FontCharIsEmpty(h: HDC; c: Word): Boolean;
var
gm: _GLYPHMETRICS;
m: _MAT2;
ReqSize: DWORD;
P: Pointer;
Head: ^TTPOLYGONHEADER;
begin
M.eM11.Value := 1;
M.eM11.fract := 0;
M.eM12.Value := 0;
M.eM12.fract := 0;
M.eM21.Value := 0;
M.eM21.fract := 0;
M.eM22.Value := 1;
M.eM22.fract := 0;
ReqSize := GetGlyphOutline(h,c,GGO_NATIVE,gm,0,nil,m);
if ReqSize > 0 then
begin
GetMem(P, ReqSize);
try
if GetGlyphOutline(h,c,GGO_NATIVE,gm,ReqSize,P,m) > 0 then
begin
Head := P;
//[..Test here..]
|
I am not sure what you mean by Test here...
what should I be checking to see if the char is empty?
ReqSize > 0?
Head.cb?
Head.dwType?
Head.pfxStart?
| Quote: | end;
finally
FreeMem(P);
end;
end;
end;
HTH, Soeren
|
Paul.
|
|
| Back to top |
|
 |
Soeren Muehlbauer Guest
|
Posted: Fri Feb 11, 2005 2:10 pm Post subject: Re: Finding non-blank chars in a true type font? |
|
|
Hi,
Test the ReqSize. If it returns 0 then there is no contuor.
Your test can be after the first call to getglyphoutlines
HTH, Soeren
Paul Nicholls schrieb:
| Quote: | "Soeren Muehlbauer" <soeren.dd (AT) gmx (DOT) de> wrote in message
news:4209b748$1 (AT) newsgroups (DOT) borland.com...
SNIP
First: You have to initialize the _MAT2:
function FontCharIsEmpty(h: HDC; c: Word): Boolean;
var
gm: _GLYPHMETRICS;
m: _MAT2;
ReqSize: DWORD;
P: Pointer;
Head: ^TTPOLYGONHEADER;
begin
M.eM11.Value := 1;
M.eM11.fract := 0;
M.eM12.Value := 0;
M.eM12.fract := 0;
M.eM21.Value := 0;
M.eM21.fract := 0;
M.eM22.Value := 1;
M.eM22.fract := 0;
ReqSize := GetGlyphOutline(h,c,GGO_NATIVE,gm,0,nil,m);
if ReqSize > 0 then
begin
GetMem(P, ReqSize);
try
if GetGlyphOutline(h,c,GGO_NATIVE,gm,ReqSize,P,m) > 0 then
begin
Head := P;
//[..Test here..]
I am not sure what you mean by Test here...
what should I be checking to see if the char is empty?
ReqSize > 0?
Head.cb?
Head.dwType?
Head.pfxStart?
end;
finally
FreeMem(P);
end;
end;
end;
HTH, Soeren
Paul.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|