Bug 39473 - [DRT/Chromium] Link resources and load Ahem font for Windows
Summary: [DRT/Chromium] Link resources and load Ahem font for Windows
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other Windows Vista
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 35902
  Show dependency treegraph
 
Reported: 2010-05-20 23:34 PDT by Kent Tamura
Modified: 2010-05-22 10:17 PDT (History)
3 users (show)

See Also:


Attachments
Patch (7.23 KB, patch)
2010-05-20 23:43 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Patch (rev.2) (7.90 KB, patch)
2010-05-21 02:09 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Patch (rev.3) (7.79 KB, patch)
2010-05-21 03:04 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Tamura 2010-05-20 23:34:12 PDT
[DRT/Chromium] Link resources and load Ahem font for Windows
Comment 1 Kent Tamura 2010-05-20 23:43:09 PDT
Created attachment 56677 [details]
Patch
Comment 2 Tony Chang 2010-05-20 23:51:36 PDT
Comment on attachment 56677 [details]
Patch

> +    // Load AHEM font.
> +    // The DRT executable file is placed at:
> +    //  - src/chrome/{Debug,Release}/DumpRenderTree.exe or
> +    //  - WebKit/WebKit/chromium/{Debug,Release}/DumpRenderTree.exe.
> +    // So, WebKit top directory is "../../third_party/WebKit" or "../../..".

It might be easier to just copy AHEM____.TTF next to DumpRenderTree.exe with a gyp rule.  It makes the code for finding it a lot simpler.
Comment 3 Kent Tamura 2010-05-21 01:37:35 PDT
(In reply to comment #2)
> (From update of attachment 56677 [details])
> > +    // Load AHEM font.
> > +    // The DRT executable file is placed at:
> > +    //  - src/chrome/{Debug,Release}/DumpRenderTree.exe or
> > +    //  - WebKit/WebKit/chromium/{Debug,Release}/DumpRenderTree.exe.
> > +    // So, WebKit top directory is "../../third_party/WebKit" or "../../..".
> 
> It might be easier to just copy AHEM____.TTF next to DumpRenderTree.exe with a gyp rule.  It makes the code for finding it a lot simpler.

It's a good idea!  Thanks.
Comment 4 Kent Tamura 2010-05-21 02:09:00 PDT
Created attachment 56683 [details]
Patch (rev.2)
Comment 5 Tony Chang 2010-05-21 02:19:02 PDT
Comment on attachment 56683 [details]
Patch (rev.2)

The Apple win code just uses AddFontResourceEx instead of AddFontMemResourceEx.  I don't have a preference between the two functions, but it might be less code.  Anyway, I think this is fine too.  LGTM with two style nits.

> +    ::PathRemoveFileSpec(modulePath);
> +    WCHAR ahemPath[_MAX_PATH];
> +    struct _stat ahemStat;

Nit: Drop struct since it's not needed in C++.

> +    DWORD numFonts = 1;
> +    HANDLE h = ::AddFontMemResourceEx(fontBuffer, size, 0, &numFonts);

Nit: handle or fontHandle would be a more descriptive variable name.
Comment 6 Kent Tamura 2010-05-21 02:47:01 PDT
(In reply to comment #5)
> (From update of attachment 56683 [details])
> The Apple win code just uses AddFontResourceEx instead of AddFontMemResourceEx.  I don't have a preference between the two functions, but it might be less code.  Anyway, I think this is fine too.  LGTM with two style nits.

I tried to use AddFontResourceEx(), but it failed on my Vista machine.  I couldn't find the failure reasons and workarounds other than AddFontMemResourceEx().
(AddFontResourceEx() doesn't provide an error code!)

> > +    ::PathRemoveFileSpec(modulePath);
> > +    WCHAR ahemPath[_MAX_PATH];
> > +    struct _stat ahemStat;
> 
> Nit: Drop struct since it's not needed in C++.
> 
> > +    DWORD numFonts = 1;
> > +    HANDLE h = ::AddFontMemResourceEx(fontBuffer, size, 0, &numFonts);
> 
> Nit: handle or fontHandle would be a more descriptive variable name.

I'll fix them.
Comment 7 Kent Tamura 2010-05-21 03:04:49 PDT
Created attachment 56690 [details]
Patch (rev.3)
Comment 8 Kent Tamura 2010-05-21 03:06:34 PDT
(In reply to comment #5)
> > +    WCHAR ahemPath[_MAX_PATH];
> > +    struct _stat ahemStat;
> 
> Nit: Drop struct since it's not needed in C++.

Unfortunately, removing "struct" caused an error.  Probably because _stat is a function name too.

> > +    HANDLE h = ::AddFontMemResourceEx(fontBuffer, size, 0, &numFonts);
> 
> Nit: handle or fontHandle would be a more descriptive variable name.

Done.
Comment 9 Dimitri Glazkov (Google) 2010-05-21 07:41:21 PDT
Comment on attachment 56690 [details]
Patch (rev.3)

ok.
Comment 10 Kent Tamura 2010-05-22 10:17:20 PDT
Comment on attachment 56690 [details]
Patch (rev.3)

Clearing flags on attachment: 56690

Committed r60005: <http://trac.webkit.org/changeset/60005>
Comment 11 Kent Tamura 2010-05-22 10:17:31 PDT
All reviewed patches have been landed.  Closing bug.