| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/platform_font_win.h" | 5 #include "ui/gfx/platform_font_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <dwrite.h> | 8 #include <dwrite.h> |
| 9 #include <limits.h> | 9 #include <limits.h> |
| 10 #include <math.h> | 10 #include <math.h> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 base::win::ScopedGDIObject<HFONT> font(::CreateFontIndirect(font_info)); | 104 base::win::ScopedGDIObject<HFONT> font(::CreateFontIndirect(font_info)); |
| 105 base::win::ScopedGetDC screen_dc(NULL); | 105 base::win::ScopedGetDC screen_dc(NULL); |
| 106 base::win::ScopedSelectObject scoped_font(screen_dc, font.get()); | 106 base::win::ScopedSelectObject scoped_font(screen_dc, font.get()); |
| 107 | 107 |
| 108 base::win::ScopedComPtr<IDWriteFontFace> font_face; | 108 base::win::ScopedComPtr<IDWriteFontFace> font_face; |
| 109 hr = gdi_interop->CreateFontFaceFromHdc(screen_dc, font_face.Receive()); | 109 hr = gdi_interop->CreateFontFaceFromHdc(screen_dc, font_face.Receive()); |
| 110 if (FAILED(hr)) | 110 if (FAILED(hr)) |
| 111 return hr; | 111 return hr; |
| 112 | 112 |
| 113 LOGFONT converted_font = {0}; | 113 LOGFONT converted_font = {0}; |
| 114 hr = gdi_interop->ConvertFontFaceToLOGFONT(font_face.get(), &converted_font); | 114 hr = gdi_interop->ConvertFontFaceToLOGFONT(font_face.Get(), &converted_font); |
| 115 if (SUCCEEDED(hr)) { | 115 if (SUCCEEDED(hr)) { |
| 116 hr = font_collection->GetFontFromFontFace(font_face.get(), dwrite_font); | 116 hr = font_collection->GetFontFromFontFace(font_face.Get(), dwrite_font); |
| 117 if (SUCCEEDED(hr)) { | 117 if (SUCCEEDED(hr)) { |
| 118 wcscpy_s(font_info->lfFaceName, arraysize(font_info->lfFaceName), | 118 wcscpy_s(font_info->lfFaceName, arraysize(font_info->lfFaceName), |
| 119 converted_font.lfFaceName); | 119 converted_font.lfFaceName); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 return hr; | 122 return hr; |
| 123 } | 123 } |
| 124 | 124 |
| 125 // Returns a matching IDWriteFont for the |font_info| passed in. If we fail | 125 // Returns a matching IDWriteFont for the |font_info| passed in. If we fail |
| 126 // to find a matching font, then we return the IDWriteFont corresponding to | 126 // to find a matching font, then we return the IDWriteFont corresponding to |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 return new PlatformFontWin(native_font); | 679 return new PlatformFontWin(native_font); |
| 680 } | 680 } |
| 681 | 681 |
| 682 // static | 682 // static |
| 683 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 683 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
| 684 int font_size) { | 684 int font_size) { |
| 685 return new PlatformFontWin(font_name, font_size); | 685 return new PlatformFontWin(font_name, font_size); |
| 686 } | 686 } |
| 687 | 687 |
| 688 } // namespace gfx | 688 } // namespace gfx |
| OLD | NEW |