OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fx_fpf.h" | 7 #include "fx_fpf.h" |
| 8 |
| 9 #include <algorithm> |
| 10 |
8 #if _FX_OS_ == _FX_ANDROID_ | 11 #if _FX_OS_ == _FX_ANDROID_ |
9 #include "fpf_skiafont.h" | 12 #include "fpf_skiafont.h" |
10 #include "fpf_skiafontmgr.h" | 13 #include "fpf_skiafontmgr.h" |
11 #define FPF_EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em) | 14 #define FPF_EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em) |
12 CFPF_SkiaFont::CFPF_SkiaFont() | 15 CFPF_SkiaFont::CFPF_SkiaFont() |
13 : m_pFontMgr(NULL), | 16 : m_pFontMgr(NULL), |
14 m_pFontDes(NULL), | 17 m_pFontDes(NULL), |
15 m_Face(NULL), | 18 m_Face(NULL), |
16 m_dwStyle(0), | 19 m_dwStyle(0), |
17 m_uCharset(0), | 20 m_uCharset(0), |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return FALSE; | 102 return FALSE; |
100 } | 103 } |
101 FXFT_BBox cbox; | 104 FXFT_BBox cbox; |
102 FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); | 105 FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); |
103 int32_t x_ppem = m_Face->size->metrics.x_ppem; | 106 int32_t x_ppem = m_Face->size->metrics.x_ppem; |
104 int32_t y_ppem = m_Face->size->metrics.y_ppem; | 107 int32_t y_ppem = m_Face->size->metrics.y_ppem; |
105 rtBBox.left = FPF_EM_ADJUST(x_ppem, cbox.xMin); | 108 rtBBox.left = FPF_EM_ADJUST(x_ppem, cbox.xMin); |
106 rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax); | 109 rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax); |
107 rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax); | 110 rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax); |
108 rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin); | 111 rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin); |
109 rtBBox.top = FX_MIN(rtBBox.top, GetAscent()); | 112 rtBBox.top = std::min(rtBBox.top, GetAscent()); |
110 rtBBox.bottom = FX_MAX(rtBBox.bottom, GetDescent()); | 113 rtBBox.bottom = std::max(rtBBox.bottom, GetDescent()); |
111 FXFT_Done_Glyph(glyph); | 114 FXFT_Done_Glyph(glyph); |
112 return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; | 115 return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; |
113 } | 116 } |
114 if (FXFT_Load_Glyph( | 117 if (FXFT_Load_Glyph( |
115 m_Face, iGlyphIndex, | 118 m_Face, iGlyphIndex, |
116 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { | 119 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { |
117 return FALSE; | 120 return FALSE; |
118 } | 121 } |
119 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), | 122 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), |
120 FXFT_Get_Glyph_HoriBearingX(m_Face)); | 123 FXFT_Get_Glyph_HoriBearingX(m_Face)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 return FALSE; | 204 return FALSE; |
202 } | 205 } |
203 m_dwStyle = dwStyle; | 206 m_dwStyle = dwStyle; |
204 m_uCharset = uCharset; | 207 m_uCharset = uCharset; |
205 m_pFontMgr = pFontMgr; | 208 m_pFontMgr = pFontMgr; |
206 m_pFontDes = pFontDes; | 209 m_pFontDes = pFontDes; |
207 m_dwRefCount = 1; | 210 m_dwRefCount = 1; |
208 return TRUE; | 211 return TRUE; |
209 } | 212 } |
210 #endif | 213 #endif |
OLD | NEW |