1 // Copyright 2019 PDFium 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 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "core/fxge/text_glyph_pos.h" 8 9 #include "core/fxcrt/fx_safe_types.h" 10 #include "core/fxge/cfx_glyphbitmap.h" 11 12 TextGlyphPos::TextGlyphPos() = default; 13 14 TextGlyphPos::TextGlyphPos(const TextGlyphPos&) = default; 15 16 TextGlyphPos::~TextGlyphPos() = default; 17 GetOrigin(const CFX_Point & offset) const18Optional<CFX_Point> TextGlyphPos::GetOrigin(const CFX_Point& offset) const { 19 FX_SAFE_INT32 left = m_Origin.x; 20 left += m_pGlyph->left(); 21 left -= offset.x; 22 if (!left.IsValid()) 23 return {}; 24 25 FX_SAFE_INT32 top = m_Origin.y; 26 top -= m_pGlyph->top(); 27 top -= offset.y; 28 if (!top.IsValid()) 29 return {}; 30 31 return CFX_Point(left.ValueOrDie(), top.ValueOrDie()); 32 } 33