--- In [email protected], "entropyreduction" <[EMAIL PROTECTED]> wrote:
>
> --- In [email protected], "entropyreduction" <powerp@> wrote:
> >
> > I'll try to think of a clever way of allowing such a thing, probably
> > by adding yet another modifier for "s".
> > 
> > In the meantime: how about making the last item a byteblock?  
> 
> ...<snip>...
> 
> Oops, that wouldn't work: I assume that when you say byteblock, 
> you mean unsigned char*. 
> 
> Rather than messing around with "string" type it's probably easiest to 
> change this definition of "byteblock" to mean scalar byteblock.  That
> will break all scripts currently using same, but someone has to
suffer...
> 
> > I'd also though of array of chars and for/endfor to fill the 
> > individual chars.
> 
> Like this:
> 
> local iLenFaceName = length(sFaceName)
> local arChars = dll.create_array(iLenFaceName+1, "char")
> 
> for (local i = 1; i le iLenFaceName; i++)
>   arChars[i] = select(sFaceName, 1, 1)
> endfor  
> arChars[iLenFaceName+1] = 0x0
> local tLogFont=dll.create_struct("i i i i i uc uc uc uc uc uc uc uc
> array",;;+
> nHeight,0,0,0,400,0,0,0,1,0,0,0,0,arChars)
> 
> getsize now returns the size you expect.
> 
> Tedious, but a workaround for now.
> 
> Be interested to see the script you're using it in.

I already did it yesterday after I understood the current behavior of
char types, however, I didn't post it as it crashed PP badly:
.GetTextSize("This is a test","Courier New",12)

Now, I tried again after this post, it worked fine this time:
.GetTextSize("This is a test","Tahoma",12)

So, there is a problem with a font name containing white space in it.

------------------ GetTextSize.PowerPro -------------------------------
args sString,sFaceName,nHeight,bold,italic
local hWnd,hDC,hFont,hFold,tLogFont,aSize,aName,nLeng,_1_

_1_=esc(?"\x01",?"\")

nLeng=length(sFaceName)
aName=dll.create_array(nLeng+1,"c")
for(local i=1;i<=nLeng;i++)
aName[i]=sFaceName[?"(?#1)(?s)(?<=.{"++i-1++?"})."]
endfor
aName[nLeng+1]=""

hWnd=0
hDC=dll.call("GetDC|ui",hWnd)
nHeight=0-dll.call("MulDiv|i i i",;;+
nHeight,dll.call("GetDeviceCaps|ui i",hDC,90),72)

tLogFont=dll.create_struct("i i i i i uc uc uc uc uc uc uc uc a",;;+
nHeight,0,0,0,400+300*bold,;;+
if(italic,_1_),"","",_1_,"","","","",aName)
hFont=dll.call("CreateFontIndirect|t* ui",tLogFont)
hFold=dll.call("SelectObject|ui ui",hDC,hFont)

aSize=dll.create_array(2,"i")
dll.call("GetTextExtentPoint32|ui s i a* b",;;+
hDC,sString,length(sString),aSize)

dll.call("SelectObject|ui ui",hDC,hFold)
dll.call("DeleteObject|ui",hFont)
dll.call("ReleaseDC|ui ui",hWnd,hDC)

win.debug("Width:"++aSize[1],"Height:"++aSize[2])
quit
-----------------------------------------------------------------------

Sean






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Groups gets a make over. See the new email design.
http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/JV_rlB/TM
--------------------------------------------------------------------~-> 

Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to