The *.ttc support for windows stated in this submit by an ex-colleague
of mine is insufficient:
http://sourceforge.net/p/podofo/mailman/message/27461957/
It only works if the *.ttc has a font in it with the platformid = 0
(unicode platform) and if that font has a languageID = 0 (unicode 1.0).
I fixed that issue so that all *.ttc files with a font in them which has
a platformId = 3 (Windows) are supported as long as they have a
languageID equal to the users local LCID or (as fallback) an english
version of the font (id = 1033).
(Details on ttc naming tables:
http://www.microsoft.com/typography/otspec/name.htm)
What has to be done in the future:
- More attributes of the font should be checked e.g. fontstyle,
ps-fontname etc. (now only the fontname will be checked against the
demanded fontname)
Regards,
Dennis Voss
Index: src/doc/PdfFontCache.cpp
===================================================================
--- src/doc/PdfFontCache.cpp (revision 1661)
+++ src/doc/PdfFontCache.cpp (working copy)
@@ -137,7 +137,11 @@
ULONG offset = FromBigEndian(*(ULONG *)(entry+8));
ULONG length = FromBigEndian(*(ULONG *)(entry+12));
length = (length+3) & ~3;
- if(offset+length > bufferLen) return false; // truncated or corrupted
buffer
+ if(offset+length > bufferLen){
+ return false; // truncated or corrupted buffer
+ }
+
+
if(strcmp(tag, "name") == 0)
{
//us: see "http://www.microsoft.com/typography/otspec/name.htm"
@@ -147,14 +151,18 @@
USHORT stringOffset = ShortFromBigEndian(*(USHORT *)(nameTable+4));
char *stringArea = nameTable + stringOffset;
char *nameRecord = nameTable + 6;
+
+ int systemLCID = GetUserDefaultLCID();
//systemcall to get the locale user ID
+
for(int n=0; n<nameCount; n++)
{
USHORT platformID = ShortFromBigEndian(*(USHORT
*)(nameRecord));
USHORT encodingID = ShortFromBigEndian(*(USHORT
*)(nameRecord+2));
USHORT languageID = ShortFromBigEndian(*(USHORT
*)(nameRecord+4));
- if(platformID == 0 && languageID == 0)
+
+ if(platformID == 0 && languageID == 0)
{
- // only Unicode platform / english
+ //Unicode platform / unicode 1.0
USHORT nameID = ShortFromBigEndian(*(USHORT
*)(nameRecord+6));
USHORT length = ShortFromBigEndian(*(USHORT
*)(nameRecord+8));
USHORT offset = ShortFromBigEndian(*(USHORT
*)(nameRecord+10));
@@ -166,6 +174,7 @@
name[i] = ShortFromBigEndian(((USHORT *)(stringArea +
offset))[i]);
}
name[charCount] = 0;
+
switch(nameID)
{
case 1:
@@ -182,6 +191,38 @@
break;
}
}
+ //dv: see
"http://www.microsoft.com/typography/otspec/name.htm"
+ if(platformID == 3 && encodingID == 1 &&
(languageID == systemLCID || languageID == 1033)) //1033 == English(US)
+ {
+ //Platform Windows -> Unicode (UCS-2)
+ USHORT nameID = ShortFromBigEndian(*(USHORT
*)(nameRecord+6));
+ USHORT length = ShortFromBigEndian(*(USHORT
*)(nameRecord+8));
+ USHORT offset = ShortFromBigEndian(*(USHORT
*)(nameRecord+10));
+ wchar_t name[1024];
+ if(length >= sizeof(name)) length = sizeof(name) -
sizeof(wchar_t);
+ unsigned int charCount = length / sizeof(wchar_t);
+ for(unsigned int i=0; i<charCount; i++)
+ {
+ name[i] = ShortFromBigEndian(((USHORT *)(stringArea +
offset))[i]);
+ }
+ name[charCount] = 0;
+
+ switch(nameID)
+ {
+ case 1:
+ wcscpy(fontFamily, name);
+ break;
+ case 2:
+ wcscpy(fontStyle, name);
+ break;
+ case 4:
+ wcscpy(fontFullName, name);
+ break;
+ case 6:
+ wcscpy(fontPostscriptName, name);
+ break;
+ }
+ }
nameRecord += 12;
}
}
@@ -189,6 +230,7 @@
fontFileSize += 16 + length;
}
+
// check if font matches the wanted properties
unsigned int isMatchingFont = _wcsicmp(fontFamily, inFont->lfFaceName) ==
0;
//..TODO.. check additional styles (check fontStyle, fontFullName,
fontPostscriptName) ?
------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users