From 5a121add5e7bb191148a4e07f5ad7a1c6773ec24 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Fri, 15 Jun 2012 14:27:15 +0000 Subject: [PATCH] add more font names to our extra-bottom-space hack http://code.google.com/p/chromium/issues/detail?id=130842 Change cached names to be UTF8 encoded, since we now have some non-ascii names git-svn-id: http://skia.googlecode.com/svn/trunk@4264 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/ports/SkFontHost_win.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index f79c3eb..1deb6b1 100755 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -26,23 +26,35 @@ #include static int compute_extra_height(const LOGFONT& lf) { + static const struct { - const char* fUCName; + const char* fUCName; // UTF8 encoded, ascii is upper-case int fExtraHeight; } gData[] = { - { "DOTUM", 1 }, // http://code.google.com/p/chromium/issues/detail?id=130842 + // http://code.google.com/p/chromium/issues/detail?id=130842 + { "DOTUM", 1 }, + { "DOTUMCHE", 1 }, + { "\xEB\x8F\x8B\xEC\x9B\x80", 1 }, + { "\xEB\x8F\x8B\xEC\x9B\x80\xEC\xB2\xB4", 1 }, }; - // Convert the lfFaceName into upper-case ascii, since our target - // list is explicitly stored that way. - char name[LF_FACESIZE]; + /** + * We convert the target name into upper-case (for ascii chars) UTF8. + * Our database is already stored in this fashion, and it allows us to + * search it with straight memcmp, since everyone is in this canonical + * form. + */ - for (int i = 0; i < LF_FACESIZE - 1; ++i) { - TCHAR c = lf.lfFaceName[i]; + // temp storage is max # TCHARs * max expantion for UTF8 + null + char name[kMaxBytesInUTF8Sequence * LF_FACESIZE + 1]; + int index = 0; + for (int i = 0; i < LF_FACESIZE; ++i) { + uint16_t c = lf.lfFaceName[i]; if (c >= 'a' && c <= 'z') { c = c - 'a' + 'A'; } - name[i] = (char)c; + size_t n = SkUTF16_ToUTF8(&c, 1, &name[index]); + index += n; if (0 == c) { break; } -- 2.7.4