| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" | 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" |
| 6 | 6 |
| 7 #include <dwrite.h> | 7 #include <dwrite.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <wrl.h> | 9 #include <wrl.h> |
| 10 | 10 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 hr = font->CreateFontFace(&font_face); | 366 hr = font->CreateFontFace(&font_face); |
| 367 ASSERT_TRUE(SUCCEEDED(hr)); | 367 ASSERT_TRUE(SUCCEEDED(hr)); |
| 368 ASSERT_EQ(3u, fake_collection_->MessageCount()); | 368 ASSERT_EQ(3u, fake_collection_->MessageCount()); |
| 369 | 369 |
| 370 mswr::ComPtr<IDWriteFont> found_font; | 370 mswr::ComPtr<IDWriteFont> found_font; |
| 371 collection_->GetFontFromFontFace(font_face.Get(), &found_font); | 371 collection_->GetFontFromFontFace(font_face.Get(), &found_font); |
| 372 EXPECT_NE(nullptr, found_font.Get()); | 372 EXPECT_NE(nullptr, found_font.Get()); |
| 373 EXPECT_EQ(3u, fake_collection_->MessageCount()); | 373 EXPECT_EQ(3u, fake_collection_->MessageCount()); |
| 374 } | 374 } |
| 375 | 375 |
| 376 TEST_F(DWriteFontProxyUnitTest, TestCustomFontFiles) { |
| 377 scoped_refptr<FakeFontCollection> fonts = new FakeFontCollection(); |
| 378 FakeFont& arial = fonts->AddFont(L"Arial").AddFamilyName(L"en-us", L"Arial"); |
| 379 for (auto& path : arial_font_files) { |
| 380 base::File file(base::FilePath(path), base::File::FLAG_OPEN | |
| 381 base::File::FLAG_READ | |
| 382 base::File::FLAG_EXCLUSIVE_WRITE); |
| 383 arial.AddFileHandle(IPC::TakePlatformFileForTransit(std::move(file))); |
| 384 } |
| 385 mswr::ComPtr<DWriteFontCollectionProxy> collection; |
| 386 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( |
| 387 &collection, factory.Get(), fonts->GetTrackingSender()); |
| 388 |
| 389 // Check that we can get the font family and match a font. |
| 390 UINT32 index = UINT_MAX; |
| 391 BOOL exists = FALSE; |
| 392 collection->FindFamilyName(L"Arial", &index, &exists); |
| 393 mswr::ComPtr<IDWriteFontFamily> family; |
| 394 collection->GetFontFamily(index, &family); |
| 395 |
| 396 mswr::ComPtr<IDWriteFont> font; |
| 397 HRESULT hr = family->GetFirstMatchingFont(DWRITE_FONT_WEIGHT_NORMAL, |
| 398 DWRITE_FONT_STRETCH_NORMAL, |
| 399 DWRITE_FONT_STYLE_NORMAL, &font); |
| 400 |
| 401 EXPECT_TRUE(SUCCEEDED(hr)); |
| 402 EXPECT_NE(nullptr, font.Get()); |
| 403 |
| 404 mswr::ComPtr<IDWriteFontFace> font_face; |
| 405 hr = font->CreateFontFace(&font_face); |
| 406 EXPECT_TRUE(SUCCEEDED(hr)); |
| 407 } |
| 408 |
| 376 } // namespace | 409 } // namespace |
| 377 | 410 |
| 378 } // namespace content | 411 } // namespace content |
| OLD | NEW |