Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: core/fxge/android/cfpf_skiafont.cpp

Issue 2477443002: Remove FX_BOOL from core (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxge/android/cfpf_skiafont.h ('k') | core/fxge/android/cfx_androidfontinfo.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "core/fxge/android/cfpf_skiafont.h" 7 #include "core/fxge/android/cfpf_skiafont.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 FXFT_Get_Face_Ascender(m_Face)); 80 FXFT_Get_Face_Ascender(m_Face));
81 } 81 }
82 82
83 int32_t CFPF_SkiaFont::GetDescent() const { 83 int32_t CFPF_SkiaFont::GetDescent() const {
84 if (!m_Face) 84 if (!m_Face)
85 return 0; 85 return 0;
86 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 86 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
87 FXFT_Get_Face_Descender(m_Face)); 87 FXFT_Get_Face_Descender(m_Face));
88 } 88 }
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 if (!m_Face) 91 if (!m_Face)
92 return FALSE; 92 return false;
93 if (FXFT_Is_Face_Tricky(m_Face)) { 93 if (FXFT_Is_Face_Tricky(m_Face)) {
94 if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72)) 94 if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72))
95 return FALSE; 95 return false;
96 if (FXFT_Load_Glyph(m_Face, iGlyphIndex, 96 if (FXFT_Load_Glyph(m_Face, iGlyphIndex,
97 FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { 97 FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
98 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); 98 FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
99 return FALSE; 99 return false;
100 } 100 }
101 FXFT_Glyph glyph; 101 FXFT_Glyph glyph;
102 if (FXFT_Get_Glyph(m_Face->glyph, &glyph)) { 102 if (FXFT_Get_Glyph(m_Face->glyph, &glyph)) {
103 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); 103 FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
104 return FALSE; 104 return false;
105 } 105 }
106 FXFT_BBox cbox; 106 FXFT_BBox cbox;
107 FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); 107 FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox);
108 int32_t x_ppem = m_Face->size->metrics.x_ppem; 108 int32_t x_ppem = m_Face->size->metrics.x_ppem;
109 int32_t y_ppem = m_Face->size->metrics.y_ppem; 109 int32_t y_ppem = m_Face->size->metrics.y_ppem;
110 rtBBox.left = FPF_EM_ADJUST(x_ppem, cbox.xMin); 110 rtBBox.left = FPF_EM_ADJUST(x_ppem, cbox.xMin);
111 rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax); 111 rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax);
112 rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax); 112 rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax);
113 rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin); 113 rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin);
114 rtBBox.top = std::min(rtBBox.top, GetAscent()); 114 rtBBox.top = std::min(rtBBox.top, GetAscent());
115 rtBBox.bottom = std::max(rtBBox.bottom, GetDescent()); 115 rtBBox.bottom = std::max(rtBBox.bottom, GetDescent());
116 FXFT_Done_Glyph(glyph); 116 FXFT_Done_Glyph(glyph);
117 return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; 117 return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0;
118 } 118 }
119 if (FXFT_Load_Glyph( 119 if (FXFT_Load_Glyph(
120 m_Face, iGlyphIndex, 120 m_Face, iGlyphIndex,
121 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { 121 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
122 return FALSE; 122 return false;
123 } 123 }
124 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 124 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
125 FXFT_Get_Glyph_HoriBearingX(m_Face)); 125 FXFT_Get_Glyph_HoriBearingX(m_Face));
126 rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 126 rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
127 FXFT_Get_Glyph_HoriBearingY(m_Face)); 127 FXFT_Get_Glyph_HoriBearingY(m_Face));
128 rtBBox.right = FPF_EM_ADJUST( 128 rtBBox.right = FPF_EM_ADJUST(
129 FXFT_Get_Face_UnitsPerEM(m_Face), 129 FXFT_Get_Face_UnitsPerEM(m_Face),
130 FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face)); 130 FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face));
131 rtBBox.top = FPF_EM_ADJUST( 131 rtBBox.top = FPF_EM_ADJUST(
132 FXFT_Get_Face_UnitsPerEM(m_Face), 132 FXFT_Get_Face_UnitsPerEM(m_Face),
133 FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face)); 133 FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face));
134 return TRUE; 134 return true;
135 } 135 }
136 136
137 FX_BOOL CFPF_SkiaFont::GetBBox(FX_RECT& rtBBox) { 137 bool CFPF_SkiaFont::GetBBox(FX_RECT& rtBBox) {
138 if (!m_Face) { 138 if (!m_Face) {
139 return FALSE; 139 return false;
140 } 140 }
141 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 141 rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
142 FXFT_Get_Face_xMin(m_Face)); 142 FXFT_Get_Face_xMin(m_Face));
143 rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 143 rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
144 FXFT_Get_Face_yMin(m_Face)); 144 FXFT_Get_Face_yMin(m_Face));
145 rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 145 rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
146 FXFT_Get_Face_xMax(m_Face)); 146 FXFT_Get_Face_xMax(m_Face));
147 rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 147 rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
148 FXFT_Get_Face_yMax(m_Face)); 148 FXFT_Get_Face_yMax(m_Face));
149 return TRUE; 149 return true;
150 } 150 }
151 151
152 int32_t CFPF_SkiaFont::GetHeight() const { 152 int32_t CFPF_SkiaFont::GetHeight() const {
153 if (!m_Face) 153 if (!m_Face)
154 return 0; 154 return 0;
155 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 155 return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
156 FXFT_Get_Face_Height(m_Face)); 156 FXFT_Get_Face_Height(m_Face));
157 } 157 }
158 158
159 int32_t CFPF_SkiaFont::GetItalicAngle() const { 159 int32_t CFPF_SkiaFont::GetItalicAngle() const {
(...skipping 12 matching lines...) Expand all
172 uint32_t dwSize) { 172 uint32_t dwSize) {
173 if (!m_Face) 173 if (!m_Face)
174 return 0; 174 return 0;
175 175
176 FT_ULong ulSize = pdfium::base::checked_cast<FT_ULong>(dwSize); 176 FT_ULong ulSize = pdfium::base::checked_cast<FT_ULong>(dwSize);
177 if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, &ulSize)) 177 if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, &ulSize))
178 return 0; 178 return 0;
179 return pdfium::base::checked_cast<uint32_t>(ulSize); 179 return pdfium::base::checked_cast<uint32_t>(ulSize);
180 } 180 }
181 181
182 FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr, 182 bool CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr,
183 CFPF_SkiaFontDescriptor* pFontDes, 183 CFPF_SkiaFontDescriptor* pFontDes,
184 const CFX_ByteStringC& bsFamily, 184 const CFX_ByteStringC& bsFamily,
185 uint32_t dwStyle, 185 uint32_t dwStyle,
186 uint8_t uCharset) { 186 uint8_t uCharset) {
187 if (!pFontMgr || !pFontDes) 187 if (!pFontMgr || !pFontDes)
188 return FALSE; 188 return false;
189 189
190 switch (pFontDes->GetType()) { 190 switch (pFontDes->GetType()) {
191 case FPF_SKIAFONTTYPE_Path: { 191 case FPF_SKIAFONTTYPE_Path: {
192 CFPF_SkiaPathFont* pFont = (CFPF_SkiaPathFont*)pFontDes; 192 CFPF_SkiaPathFont* pFont = (CFPF_SkiaPathFont*)pFontDes;
193 m_Face = pFontMgr->GetFontFace(pFont->m_pPath, pFont->m_iFaceIndex); 193 m_Face = pFontMgr->GetFontFace(pFont->m_pPath, pFont->m_iFaceIndex);
194 break; 194 break;
195 } 195 }
196 case FPF_SKIAFONTTYPE_File: { 196 case FPF_SKIAFONTTYPE_File: {
197 CFPF_SkiaFileFont* pFont = (CFPF_SkiaFileFont*)pFontDes; 197 CFPF_SkiaFileFont* pFont = (CFPF_SkiaFileFont*)pFontDes;
198 m_Face = pFontMgr->GetFontFace(pFont->m_pFile, pFont->m_iFaceIndex); 198 m_Face = pFontMgr->GetFontFace(pFont->m_pFile, pFont->m_iFaceIndex);
199 break; 199 break;
200 } 200 }
201 case FPF_SKIAFONTTYPE_Buffer: { 201 case FPF_SKIAFONTTYPE_Buffer: {
202 CFPF_SkiaBufferFont* pFont = (CFPF_SkiaBufferFont*)pFontDes; 202 CFPF_SkiaBufferFont* pFont = (CFPF_SkiaBufferFont*)pFontDes;
203 m_Face = pFontMgr->GetFontFace((const uint8_t*)pFont->m_pBuffer, 203 m_Face = pFontMgr->GetFontFace((const uint8_t*)pFont->m_pBuffer,
204 pFont->m_szBuffer, pFont->m_iFaceIndex); 204 pFont->m_szBuffer, pFont->m_iFaceIndex);
205 break; 205 break;
206 } 206 }
207 default: 207 default:
208 return FALSE; 208 return false;
209 } 209 }
210 if (!m_Face) 210 if (!m_Face)
211 return FALSE; 211 return false;
212 212
213 m_dwStyle = dwStyle; 213 m_dwStyle = dwStyle;
214 m_uCharset = uCharset; 214 m_uCharset = uCharset;
215 m_pFontMgr = pFontMgr; 215 m_pFontMgr = pFontMgr;
216 m_pFontDes = pFontDes; 216 m_pFontDes = pFontDes;
217 m_dwRefCount = 1; 217 m_dwRefCount = 1;
218 return TRUE; 218 return true;
219 } 219 }
OLDNEW
« no previous file with comments | « core/fxge/android/cfpf_skiafont.h ('k') | core/fxge/android/cfx_androidfontinfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698