aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-13 03:41:29 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-13 03:41:29 +0000
commitd604481f7a2587f5b400d2a0a68a6491a0d584c7 (patch)
tree0c4cd0621d5e024108e2aec529f91975b23bbf68
parentaf8edcc477ad36592adcf53d14e8bf4441143b31 (diff)
[PDF] Fix windows SkFontHost::OpenStream for TTC fonts.
Review URL: http://codereview.appspot.com/4515074 git-svn-id: http://skia.googlecode.com/svn/trunk@1319 2bbb7eff-a529-9590-31e7-b0007b416f81
-rwxr-xr-xsrc/ports/SkFontHost_win.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index fd5b929ae2..d9404f3943 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -790,6 +790,7 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
}
SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
+ const DWORD kTTCTag = *(DWORD*) "ttcf";
LOGFONT lf;
GetLogFontByID(uniqueID, &lf);
@@ -797,11 +798,20 @@ SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
HFONT font = CreateFontIndirect(&lf);
HFONT savefont = (HFONT)SelectObject(hdc, font);
- size_t bufferSize = GetFontData(hdc, 0, 0, NULL, 0);
- SkMemoryStream* stream = new SkMemoryStream(bufferSize);
- if (!GetFontData(hdc, 0, 0, (void*)stream->getMemoryBase(), bufferSize)) {
- delete stream;
- stream = NULL;
+ SkMemoryStream* stream = NULL;
+ DWORD tables[2] = {kTTCTag, 0};
+ for (int i = 0; i < SK_ARRAY_COUNT(tables); i++) {
+ size_t bufferSize = GetFontData(hdc, tables[i], 0, NULL, 0);
+ if (bufferSize != GDI_ERROR) {
+ stream = new SkMemoryStream(bufferSize);
+ if (GetFontData(hdc, tables[i], 0, (void*)stream->getMemoryBase(),
+ bufferSize)) {
+ break;
+ } else {
+ delete stream;
+ stream = NULL;
+ }
+ }
}
SelectObject(hdc, savefont);