| 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/font_render_params.h" | 5 #include "ui/gfx/font_render_params.h" |
| 6 | 6 |
| 7 #include <fontconfig/fontconfig.h> | 7 #include <fontconfig/fontconfig.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> |
| 12 |
| 11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 12 #include "base/containers/mru_cache.h" | 14 #include "base/containers/mru_cache.h" |
| 13 #include "base/hash.h" | 15 #include "base/hash.h" |
| 14 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 15 #include "base/logging.h" | 17 #include "base/logging.h" |
| 16 #include "base/macros.h" | 18 #include "base/macros.h" |
| 17 #include "base/memory/scoped_ptr.h" | |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 20 #include "base/synchronization/lock.h" | 21 #include "base/synchronization/lock.h" |
| 21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 22 #include "ui/gfx/font.h" | 23 #include "ui/gfx/font.h" |
| 23 #include "ui/gfx/linux_font_delegate.h" | 24 #include "ui/gfx/linux_font_delegate.h" |
| 24 #include "ui/gfx/switches.h" | 25 #include "ui/gfx/switches.h" |
| 25 | 26 |
| 26 namespace gfx { | 27 namespace gfx { |
| 27 | 28 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 86 } |
| 86 | 87 |
| 87 // Queries Fontconfig for rendering settings and updates |params_out| and | 88 // Queries Fontconfig for rendering settings and updates |params_out| and |
| 88 // |family_out| (if non-NULL). Returns false on failure. | 89 // |family_out| (if non-NULL). Returns false on failure. |
| 89 bool QueryFontconfig(const FontRenderParamsQuery& query, | 90 bool QueryFontconfig(const FontRenderParamsQuery& query, |
| 90 FontRenderParams* params_out, | 91 FontRenderParams* params_out, |
| 91 std::string* family_out) { | 92 std::string* family_out) { |
| 92 struct FcPatternDeleter { | 93 struct FcPatternDeleter { |
| 93 void operator()(FcPattern* ptr) const { FcPatternDestroy(ptr); } | 94 void operator()(FcPattern* ptr) const { FcPatternDestroy(ptr); } |
| 94 }; | 95 }; |
| 95 typedef scoped_ptr<FcPattern, FcPatternDeleter> ScopedFcPattern; | 96 typedef std::unique_ptr<FcPattern, FcPatternDeleter> ScopedFcPattern; |
| 96 | 97 |
| 97 ScopedFcPattern query_pattern(FcPatternCreate()); | 98 ScopedFcPattern query_pattern(FcPatternCreate()); |
| 98 CHECK(query_pattern); | 99 CHECK(query_pattern); |
| 99 | 100 |
| 100 FcPatternAddBool(query_pattern.get(), FC_SCALABLE, FcTrue); | 101 FcPatternAddBool(query_pattern.get(), FC_SCALABLE, FcTrue); |
| 101 | 102 |
| 102 for (std::vector<std::string>::const_iterator it = query.families.begin(); | 103 for (std::vector<std::string>::const_iterator it = query.families.begin(); |
| 103 it != query.families.end(); ++it) { | 104 it != query.families.end(); ++it) { |
| 104 FcPatternAddString(query_pattern.get(), | 105 FcPatternAddString(query_pattern.get(), |
| 105 FC_FAMILY, reinterpret_cast<const FcChar8*>(it->c_str())); | 106 FC_FAMILY, reinterpret_cast<const FcChar8*>(it->c_str())); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 268 |
| 268 float GetFontRenderParamsDeviceScaleFactor() { | 269 float GetFontRenderParamsDeviceScaleFactor() { |
| 269 return device_scale_factor_; | 270 return device_scale_factor_; |
| 270 } | 271 } |
| 271 | 272 |
| 272 void SetFontRenderParamsDeviceScaleFactor(float device_scale_factor) { | 273 void SetFontRenderParamsDeviceScaleFactor(float device_scale_factor) { |
| 273 device_scale_factor_ = device_scale_factor; | 274 device_scale_factor_ = device_scale_factor; |
| 274 } | 275 } |
| 275 | 276 |
| 276 } // namespace gfx | 277 } // namespace gfx |
| OLD | NEW |