OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkAdvancedTypefaceMetrics.h" | 9 #include "SkAdvancedTypefaceMetrics.h" |
10 #include "SkBase64.h" | 10 #include "SkBase64.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 static LogFontTypeface* Create(const LOGFONT& lf) { | 194 static LogFontTypeface* Create(const LOGFONT& lf) { |
195 SkTypeface::Style style = get_style(lf); | 195 SkTypeface::Style style = get_style(lf); |
196 SkFontID fontID = SkTypefaceCache::NewFontID(); | 196 SkFontID fontID = SkTypefaceCache::NewFontID(); |
197 return new LogFontTypeface(style, fontID, lf); | 197 return new LogFontTypeface(style, fontID, lf); |
198 } | 198 } |
199 | 199 |
200 protected: | 200 protected: |
201 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; | 201 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; |
202 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | 202 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
| 203 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
| 204 SkAdvancedTypefaceMetrics::PerGlyphInfo, |
| 205 const uint32_t*, uint32_t) const SK_OVERRIDE; |
203 }; | 206 }; |
204 | 207 |
205 class FontMemResourceTypeface : public LogFontTypeface { | 208 class FontMemResourceTypeface : public LogFontTypeface { |
206 public: | 209 public: |
207 /** | 210 /** |
208 * Takes ownership of fontMemResource. | 211 * Takes ownership of fontMemResource. |
209 */ | 212 */ |
210 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF
ONT& lf, HANDLE fontMemResource) : | 213 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF
ONT& lf, HANDLE fontMemResource) : |
211 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour
ce) { | 214 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour
ce) { |
212 } | 215 } |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 int flags = GGO_METRICS | GGO_GLYPH_INDEX; | 1343 int flags = GGO_METRICS | GGO_GLYPH_INDEX; |
1341 GLYPHMETRICS gm; | 1344 GLYPHMETRICS gm; |
1342 if (GDI_ERROR == GetGlyphOutline(hdc, gId, flags, &gm, 0, NULL, &mat2)) { | 1345 if (GDI_ERROR == GetGlyphOutline(hdc, gId, flags, &gm, 0, NULL, &mat2)) { |
1343 return false; | 1346 return false; |
1344 } | 1347 } |
1345 SkASSERT(advance); | 1348 SkASSERT(advance); |
1346 *advance = gm.gmCellIncX; | 1349 *advance = gm.gmCellIncX; |
1347 return true; | 1350 return true; |
1348 } | 1351 } |
1349 | 1352 |
1350 // static | 1353 SkAdvancedTypefaceMetrics* LogFontTypeface::onGetAdvancedTypefaceMetrics( |
1351 SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( | |
1352 uint32_t fontID, | |
1353 SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, | 1354 SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, |
1354 const uint32_t* glyphIDs, | 1355 const uint32_t* glyphIDs, |
1355 uint32_t glyphIDsCount) { | 1356 uint32_t glyphIDsCount) const { |
1356 LOGFONT lf; | 1357 LOGFONT lf = fLogFont; |
1357 GetLogFontByID(fontID, &lf); | |
1358 SkAdvancedTypefaceMetrics* info = NULL; | 1358 SkAdvancedTypefaceMetrics* info = NULL; |
1359 | 1359 |
1360 HDC hdc = CreateCompatibleDC(NULL); | 1360 HDC hdc = CreateCompatibleDC(NULL); |
1361 HFONT font = CreateFontIndirect(&lf); | 1361 HFONT font = CreateFontIndirect(&lf); |
1362 HFONT savefont = (HFONT)SelectObject(hdc, font); | 1362 HFONT savefont = (HFONT)SelectObject(hdc, font); |
1363 HFONT designFont = NULL; | 1363 HFONT designFont = NULL; |
1364 | 1364 |
1365 const char stem_chars[] = {'i', 'I', '!', '1'}; | 1365 const char stem_chars[] = {'i', 'I', '!', '1'}; |
1366 int16_t min_width; | 1366 int16_t min_width; |
1367 unsigned glyphCount; | 1367 unsigned glyphCount; |
1368 | 1368 |
1369 // To request design units, create a logical font whose height is specified | 1369 // To request design units, create a logical font whose height is specified |
1370 // as unitsPerEm. | 1370 // as unitsPerEm. |
1371 OUTLINETEXTMETRIC otm; | 1371 OUTLINETEXTMETRIC otm; |
1372 unsigned int otmRet = GetOutlineTextMetrics(hdc, sizeof(otm), &otm); | 1372 unsigned int otmRet = GetOutlineTextMetrics(hdc, sizeof(otm), &otm); |
1373 if (0 == otmRet) { | 1373 if (0 == otmRet) { |
1374 ensure_typeface_accessible(fontID); | 1374 ensure_typeface_accessible(this->uniqueID()); |
1375 otmRet = GetOutlineTextMetrics(hdc, sizeof(otm), &otm); | 1375 otmRet = GetOutlineTextMetrics(hdc, sizeof(otm), &otm); |
1376 } | 1376 } |
1377 if (!otmRet || !GetTextFace(hdc, LF_FACESIZE, lf.lfFaceName)) { | 1377 if (!otmRet || !GetTextFace(hdc, LF_FACESIZE, lf.lfFaceName)) { |
1378 goto Error; | 1378 goto Error; |
1379 } | 1379 } |
1380 lf.lfHeight = -SkToS32(otm.otmEMSquare); | 1380 lf.lfHeight = -SkToS32(otm.otmEMSquare); |
1381 designFont = CreateFontIndirect(&lf); | 1381 designFont = CreateFontIndirect(&lf); |
1382 SelectObject(hdc, designFont); | 1382 SelectObject(hdc, designFont); |
1383 if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) { | 1383 if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) { |
1384 goto Error; | 1384 goto Error; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 if (isLCD(*rec) && !isAxisAligned(*rec)) { | 1691 if (isLCD(*rec) && !isAxisAligned(*rec)) { |
1692 rec->fMaskFormat = SkMask::kA8_Format; | 1692 rec->fMaskFormat = SkMask::kA8_Format; |
1693 } | 1693 } |
1694 #endif | 1694 #endif |
1695 | 1695 |
1696 if (!fCanBeLCD && isLCD(*rec)) { | 1696 if (!fCanBeLCD && isLCD(*rec)) { |
1697 rec->fMaskFormat = SkMask::kA8_Format; | 1697 rec->fMaskFormat = SkMask::kA8_Format; |
1698 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag; | 1698 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag; |
1699 } | 1699 } |
1700 } | 1700 } |
OLD | NEW |