Talk:Get localised font name: Difference between revisions
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 24: | Line 24: | ||
Alex Che Korotkin | Alex Che Korotkin | ||
---- | |||
System::Call *(&w${NSIS_MAX_STRLEN})i.R2 is probably a better alternative (You can verify this with System::Call kernel32::GlobalSize(iR2)i.r1 ). | System::Call *(&w${NSIS_MAX_STRLEN})i.R2 is probably a better alternative (You can verify this with System::Call kernel32::GlobalSize(iR2)i.r1 ). | ||
Line 34: | Line 34: | ||
---- | ---- | ||
Anders, you're right. | |||
My code won't work for non-Unicode version of NSIS, because System::StrAlloc in this case will allocate non-Unicode string, while the code explicitly uses the Unicode version of system function: GetFontResourceInfoW. | |||
I changed the lines to | |||
System::Call *(&w${NSIS_MAX_STRLEN})i.R2 | |||
System::Call kernel32::GlobalSize(iR2)i.R1 | |||
System::Call *(i$R1)i.R1 | |||
and it works OK in the Unicode NSIS. | |||
Thanks. | |||
Alex Che Korotkin |
Latest revision as of 09:05, 6 May 2011
Hi,
Probably there is a bug in the code. The code first allocates a block of ${NSIS_MAX_STRLEN} bytes, but then copies it to $R0 as a WCHAR string of ${NSIS_MAX_STRLEN} characters, which are actually ${NSIS_MAX_STRLEN} * 2 bytes.
With the Unicode NSIS I have the code crashing from time to time on the line:
System::Call *$R2(&w${NSIS_MAX_STRLEN}.R0)
I fixed the code by replacing the following lines:
System::Call *(i${NSIS_MAX_STRLEN})i.R1 System::Alloc ${NSIS_MAX_STRLEN} Pop $R2
with the new lines:
IntOp $R1 ${NSIS_MAX_STRLEN} * 2 ; number of bytes in WCHAR string of NSIS_MAX_STRLEN length System::Call *(i$R1)i.R1 System::StrAlloc ${NSIS_MAX_STRLEN} Pop $R2
I am not a NSIS expert, so the code may be not the most efficient. If my assumption is correct, please, update the code in case everyone else needs it. Thanks.
Alex Che Korotkin
System::Call *(&w${NSIS_MAX_STRLEN})i.R2 is probably a better alternative (You can verify this with System::Call kernel32::GlobalSize(iR2)i.r1 ).
NSIS_CHAR_SIZE is defined as 2 in the unicode build (There might be a NSIS_MAX_STRLEN as bytes define, I don't remember)
--Anders 17:40, 5 May 2011 (UTC)
Anders, you're right. My code won't work for non-Unicode version of NSIS, because System::StrAlloc in this case will allocate non-Unicode string, while the code explicitly uses the Unicode version of system function: GetFontResourceInfoW. I changed the lines to
System::Call *(&w${NSIS_MAX_STRLEN})i.R2 System::Call kernel32::GlobalSize(iR2)i.R1 System::Call *(i$R1)i.R1
and it works OK in the Unicode NSIS. Thanks.
Alex Che Korotkin