[webkit-reviews] review granted: [Bug 42782] WebKitTestRunner needs to support loading custom fonts (via the WEBKIT_TESTFONTS environment variable) : [Attachment 63309] Patch
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Aug 3 04:50:54 PDT 2010
Adam Roben (aroben) <aroben at apple.com> has granted Jon Honeycutt
<jhoneycutt at apple.com>'s request for review:
Bug 42782: WebKitTestRunner needs to support loading custom fonts (via the
WEBKIT_TESTFONTS environment variable)
https://bugs.webkit.org/show_bug.cgi?id=42782
Attachment 63309: Patch
https://bugs.webkit.org/attachment.cgi?id=63309&action=review
------- Additional Comments from Adam Roben (aroben) <aroben at apple.com>
> +static const wstring& fontsPath()
> +{
> + static wstring path;
> + static bool initialized;
> +
> + if (initialized)
> + return path;
> + initialized = true;
> +
> + DWORD size = GetEnvironmentVariable(fontsEnvironmentVariable, 0, 0);
The style being used elsewhere in WebKit2 code is to prefix Win32 APIs with ::
and to always use the W variant.
> + Vector<TCHAR> buffer(size);
If you switch to using the W variant, this should be Vector<WCHAR>.
> + if (!GetEnvironmentVariable(fontsEnvironmentVariable, buffer.data(),
buffer.size()))
> + return path;
> +
> + path = buffer.data();
> + if (path[path.length() - 1] != '\\')
> + path.append(L"\\");
> +
> + return path;
> +}
I guess you decided that falling back to the path to the executable when
WEBKIT_TESTFONTS is undefined isn't helpful?
> void activateFonts()
> {
> - // FIXME: Not implemented.
> + static LPCTSTR fontsToInstall[] = {
> + TEXT("AHEM____.ttf"),
> + TEXT("Apple Chancery.ttf"),
> + TEXT("Courier Bold.ttf"),
> + TEXT("Courier.ttf"),
> + TEXT("Helvetica Bold Oblique.ttf"),
> + TEXT("Helvetica Bold.ttf"),
> + TEXT("Helvetica Oblique.ttf"),
> + TEXT("Helvetica.ttf"),
> + TEXT("Helvetica Neue Bold Italic.ttf"),
> + TEXT("Helvetica Neue Bold.ttf"),
> + TEXT("Helvetica Neue Condensed Black.ttf"),
> + TEXT("Helvetica Neue Condensed Bold.ttf"),
> + TEXT("Helvetica Neue Italic.ttf"),
> + TEXT("Helvetica Neue Light Italic.ttf"),
> + TEXT("Helvetica Neue Light.ttf"),
> + TEXT("Helvetica Neue UltraLight Italic.ttf"),
> + TEXT("Helvetica Neue UltraLight.ttf"),
> + TEXT("Helvetica Neue.ttf"),
> + TEXT("Lucida Grande.ttf"),
> + TEXT("Lucida Grande Bold.ttf"),
> + TEXT("Monaco.ttf"),
> + TEXT("Papyrus.ttf"),
> + TEXT("Times Bold Italic.ttf"),
> + TEXT("Times Bold.ttf"),
> + TEXT("Times Italic.ttf"),
> + TEXT("Times Roman.ttf"),
> + TEXT("WebKit Layout Tests 2.ttf"),
> + TEXT("WebKit Layout Tests.ttf"),
> + TEXT("WebKitWeightWatcher100.ttf"),
> + TEXT("WebKitWeightWatcher200.ttf"),
> + TEXT("WebKitWeightWatcher300.ttf"),
> + TEXT("WebKitWeightWatcher400.ttf"),
> + TEXT("WebKitWeightWatcher500.ttf"),
> + TEXT("WebKitWeightWatcher600.ttf"),
> + TEXT("WebKitWeightWatcher700.ttf"),
> + TEXT("WebKitWeightWatcher800.ttf"),
> + TEXT("WebKitWeightWatcher900.ttf")
> + };
> +
> + wstring resourcesPath = fontsPath();
> +
> + for (unsigned i = 0; i < ARRAYSIZE(fontsToInstall); ++i)
> + AddFontResourceEx(wstring(resourcesPath +
fontsToInstall[i]).c_str(), FR_PRIVATE, 0);
If you switch to the W variant, you should use an LPCWSTR array.
r=me
More information about the webkit-reviews
mailing list