| 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 "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
| 8 #include "../../../include/fxge/fx_freetype.h" | 8 #include "../../../include/fxge/fx_freetype.h" |
| 9 #include "text_int.h" | 9 #include "text_int.h" |
| 10 #define EM_ADJUST(em, a) (em == 0?(a): (a)*1000/em) | 10 #define EM_ADJUST(em, a) (em == 0?(a): (a)*1000/em) |
| 11 extern void _FPDFAPI_GetInternalFontData(int id1, const uint8_t*& data, FX_DWORD
& size); | 11 extern void _FPDFAPI_GetInternalFontData(int id1, const uint8_t*& data, FX_DWORD
& size); |
| 12 CFX_Font::CFX_Font() | 12 CFX_Font::CFX_Font() |
| 13 { | 13 { |
| 14 m_pSubstFont = NULL; | 14 m_pSubstFont = NULL; |
| 15 m_Face = NULL; | 15 m_Face = NULL; |
| 16 m_bEmbedded = FALSE; | 16 m_bEmbedded = false; |
| 17 m_bVertical = FALSE; | 17 m_bVertical = false; |
| 18 m_pFontData = NULL; | 18 m_pFontData = NULL; |
| 19 m_pFontDataAllocation = NULL; | 19 m_pFontDataAllocation = NULL; |
| 20 m_dwSize = 0; | 20 m_dwSize = 0; |
| 21 m_pOwnedStream = NULL; | 21 m_pOwnedStream = NULL; |
| 22 m_pGsubData = NULL; | 22 m_pGsubData = NULL; |
| 23 m_pPlatformFont = NULL; | 23 m_pPlatformFont = NULL; |
| 24 m_pPlatformFontCollection = NULL; | 24 m_pPlatformFontCollection = NULL; |
| 25 m_pDwFont = NULL; | 25 m_pDwFont = NULL; |
| 26 m_hHandle = NULL; | 26 m_hHandle = NULL; |
| 27 m_bDwLoaded = FALSE; | 27 m_bDwLoaded = false; |
| 28 } | 28 } |
| 29 CFX_Font::~CFX_Font() | 29 CFX_Font::~CFX_Font() |
| 30 { | 30 { |
| 31 delete m_pSubstFont; | 31 delete m_pSubstFont; |
| 32 m_pSubstFont = NULL; | 32 m_pSubstFont = NULL; |
| 33 if (m_pFontDataAllocation) { | 33 if (m_pFontDataAllocation) { |
| 34 FX_Free(m_pFontDataAllocation); | 34 FX_Free(m_pFontDataAllocation); |
| 35 m_pFontDataAllocation = NULL; | 35 m_pFontDataAllocation = NULL; |
| 36 } | 36 } |
| 37 if (m_Face) { | 37 if (m_Face) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 54 } | 54 } |
| 55 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 55 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 56 ReleasePlatformResource(); | 56 ReleasePlatformResource(); |
| 57 #endif | 57 #endif |
| 58 } | 58 } |
| 59 void CFX_Font::DeleteFace() | 59 void CFX_Font::DeleteFace() |
| 60 { | 60 { |
| 61 FXFT_Done_Face(m_Face); | 61 FXFT_Done_Face(m_Face); |
| 62 m_Face = NULL; | 62 m_Face = NULL; |
| 63 } | 63 } |
| 64 FX_BOOL CFX_Font::LoadSubst(const CFX_ByteString& face_name, FX_BOOL bTrueType,
FX_DWORD flags, | 64 bool CFX_Font::LoadSubst(const CFX_ByteString& face_name, bool bTrueType, FX_DWO
RD flags, |
| 65 int weight, int italic_angle, int CharsetCP, FX_BOOL
bVertical) | 65 int weight, int italic_angle, int CharsetCP, bool bV
ertical) |
| 66 { | 66 { |
| 67 m_bEmbedded = FALSE; | 67 m_bEmbedded = false; |
| 68 m_bVertical = bVertical; | 68 m_bVertical = bVertical; |
| 69 m_pSubstFont = new CFX_SubstFont; | 69 m_pSubstFont = new CFX_SubstFont; |
| 70 m_Face = CFX_GEModule::Get()->GetFontMgr()->FindSubstFont(face_name, bTrueTy
pe, flags, weight, italic_angle, | 70 m_Face = CFX_GEModule::Get()->GetFontMgr()->FindSubstFont(face_name, bTrueTy
pe, flags, weight, italic_angle, |
| 71 CharsetCP, m_pSubstFont); | 71 CharsetCP, m_pSubstFont); |
| 72 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 72 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 73 if(m_pSubstFont->m_ExtHandle) { | 73 if(m_pSubstFont->m_ExtHandle) { |
| 74 m_pPlatformFont = m_pSubstFont->m_ExtHandle; | 74 m_pPlatformFont = m_pSubstFont->m_ExtHandle; |
| 75 m_pSubstFont->m_ExtHandle = NULL; | 75 m_pSubstFont->m_ExtHandle = NULL; |
| 76 } | 76 } |
| 77 #endif | 77 #endif |
| 78 if (m_Face) { | 78 if (m_Face) { |
| 79 m_pFontData = FXFT_Get_Face_Stream_Base(m_Face); | 79 m_pFontData = FXFT_Get_Face_Stream_Base(m_Face); |
| 80 m_dwSize = FXFT_Get_Face_Stream_Size(m_Face); | 80 m_dwSize = FXFT_Get_Face_Stream_Size(m_Face); |
| 81 } | 81 } |
| 82 return TRUE; | 82 return true; |
| 83 } | 83 } |
| 84 extern "C" { | 84 extern "C" { |
| 85 unsigned long _FTStreamRead(FXFT_Stream stream, unsigned long offset, | 85 unsigned long _FTStreamRead(FXFT_Stream stream, unsigned long offset, |
| 86 unsigned char* buffer, unsigned long count) | 86 unsigned char* buffer, unsigned long count) |
| 87 { | 87 { |
| 88 if (count == 0) { | 88 if (count == 0) { |
| 89 return 0; | 89 return 0; |
| 90 } | 90 } |
| 91 IFX_FileRead* pFile = (IFX_FileRead*)stream->descriptor.pointer; | 91 IFX_FileRead* pFile = (IFX_FileRead*)stream->descriptor.pointer; |
| 92 int res = pFile->ReadBlock(buffer, offset, count); | 92 int res = pFile->ReadBlock(buffer, offset, count); |
| 93 if (res) { | 93 if (res) { |
| 94 return count; | 94 return count; |
| 95 } | 95 } |
| 96 return 0; | 96 return 0; |
| 97 } | 97 } |
| 98 void _FTStreamClose(FXFT_Stream stream) | 98 void _FTStreamClose(FXFT_Stream stream) |
| 99 { | 99 { |
| 100 } | 100 } |
| 101 }; | 101 }; |
| 102 FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FX
FT_Stream* stream) | 102 bool _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FXFT_
Stream* stream) |
| 103 { | 103 { |
| 104 FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(uint8_t, sizeof (FXFT_StreamRec)
); | 104 FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(uint8_t, sizeof (FXFT_StreamRec)
); |
| 105 stream1->base = NULL; | 105 stream1->base = NULL; |
| 106 stream1->size = (unsigned long)pFile->GetSize(); | 106 stream1->size = (unsigned long)pFile->GetSize(); |
| 107 stream1->pos = 0; | 107 stream1->pos = 0; |
| 108 stream1->descriptor.pointer = pFile; | 108 stream1->descriptor.pointer = pFile; |
| 109 stream1->close = _FTStreamClose; | 109 stream1->close = _FTStreamClose; |
| 110 stream1->read = _FTStreamRead; | 110 stream1->read = _FTStreamRead; |
| 111 FXFT_Open_Args args; | 111 FXFT_Open_Args args; |
| 112 args.flags = FT_OPEN_STREAM; | 112 args.flags = FT_OPEN_STREAM; |
| 113 args.stream = stream1; | 113 args.stream = stream1; |
| 114 if (FXFT_Open_Face(library, &args, 0, Face)) { | 114 if (FXFT_Open_Face(library, &args, 0, Face)) { |
| 115 FX_Free(stream1); | 115 FX_Free(stream1); |
| 116 return FALSE; | 116 return false; |
| 117 } | 117 } |
| 118 if (stream) { | 118 if (stream) { |
| 119 *stream = stream1; | 119 *stream = stream1; |
| 120 } | 120 } |
| 121 return TRUE; | 121 return true; |
| 122 } | 122 } |
| 123 FX_BOOL CFX_Font::LoadFile(IFX_FileRead* pFile) | 123 bool CFX_Font::LoadFile(IFX_FileRead* pFile) |
| 124 { | 124 { |
| 125 m_bEmbedded = FALSE; | 125 m_bEmbedded = false; |
| 126 FXFT_Library library; | 126 FXFT_Library library; |
| 127 if (CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary == NULL) { | 127 if (CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary == NULL) { |
| 128 FXFT_Init_FreeType(&CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary); | 128 FXFT_Init_FreeType(&CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary); |
| 129 } | 129 } |
| 130 library = CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary; | 130 library = CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary; |
| 131 FXFT_Stream stream = NULL; | 131 FXFT_Stream stream = NULL; |
| 132 if (!_LoadFile(library, &m_Face, pFile, &stream)) { | 132 if (!_LoadFile(library, &m_Face, pFile, &stream)) { |
| 133 return FALSE; | 133 return false; |
| 134 } | 134 } |
| 135 m_pOwnedStream = stream; | 135 m_pOwnedStream = stream; |
| 136 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); | 136 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); |
| 137 return TRUE; | 137 return true; |
| 138 } | 138 } |
| 139 int CFX_Font::GetGlyphWidth(FX_DWORD glyph_index) | 139 int CFX_Font::GetGlyphWidth(FX_DWORD glyph_index) |
| 140 { | 140 { |
| 141 if (!m_Face) { | 141 if (!m_Face) { |
| 142 return 0; | 142 return 0; |
| 143 } | 143 } |
| 144 if (m_pSubstFont && (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM)) { | 144 if (m_pSubstFont && (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM)) { |
| 145 AdjustMMParams(glyph_index, 0, 0); | 145 AdjustMMParams(glyph_index, 0, 0); |
| 146 } | 146 } |
| 147 int err = FXFT_Load_Glyph(m_Face, glyph_index, FXFT_LOAD_NO_SCALE | FXFT_LOA
D_IGNORE_GLOBAL_ADVANCE_WIDTH); | 147 int err = FXFT_Load_Glyph(m_Face, glyph_index, FXFT_LOAD_NO_SCALE | FXFT_LOA
D_IGNORE_GLOBAL_ADVANCE_WIDTH); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 162 int error = FXFT_New_Memory_Face(library, pData, size, 0, &face); | 162 int error = FXFT_New_Memory_Face(library, pData, size, 0, &face); |
| 163 if (error) { | 163 if (error) { |
| 164 return NULL; | 164 return NULL; |
| 165 } | 165 } |
| 166 error = FXFT_Set_Pixel_Sizes(face, 64, 64); | 166 error = FXFT_Set_Pixel_Sizes(face, 64, 64); |
| 167 if (error) { | 167 if (error) { |
| 168 return NULL; | 168 return NULL; |
| 169 } | 169 } |
| 170 return face; | 170 return face; |
| 171 } | 171 } |
| 172 FX_BOOL CFX_Font::LoadEmbedded(const uint8_t* data, FX_DWORD size) | 172 bool CFX_Font::LoadEmbedded(const uint8_t* data, FX_DWORD size) |
| 173 { | 173 { |
| 174 m_pFontDataAllocation = FX_Alloc(uint8_t, size); | 174 m_pFontDataAllocation = FX_Alloc(uint8_t, size); |
| 175 FXSYS_memcpy(m_pFontDataAllocation, data, size); | 175 FXSYS_memcpy(m_pFontDataAllocation, data, size); |
| 176 m_Face = FT_LoadFont((uint8_t*)m_pFontDataAllocation, size); | 176 m_Face = FT_LoadFont((uint8_t*)m_pFontDataAllocation, size); |
| 177 m_pFontData = (uint8_t*)m_pFontDataAllocation; | 177 m_pFontData = (uint8_t*)m_pFontDataAllocation; |
| 178 m_bEmbedded = TRUE; | 178 m_bEmbedded = true; |
| 179 m_dwSize = size; | 179 m_dwSize = size; |
| 180 return m_Face != NULL; | 180 return m_Face != NULL; |
| 181 } | 181 } |
| 182 FX_BOOL CFX_Font::IsTTFont() | 182 bool CFX_Font::IsTTFont() |
| 183 { | 183 { |
| 184 if (m_Face == NULL) { | 184 if (m_Face == NULL) { |
| 185 return FALSE; | 185 return false; |
| 186 } | 186 } |
| 187 return FXFT_Is_Face_TT_OT(m_Face) == FXFT_FACE_FLAG_SFNT; | 187 return FXFT_Is_Face_TT_OT(m_Face) == FXFT_FACE_FLAG_SFNT; |
| 188 } | 188 } |
| 189 int CFX_Font::GetAscent() const | 189 int CFX_Font::GetAscent() const |
| 190 { | 190 { |
| 191 if (m_Face == NULL) { | 191 if (m_Face == NULL) { |
| 192 return 0; | 192 return 0; |
| 193 } | 193 } |
| 194 int ascent = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Ascen
der(m_Face)); | 194 int ascent = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Ascen
der(m_Face)); |
| 195 return ascent; | 195 return ascent; |
| 196 } | 196 } |
| 197 int CFX_Font::GetDescent() const | 197 int CFX_Font::GetDescent() const |
| 198 { | 198 { |
| 199 if (m_Face == NULL) { | 199 if (m_Face == NULL) { |
| 200 return 0; | 200 return 0; |
| 201 } | 201 } |
| 202 int descent = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Desc
ender(m_Face)); | 202 int descent = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Desc
ender(m_Face)); |
| 203 return descent; | 203 return descent; |
| 204 } | 204 } |
| 205 FX_BOOL CFX_Font::GetGlyphBBox(FX_DWORD glyph_index, FX_RECT &bbox) | 205 bool CFX_Font::GetGlyphBBox(FX_DWORD glyph_index, FX_RECT &bbox) |
| 206 { | 206 { |
| 207 if (m_Face == NULL) { | 207 if (m_Face == NULL) { |
| 208 return FALSE; | 208 return false; |
| 209 } | 209 } |
| 210 if (FXFT_Is_Face_Tricky(m_Face)) { | 210 if (FXFT_Is_Face_Tricky(m_Face)) { |
| 211 int error = FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72); | 211 int error = FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72); |
| 212 if (error) { | 212 if (error) { |
| 213 return FALSE; | 213 return false; |
| 214 } | 214 } |
| 215 error = FXFT_Load_Glyph(m_Face, glyph_index, FXFT_LOAD_IGNORE_GLOBAL_ADV
ANCE_WIDTH); | 215 error = FXFT_Load_Glyph(m_Face, glyph_index, FXFT_LOAD_IGNORE_GLOBAL_ADV
ANCE_WIDTH); |
| 216 if (error) { | 216 if (error) { |
| 217 return FALSE; | 217 return false; |
| 218 } | 218 } |
| 219 FXFT_BBox cbox; | 219 FXFT_BBox cbox; |
| 220 FT_Glyph glyph; | 220 FT_Glyph glyph; |
| 221 error = FXFT_Get_Glyph(((FXFT_Face)m_Face)->glyph, &glyph); | 221 error = FXFT_Get_Glyph(((FXFT_Face)m_Face)->glyph, &glyph); |
| 222 if (error) { | 222 if (error) { |
| 223 return FALSE; | 223 return false; |
| 224 } | 224 } |
| 225 FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); | 225 FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); |
| 226 int pixel_size_x = ((FXFT_Face)m_Face)->size->metrics.x_ppem, | 226 int pixel_size_x = ((FXFT_Face)m_Face)->size->metrics.x_ppem, |
| 227 pixel_size_y = ((FXFT_Face)m_Face)->size->metrics.y_ppem; | 227 pixel_size_y = ((FXFT_Face)m_Face)->size->metrics.y_ppem; |
| 228 if (pixel_size_x == 0 || pixel_size_y == 0) { | 228 if (pixel_size_x == 0 || pixel_size_y == 0) { |
| 229 bbox.left = cbox.xMin; | 229 bbox.left = cbox.xMin; |
| 230 bbox.right = cbox.xMax; | 230 bbox.right = cbox.xMax; |
| 231 bbox.top = cbox.yMax; | 231 bbox.top = cbox.yMax; |
| 232 bbox.bottom = cbox.yMin; | 232 bbox.bottom = cbox.yMin; |
| 233 } else { | 233 } else { |
| 234 bbox.left = cbox.xMin * 1000 / pixel_size_x; | 234 bbox.left = cbox.xMin * 1000 / pixel_size_x; |
| 235 bbox.right = cbox.xMax * 1000 / pixel_size_x; | 235 bbox.right = cbox.xMax * 1000 / pixel_size_x; |
| 236 bbox.top = cbox.yMax * 1000 / pixel_size_y; | 236 bbox.top = cbox.yMax * 1000 / pixel_size_y; |
| 237 bbox.bottom = cbox.yMin * 1000 / pixel_size_y; | 237 bbox.bottom = cbox.yMin * 1000 / pixel_size_y; |
| 238 } | 238 } |
| 239 if (bbox.top > FXFT_Get_Face_Ascender(m_Face)) { | 239 if (bbox.top > FXFT_Get_Face_Ascender(m_Face)) { |
| 240 bbox.top = FXFT_Get_Face_Ascender(m_Face); | 240 bbox.top = FXFT_Get_Face_Ascender(m_Face); |
| 241 } | 241 } |
| 242 if (bbox.bottom < FXFT_Get_Face_Descender(m_Face)) { | 242 if (bbox.bottom < FXFT_Get_Face_Descender(m_Face)) { |
| 243 bbox.bottom = FXFT_Get_Face_Descender(m_Face); | 243 bbox.bottom = FXFT_Get_Face_Descender(m_Face); |
| 244 } | 244 } |
| 245 FT_Done_Glyph(glyph); | 245 FT_Done_Glyph(glyph); |
| 246 return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; | 246 return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; |
| 247 } | 247 } |
| 248 if (FXFT_Load_Glyph(m_Face, glyph_index, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNO
RE_GLOBAL_ADVANCE_WIDTH)) { | 248 if (FXFT_Load_Glyph(m_Face, glyph_index, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNO
RE_GLOBAL_ADVANCE_WIDTH)) { |
| 249 return FALSE; | 249 return false; |
| 250 } | 250 } |
| 251 int em = FXFT_Get_Face_UnitsPerEM(m_Face); | 251 int em = FXFT_Get_Face_UnitsPerEM(m_Face); |
| 252 if (em == 0) { | 252 if (em == 0) { |
| 253 bbox.left = FXFT_Get_Glyph_HoriBearingX(m_Face); | 253 bbox.left = FXFT_Get_Glyph_HoriBearingX(m_Face); |
| 254 bbox.bottom = FXFT_Get_Glyph_HoriBearingY(m_Face); | 254 bbox.bottom = FXFT_Get_Glyph_HoriBearingY(m_Face); |
| 255 bbox.top = bbox.bottom - FXFT_Get_Glyph_Height(m_Face); | 255 bbox.top = bbox.bottom - FXFT_Get_Glyph_Height(m_Face); |
| 256 bbox.right = bbox.left + FXFT_Get_Glyph_Width(m_Face); | 256 bbox.right = bbox.left + FXFT_Get_Glyph_Width(m_Face); |
| 257 } else { | 257 } else { |
| 258 bbox.left = FXFT_Get_Glyph_HoriBearingX(m_Face) * 1000 / em; | 258 bbox.left = FXFT_Get_Glyph_HoriBearingX(m_Face) * 1000 / em; |
| 259 bbox.top = (FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(
m_Face)) * 1000 / em; | 259 bbox.top = (FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(
m_Face)) * 1000 / em; |
| 260 bbox.right = (FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width
(m_Face)) * 1000 / em; | 260 bbox.right = (FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width
(m_Face)) * 1000 / em; |
| 261 bbox.bottom = (FXFT_Get_Glyph_HoriBearingY(m_Face)) * 1000 / em; | 261 bbox.bottom = (FXFT_Get_Glyph_HoriBearingY(m_Face)) * 1000 / em; |
| 262 } | 262 } |
| 263 return TRUE; | 263 return true; |
| 264 } | 264 } |
| 265 FX_BOOL CFX_Font::IsItalic() | 265 bool CFX_Font::IsItalic() |
| 266 { | 266 { |
| 267 if (m_Face == NULL) { | 267 if (m_Face == NULL) { |
| 268 return FALSE; | 268 return false; |
| 269 } | 269 } |
| 270 FX_BOOL ret = FXFT_Is_Face_Italic(m_Face) == FXFT_STYLE_FLAG_ITALIC; | 270 bool ret = FXFT_Is_Face_Italic(m_Face) == FXFT_STYLE_FLAG_ITALIC; |
| 271 if (!ret) { | 271 if (!ret) { |
| 272 CFX_ByteString str(FXFT_Get_Face_Style_Name(m_Face)); | 272 CFX_ByteString str(FXFT_Get_Face_Style_Name(m_Face)); |
| 273 str.MakeLower(); | 273 str.MakeLower(); |
| 274 if (str.Find("italic") != -1) { | 274 if (str.Find("italic") != -1) { |
| 275 ret = TRUE; | 275 ret = true; |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 return ret; | 278 return ret; |
| 279 } | 279 } |
| 280 FX_BOOL CFX_Font::IsBold() | 280 bool CFX_Font::IsBold() |
| 281 { | 281 { |
| 282 if (m_Face == NULL) { | 282 if (m_Face == NULL) { |
| 283 return FALSE; | 283 return false; |
| 284 } | 284 } |
| 285 return FXFT_Is_Face_Bold(m_Face) == FXFT_STYLE_FLAG_BOLD; | 285 return FXFT_Is_Face_Bold(m_Face) == FXFT_STYLE_FLAG_BOLD; |
| 286 } | 286 } |
| 287 FX_BOOL CFX_Font::IsFixedWidth() | 287 bool CFX_Font::IsFixedWidth() |
| 288 { | 288 { |
| 289 if (m_Face == NULL) { | 289 if (m_Face == NULL) { |
| 290 return FALSE; | 290 return false; |
| 291 } | 291 } |
| 292 return FXFT_Is_Face_fixedwidth(m_Face); | 292 return FXFT_Is_Face_fixedwidth(m_Face); |
| 293 } | 293 } |
| 294 CFX_WideString CFX_Font::GetPsName() const | 294 CFX_WideString CFX_Font::GetPsName() const |
| 295 { | 295 { |
| 296 if (m_Face == NULL) { | 296 if (m_Face == NULL) { |
| 297 return CFX_WideString(); | 297 return CFX_WideString(); |
| 298 } | 298 } |
| 299 CFX_WideString psName = CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(m
_Face)); | 299 CFX_WideString psName = CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(m
_Face)); |
| 300 if (psName.IsEmpty()) { | 300 if (psName.IsEmpty()) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 326 facename = "Untitled"; | 326 facename = "Untitled"; |
| 327 } | 327 } |
| 328 if (!style.IsEmpty() && style != "Regular") { | 328 if (!style.IsEmpty() && style != "Regular") { |
| 329 facename += " " + style; | 329 facename += " " + style; |
| 330 } | 330 } |
| 331 return facename; | 331 return facename; |
| 332 } else { | 332 } else { |
| 333 return m_pSubstFont->m_Family; | 333 return m_pSubstFont->m_Family; |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 FX_BOOL CFX_Font::GetBBox(FX_RECT &bbox) | 336 bool CFX_Font::GetBBox(FX_RECT &bbox) |
| 337 { | 337 { |
| 338 if (m_Face == NULL) { | 338 if (m_Face == NULL) { |
| 339 return FALSE; | 339 return false; |
| 340 } | 340 } |
| 341 int em = FXFT_Get_Face_UnitsPerEM(m_Face); | 341 int em = FXFT_Get_Face_UnitsPerEM(m_Face); |
| 342 if (em == 0) { | 342 if (em == 0) { |
| 343 bbox.left = FXFT_Get_Face_xMin(m_Face); | 343 bbox.left = FXFT_Get_Face_xMin(m_Face); |
| 344 bbox.bottom = FXFT_Get_Face_yMax(m_Face); | 344 bbox.bottom = FXFT_Get_Face_yMax(m_Face); |
| 345 bbox.top = FXFT_Get_Face_yMin(m_Face); | 345 bbox.top = FXFT_Get_Face_yMin(m_Face); |
| 346 bbox.right = FXFT_Get_Face_xMax(m_Face); | 346 bbox.right = FXFT_Get_Face_xMax(m_Face); |
| 347 } else { | 347 } else { |
| 348 bbox.left = FXFT_Get_Face_xMin(m_Face) * 1000 / em; | 348 bbox.left = FXFT_Get_Face_xMin(m_Face) * 1000 / em; |
| 349 bbox.top = FXFT_Get_Face_yMin(m_Face) * 1000 / em; | 349 bbox.top = FXFT_Get_Face_yMin(m_Face) * 1000 / em; |
| 350 bbox.right = FXFT_Get_Face_xMax(m_Face) * 1000 / em; | 350 bbox.right = FXFT_Get_Face_xMax(m_Face) * 1000 / em; |
| 351 bbox.bottom = FXFT_Get_Face_yMax(m_Face) * 1000 / em; | 351 bbox.bottom = FXFT_Get_Face_yMax(m_Face) * 1000 / em; |
| 352 } | 352 } |
| 353 return TRUE; | 353 return true; |
| 354 } | 354 } |
| 355 int CFX_Font::GetHeight() | 355 int CFX_Font::GetHeight() |
| 356 { | 356 { |
| 357 if (m_Face == NULL) { | 357 if (m_Face == NULL) { |
| 358 return 0; | 358 return 0; |
| 359 } | 359 } |
| 360 int height = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Heigh
t(m_Face)); | 360 int height = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Heigh
t(m_Face)); |
| 361 return height; | 361 return height; |
| 362 } | 362 } |
| 363 int CFX_Font::GetMaxAdvanceWidth() | 363 int CFX_Font::GetMaxAdvanceWidth() |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 break; | 426 break; |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 return FXFT_Get_Char_Index(face, charcode); | 430 return FXFT_Get_Char_Index(face, charcode); |
| 431 } | 431 } |
| 432 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) | 432 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) |
| 433 { | 433 { |
| 434 return new CFX_UnicodeEncoding(pFont); | 434 return new CFX_UnicodeEncoding(pFont); |
| 435 } | 435 } |
| OLD | NEW |