kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 1 | // Copyright 2019 The PDFium Authors |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
| 7 | #include "core/fxge/scoped_font_transform.h" |
| 8 | |
| 9 | #include <utility> |
| 10 | |
| 11 | namespace { |
| 12 | |
| 13 | void ResetTransform(FT_Face face) { |
| 14 | FT_Matrix matrix; |
| 15 | matrix.xx = 0x10000L; |
| 16 | matrix.xy = 0; |
| 17 | matrix.yx = 0; |
| 18 | matrix.yy = 0x10000L; |
| 19 | FT_Set_Transform(face, &matrix, 0); |
| 20 | } |
| 21 | |
| 22 | } // namespace |
| 23 | |
| 24 | ScopedFontTransform::ScopedFontTransform(RetainPtr<CFX_Face> face, |
| 25 | FT_Matrix* matrix) |
| 26 | : m_Face(std::move(face)) { |
| 27 | FT_Set_Transform(m_Face->GetRec(), matrix, 0); |
| 28 | } |
| 29 | |
| 30 | ScopedFontTransform::~ScopedFontTransform() { |
| 31 | ResetTransform(m_Face->GetRec()); |
| 32 | } |