text_scale_skew.cpp 871 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright 2017 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "gm/gm.h"
  8. #include "include/core/SkFont.h"
  9. #include "include/core/SkPaint.h"
  10. #include "include/utils/SkTextUtils.h"
  11. #include <initializer_list>
  12. class SkCanvas;
  13. // http://bug.skia.org/7315
  14. DEF_SIMPLE_GM(text_scale_skew, canvas, 256, 128) {
  15. SkPaint p;
  16. p.setAntiAlias(true);
  17. SkFont font;
  18. font.setSize(18.0f);
  19. float y = 10.0f;
  20. for (float scale : { 0.5f, 0.71f, 1.0f, 1.41f, 2.0f }) {
  21. font.setScaleX(scale);
  22. y += font.getSpacing();
  23. float x = 50.0f;
  24. for (float skew : { -0.5f, 0.0f, 0.5f }) {
  25. font.setSkewX(skew);
  26. SkTextUtils::DrawString(canvas, "Skia", x, y, font, p, SkTextUtils::kCenter_Align);
  27. x += 78.0f;
  28. }
  29. }
  30. }