| 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 #if _FX_OS_ == _FX_ANDROID_ | 8 #if _FX_OS_ == _FX_ANDROID_ |
| 9 #include "fpf_skiafont.h" | 9 #include "fpf_skiafont.h" |
| 10 #include "fpf_skiafontmgr.h" | 10 #include "fpf_skiafontmgr.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Ascende
r(m_Face)); | 81 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Ascende
r(m_Face)); |
| 82 } | 82 } |
| 83 int32_t CFPF_SkiaFont::GetDescent() const | 83 int32_t CFPF_SkiaFont::GetDescent() const |
| 84 { | 84 { |
| 85 if (!m_Face) { | 85 if (!m_Face) { |
| 86 return 0; | 86 return 0; |
| 87 } | 87 } |
| 88 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Descend
er(m_Face)); | 88 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Descend
er(m_Face)); |
| 89 } | 89 } |
| 90 FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox) | 90 bool CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox) |
| 91 { | 91 { |
| 92 if (!m_Face) { | 92 if (!m_Face) { |
| 93 return FALSE; | 93 return false; |
| 94 } | 94 } |
| 95 if (FXFT_Is_Face_Tricky(m_Face)) { | 95 if (FXFT_Is_Face_Tricky(m_Face)) { |
| 96 if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72)) { | 96 if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72)) { |
| 97 return FALSE; | 97 return false; |
| 98 } | 98 } |
| 99 if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_IGNORE_GLOBAL_ADVANCE
_WIDTH)) { | 99 if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_IGNORE_GLOBAL_ADVANCE
_WIDTH)) { |
| 100 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); | 100 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); |
| 101 return FALSE; | 101 return false; |
| 102 } | 102 } |
| 103 FXFT_Glyph glyph; | 103 FXFT_Glyph glyph; |
| 104 if (FXFT_Get_Glyph(m_Face->glyph, &glyph)) { | 104 if (FXFT_Get_Glyph(m_Face->glyph, &glyph)) { |
| 105 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); | 105 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); |
| 106 return FALSE; | 106 return false; |
| 107 } | 107 } |
| 108 FXFT_BBox cbox; | 108 FXFT_BBox cbox; |
| 109 FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); | 109 FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); |
| 110 int32_t x_ppem = m_Face->size->metrics.x_ppem; | 110 int32_t x_ppem = m_Face->size->metrics.x_ppem; |
| 111 int32_t y_ppem = m_Face->size->metrics.y_ppem; | 111 int32_t y_ppem = m_Face->size->metrics.y_ppem; |
| 112 rtBBox.left = FPF_EM_ADJUST(x_ppem, cbox.xMin); | 112 rtBBox.left = FPF_EM_ADJUST(x_ppem, cbox.xMin); |
| 113 rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax); | 113 rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax); |
| 114 rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax); | 114 rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax); |
| 115 rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin); | 115 rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin); |
| 116 rtBBox.top = FX_MIN(rtBBox.top, GetAscent()); | 116 rtBBox.top = FX_MIN(rtBBox.top, GetAscent()); |
| 117 rtBBox.bottom = FX_MAX(rtBBox.bottom, GetDescent()); | 117 rtBBox.bottom = FX_MAX(rtBBox.bottom, GetDescent()); |
| 118 FXFT_Done_Glyph(glyph); | 118 FXFT_Done_Glyph(glyph); |
| 119 return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; | 119 return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; |
| 120 } | 120 } |
| 121 if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNO
RE_GLOBAL_ADVANCE_WIDTH)) { | 121 if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNO
RE_GLOBAL_ADVANCE_WIDTH)) { |
| 122 return FALSE; | 122 return false; |
| 123 } | 123 } |
| 124 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph
_HoriBearingX(m_Face)); | 124 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph
_HoriBearingX(m_Face)); |
| 125 rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Gly
ph_HoriBearingY(m_Face)); | 125 rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Gly
ph_HoriBearingY(m_Face)); |
| 126 rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyp
h_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face)); | 126 rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyp
h_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face)); |
| 127 rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_
HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face)); | 127 rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_
HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face)); |
| 128 return TRUE; | 128 return true; |
| 129 } | 129 } |
| 130 FX_BOOL CFPF_SkiaFont::GetBBox(FX_RECT &rtBBox) | 130 bool CFPF_SkiaFont::GetBBox(FX_RECT &rtBBox) |
| 131 { | 131 { |
| 132 if (!m_Face) { | 132 if (!m_Face) { |
| 133 return FALSE; | 133 return false; |
| 134 } | 134 } |
| 135 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_
xMin(m_Face)); | 135 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_
xMin(m_Face)); |
| 136 rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_y
Min(m_Face)); | 136 rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_y
Min(m_Face)); |
| 137 rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face
_xMax(m_Face)); | 137 rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face
_xMax(m_Face)); |
| 138 rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Fac
e_yMax(m_Face)); | 138 rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Fac
e_yMax(m_Face)); |
| 139 return TRUE; | 139 return true; |
| 140 } | 140 } |
| 141 int32_t CFPF_SkiaFont::GetHeight() const | 141 int32_t CFPF_SkiaFont::GetHeight() const |
| 142 { | 142 { |
| 143 if (!m_Face) { | 143 if (!m_Face) { |
| 144 return 0; | 144 return 0; |
| 145 } | 145 } |
| 146 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_He
ight(m_Face)); | 146 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_He
ight(m_Face)); |
| 147 } | 147 } |
| 148 int32_t CFPF_SkiaFont::GetItalicAngle() const | 148 int32_t CFPF_SkiaFont::GetItalicAngle() const |
| 149 { | 149 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 160 { | 160 { |
| 161 if (!m_Face) { | 161 if (!m_Face) { |
| 162 return 0; | 162 return 0; |
| 163 } | 163 } |
| 164 FT_ULong ulSize = pdfium::base::checked_cast<FT_ULong>(dwSize); | 164 FT_ULong ulSize = pdfium::base::checked_cast<FT_ULong>(dwSize); |
| 165 if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, &ulSize)) { | 165 if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, &ulSize)) { |
| 166 return 0; | 166 return 0; |
| 167 } | 167 } |
| 168 return pdfium::base::checked_cast<FX_DWORD>(ulSize); | 168 return pdfium::base::checked_cast<FX_DWORD>(ulSize); |
| 169 } | 169 } |
| 170 FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescrip
tor *pFontDes, const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uChars
et) | 170 bool CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor
*pFontDes, const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uCharset) |
| 171 { | 171 { |
| 172 if (!pFontMgr || !pFontDes) { | 172 if (!pFontMgr || !pFontDes) { |
| 173 return FALSE; | 173 return false; |
| 174 } | 174 } |
| 175 switch (pFontDes->GetType()) { | 175 switch (pFontDes->GetType()) { |
| 176 case FPF_SKIAFONTTYPE_Path: { | 176 case FPF_SKIAFONTTYPE_Path: { |
| 177 CFPF_SkiaPathFont *pFont = (CFPF_SkiaPathFont*)pFontDes; | 177 CFPF_SkiaPathFont *pFont = (CFPF_SkiaPathFont*)pFontDes; |
| 178 m_Face = pFontMgr->GetFontFace(pFont->m_pPath, pFont->m_iFaceInd
ex); | 178 m_Face = pFontMgr->GetFontFace(pFont->m_pPath, pFont->m_iFaceInd
ex); |
| 179 } | 179 } |
| 180 break; | 180 break; |
| 181 case FPF_SKIAFONTTYPE_File: { | 181 case FPF_SKIAFONTTYPE_File: { |
| 182 CFPF_SkiaFileFont *pFont = (CFPF_SkiaFileFont*)pFontDes; | 182 CFPF_SkiaFileFont *pFont = (CFPF_SkiaFileFont*)pFontDes; |
| 183 m_Face = pFontMgr->GetFontFace(pFont->m_pFile, pFont->m_iFaceInd
ex); | 183 m_Face = pFontMgr->GetFontFace(pFont->m_pFile, pFont->m_iFaceInd
ex); |
| 184 } | 184 } |
| 185 break; | 185 break; |
| 186 case FPF_SKIAFONTTYPE_Buffer: { | 186 case FPF_SKIAFONTTYPE_Buffer: { |
| 187 CFPF_SkiaBufferFont *pFont = (CFPF_SkiaBufferFont*)pFontDes; | 187 CFPF_SkiaBufferFont *pFont = (CFPF_SkiaBufferFont*)pFontDes; |
| 188 m_Face = pFontMgr->GetFontFace((const uint8_t*)pFont->m_pBuffer,
pFont->m_szBuffer, pFont->m_iFaceIndex); | 188 m_Face = pFontMgr->GetFontFace((const uint8_t*)pFont->m_pBuffer,
pFont->m_szBuffer, pFont->m_iFaceIndex); |
| 189 } | 189 } |
| 190 break; | 190 break; |
| 191 default: | 191 default: |
| 192 return FALSE; | 192 return false; |
| 193 } | 193 } |
| 194 if (!m_Face) { | 194 if (!m_Face) { |
| 195 return FALSE; | 195 return false; |
| 196 } | 196 } |
| 197 m_dwStyle = dwStyle; | 197 m_dwStyle = dwStyle; |
| 198 m_uCharset = uCharset; | 198 m_uCharset = uCharset; |
| 199 m_pFontMgr = pFontMgr; | 199 m_pFontMgr = pFontMgr; |
| 200 m_pFontDes = pFontDes; | 200 m_pFontDes = pFontDes; |
| 201 m_dwRefCount = 1; | 201 m_dwRefCount = 1; |
| 202 return TRUE; | 202 return true; |
| 203 } | 203 } |
| 204 #endif | 204 #endif |
| OLD | NEW |