font_render_params_skia.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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
  3. // found in the LICENSE file.
  4. #include "ui/gfx/font_render_params.h"
  5. #include "base/notreached.h"
  6. namespace gfx {
  7. namespace {
  8. // Returns the system's default settings.
  9. FontRenderParams LoadDefaults() {
  10. FontRenderParams params;
  11. params.antialiasing = true;
  12. params.autohinter = true;
  13. params.use_bitmaps = true;
  14. params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
  15. // Use subpixel text positioning to keep consistent character spacing when
  16. // the page is scaled by a fractional factor.
  17. params.subpixel_positioning = true;
  18. // Slight hinting renders much better than normal hinting on Android.
  19. params.hinting = FontRenderParams::HINTING_SLIGHT;
  20. return params;
  21. }
  22. // A device scale factor used to determine if subpixel positioning
  23. // should be used.
  24. float device_scale_factor_ = 1.0f;
  25. } // namespace
  26. FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
  27. std::string* family_out) {
  28. if (family_out)
  29. NOTIMPLEMENTED();
  30. // Customized font rendering settings are not supported, only defaults.
  31. static const gfx::FontRenderParams params(LoadDefaults());
  32. return params;
  33. }
  34. float GetFontRenderParamsDeviceScaleFactor() {
  35. return device_scale_factor_;
  36. }
  37. void SetFontRenderParamsDeviceScaleFactor(float device_scale_factor) {
  38. device_scale_factor_ = device_scale_factor;
  39. }
  40. } // namespace gfx