Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Get locale font name of a TTF file (http://forums.winamp.com/showthread.php?t=318951)

jiake 5th May 2010 08:02

Get locale font name of a TTF file
 
I have tried the FontName plugin, but the name it got is not what I want. It got the English name of the font. If I copy a ttf file to the Fonts folder, first I will see the Chinese name of the font in Fonts of Control Pannel, and also in the registry key "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" I can find that the Chinese name, such as "微软雅黑 (TrueType)", of the font. But when using the FontName plugin I will only got the name "Microsoft Yahei".

If I inst the ttf file to fonts directory, I just need to copy the ttf file to there and using:
PHP Code:

SetOutPath $FONTS
File MSYH
.TTF
System
::Call "GDI32::AddFontResource(t) i ('MSYH.TTF') .s" 

It is a easy way and the value in registry is correct. But if I want to inst it to my directory, I must use:
PHP Code:

SetOutPath $INSTDIR\TrueType
File MSYH
.TTF
WriteRegStr HKLM 
"Software\Microsoft\Windows NT\CurrentVersion\Fonts" "微软雅黑 (TrueType)" "$INSTDIR\TrueType\MSYH.TTF"
System::Call "GDI32::AddFontResource(t) i ('$INSTDIR\TrueType\MSYH.TTF') .s" 

When there are a large number of fonts to install to custom directory, I must write each font name to registry but not using the FontName plugin, as the reason above. After searching by google, I founder that a function GetTextFaceA. But I don't know how to use it to get the name of a font. Please help me.

Afrow UK 5th May 2010 14:03

The FontName plug-in does not use the uLanguageID parameter of the TT_NAME_RECORD structure when reading strings from the TT_NAME_TABLE_HEADER struct and is returning the first font name it finds (1033 I guess, but that may not always be the case?) You should contact the author and ask him to add a switch to specify the locale ID to search for (i.e. /locale=2052). Also that plug-in uses a lot of CRT calls which could be avoided but I won't be cleaning it up!

Stu


All times are GMT. The time now is 17:52.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.