[PATCH 39/45] [WinHelp]: add proper support for charset from headers
Eric Pouech
eric.pouech at orange.fr
Sun Mar 23 04:21:23 CDT 2008
A+
---
programs/winhelp/hlpfile.c | 48 ++++++++++++++++++++++++++++++++++++++++----
programs/winhelp/hlpfile.h | 1 +
2 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c
index 06c061d..19c8f0b 100644
--- a/programs/winhelp/hlpfile.c
+++ b/programs/winhelp/hlpfile.c
@@ -1474,8 +1474,9 @@ BOOL HLPFILE_BrowsePage(HLPFILE_PAGE* page, struct RtfData* rd, unsigned font
HLPFILE *hlpfile = page->file;
BYTE *buf, *end;
DWORD ref = page->reference;
- unsigned index, offset, old_index = -1, count = 0;
+ unsigned index, offset, old_index = -1, count = 0, cpg;
char tmp[1024];
+ const char* ck = NULL;
rd->in_text = TRUE;
rd->data = rd->ptr = HeapAlloc(GetProcessHeap(), 0, rd->allocated = 32768);
@@ -1484,7 +1485,40 @@ BOOL HLPFILE_BrowsePage(HLPFILE_PAGE* page, struct RtfData* rd, unsigned font
rd->force_color = FALSE;
rd->font_scale = font_scale;
- if (!HLPFILE_RtfAddControl(rd, "{\\rtf1\\ansi\\ansicpg1252\\deff0")) return FALSE;
+ switch (hlpfile->charset)
+ {
+ case DEFAULT_CHARSET:
+ case ANSI_CHARSET: cpg = 1252; break;
+ case SHIFTJIS_CHARSET: cpg = 932; break;
+ case HANGEUL_CHARSET: cpg = 949; break;
+ case GB2312_CHARSET: cpg = 936; break;
+ case CHINESEBIG5_CHARSET: cpg = 950; break;
+ case GREEK_CHARSET: cpg = 1253; break;
+ case TURKISH_CHARSET: cpg = 1254; break;
+ case HEBREW_CHARSET: cpg = 1255; break;
+ case ARABIC_CHARSET: cpg = 1256; break;
+ case BALTIC_CHARSET: cpg = 1257; break;
+ case VIETNAMESE_CHARSET: cpg = 1258; break;
+ case RUSSIAN_CHARSET: cpg = 1251; break;
+ case EE_CHARSET: cpg = 1250; break;
+ case THAI_CHARSET: cpg = 874; break;
+ case JOHAB_CHARSET: cpg = 1361; break;
+ case MAC_CHARSET: ck = "mac"; break;
+ default:
+ WINE_FIXME("Unsupported charset %u\n", hlpfile->charset);
+ cpg = 1252;
+ }
+ if (ck)
+ {
+ sprintf(tmp, "{\\rtf1\\%s\\deff0", ck);
+ if (!HLPFILE_RtfAddControl(rd, tmp)) return FALSE;
+ }
+ else
+ {
+ sprintf(tmp, "{\\rtf1\\ansi\\ansicpg%d\\deff0", cpg);
+ if (!HLPFILE_RtfAddControl(rd, tmp)) return FALSE;
+ }
+
/* generate font table */
if (!HLPFILE_RtfAddControl(rd, "{\\fonttbl")) return FALSE;
for (index = 0; index < hlpfile->numFonts; index++)
@@ -1499,9 +1533,10 @@ BOOL HLPFILE_BrowsePage(HLPFILE_PAGE* page, struct RtfData* rd, unsigned font
case FF_DECORATIVE: family = "decor"; break;
default: family = "nil"; break;
}
- sprintf(tmp, "{\\f%d\\f%s\\fprq%d\\fcharset0 %s;}",
+ sprintf(tmp, "{\\f%d\\f%s\\fprq%d\\fcharset%d %s;}",
index, family,
hlpfile->fonts[index].LogFont.lfPitchAndFamily & 0x0F,
+ hlpfile->fonts[index].LogFont.lfCharSet,
hlpfile->fonts[index].LogFont.lfFaceName);
if (!HLPFILE_RtfAddControl(rd, tmp)) return FALSE;
}
@@ -1629,7 +1664,7 @@ static BOOL HLPFILE_ReadFont(HLPFILE* hlpfile)
hlpfile->fonts[i].LogFont.lfItalic = (flag & 2) ? TRUE : FALSE;
hlpfile->fonts[i].LogFont.lfUnderline = (flag & 4) ? TRUE : FALSE;
hlpfile->fonts[i].LogFont.lfStrikeOut = (flag & 8) ? TRUE : FALSE;
- hlpfile->fonts[i].LogFont.lfCharSet = DEFAULT_CHARSET;
+ hlpfile->fonts[i].LogFont.lfCharSet = hlpfile->charset;
hlpfile->fonts[i].LogFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
hlpfile->fonts[i].LogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
hlpfile->fonts[i].LogFont.lfQuality = DEFAULT_QUALITY;
@@ -1803,6 +1838,7 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile)
hlpfile->version = minor;
hlpfile->flags = flags;
+ hlpfile->charset = DEFAULT_CHARSET;
for (ptr = buf + 0x15; ptr + 4 <= end; ptr += GET_USHORT(ptr, 2) + 4)
{
@@ -1884,6 +1920,10 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile)
wi->size.cx, wi->size.cy);
}
break;
+ case 11:
+ hlpfile->charset = ptr[4];
+ WINE_TRACE("Charset: %d\n", hlpfile->charset);
+ break;
default:
WINE_WARN("Unsupported SystemRecord[%d]\n", GET_USHORT(ptr, 0));
}
diff --git a/programs/winhelp/hlpfile.h b/programs/winhelp/hlpfile.h
index 50b9076..5b02085 100644
--- a/programs/winhelp/hlpfile.h
+++ b/programs/winhelp/hlpfile.h
@@ -104,6 +104,7 @@ typedef struct tagHlpFileFile
unsigned short version;
unsigned short flags;
+ unsigned short charset;
unsigned short tbsize; /* topic block size */
unsigned short dsize; /* decompress size */
unsigned short compressed;
More information about the wine-patches
mailing list