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

Side by Side Diff: src/ports/SkFontHost_FreeType.cpp

Issue 271333002: Stage fixes for underline position. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 SkScalar underlineThickness, underlinePosition; 1400 SkScalar underlineThickness, underlinePosition;
1401 if (face->face_flags & FT_FACE_FLAG_SCALABLE) { // scalable outline font 1401 if (face->face_flags & FT_FACE_FLAG_SCALABLE) { // scalable outline font
1402 ascent = -SkIntToScalar(face->ascender) / upem; 1402 ascent = -SkIntToScalar(face->ascender) / upem;
1403 descent = -SkIntToScalar(face->descender) / upem; 1403 descent = -SkIntToScalar(face->descender) / upem;
1404 leading = SkIntToScalar(face->height + (face->descender - face->ascender )) / upem; 1404 leading = SkIntToScalar(face->height + (face->descender - face->ascender )) / upem;
1405 xmin = SkIntToScalar(face->bbox.xMin) / upem; 1405 xmin = SkIntToScalar(face->bbox.xMin) / upem;
1406 xmax = SkIntToScalar(face->bbox.xMax) / upem; 1406 xmax = SkIntToScalar(face->bbox.xMax) / upem;
1407 ymin = -SkIntToScalar(face->bbox.yMin) / upem; 1407 ymin = -SkIntToScalar(face->bbox.yMin) / upem;
1408 ymax = -SkIntToScalar(face->bbox.yMax) / upem; 1408 ymax = -SkIntToScalar(face->bbox.yMax) / upem;
1409 underlineThickness = SkIntToScalar(face->underline_thickness) / upem; 1409 underlineThickness = SkIntToScalar(face->underline_thickness) / upem;
1410 #ifdef SK_IGNORE_UNDERLINE_POSITION_FIX
1410 underlinePosition = -SkIntToScalar(face->underline_position) / upem; 1411 underlinePosition = -SkIntToScalar(face->underline_position) / upem;
1412 #else
1413 underlinePosition = -SkIntToScalar(face->underline_position +
1414 face->underline_thickness / 2) / upem ;
1415 #endif
1411 1416
1412 if(mx) { 1417 if(mx) {
1413 mx->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; 1418 mx->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag;
1414 mx->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; 1419 mx->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag;
1415 } 1420 }
1416 if(my){ 1421 if(my){
1417 my->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; 1422 my->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag;
1418 my->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; 1423 my->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag;
1419 } 1424 }
1420 // we may be able to synthesize x_height and cap_height from outline 1425 // we may be able to synthesize x_height and cap_height from outline
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 mx->fTop = ymax * mxy; 1481 mx->fTop = ymax * mxy;
1477 mx->fAscent = ascent * mxy; 1482 mx->fAscent = ascent * mxy;
1478 mx->fDescent = descent * mxy; 1483 mx->fDescent = descent * mxy;
1479 mx->fBottom = ymin * mxy; 1484 mx->fBottom = ymin * mxy;
1480 mx->fLeading = leading * mxy; 1485 mx->fLeading = leading * mxy;
1481 mx->fAvgCharWidth = avgCharWidth * mxy; 1486 mx->fAvgCharWidth = avgCharWidth * mxy;
1482 mx->fXMin = xmin; 1487 mx->fXMin = xmin;
1483 mx->fXMax = xmax; 1488 mx->fXMax = xmax;
1484 mx->fXHeight = x_height; 1489 mx->fXHeight = x_height;
1485 mx->fCapHeight = cap_height; 1490 mx->fCapHeight = cap_height;
1491 #ifdef SK_IGNORE_UNDERLINE_POSITION_FIX
1486 mx->fUnderlineThickness = underlineThickness; 1492 mx->fUnderlineThickness = underlineThickness;
1487 mx->fUnderlinePosition = underlinePosition; 1493 mx->fUnderlinePosition = underlinePosition;
1494 #else
1495 mx->fUnderlineThickness = underlineThickness * mxy;
1496 mx->fUnderlinePosition = underlinePosition * mxy;
1497 #endif
1488 } 1498 }
1489 if (my) { 1499 if (my) {
1490 my->fTop = ymax * myy; 1500 my->fTop = ymax * myy;
1491 my->fAscent = ascent * myy; 1501 my->fAscent = ascent * myy;
1492 my->fDescent = descent * myy; 1502 my->fDescent = descent * myy;
1493 my->fBottom = ymin * myy; 1503 my->fBottom = ymin * myy;
1494 my->fLeading = leading * myy; 1504 my->fLeading = leading * myy;
1495 my->fAvgCharWidth = avgCharWidth * myy; 1505 my->fAvgCharWidth = avgCharWidth * myy;
1496 my->fXMin = xmin; 1506 my->fXMin = xmin;
1497 my->fXMax = xmax; 1507 my->fXMax = xmax;
1498 my->fXHeight = x_height; 1508 my->fXHeight = x_height;
1499 my->fCapHeight = cap_height; 1509 my->fCapHeight = cap_height;
1510 #ifdef SK_IGNORE_UNDERLINE_POSITION_FIX
1500 my->fUnderlineThickness = underlineThickness; 1511 my->fUnderlineThickness = underlineThickness;
1501 my->fUnderlinePosition = underlinePosition; 1512 my->fUnderlinePosition = underlinePosition;
1513 #else
1514 my->fUnderlineThickness = underlineThickness * myy;
1515 my->fUnderlinePosition = underlinePosition * myy;
1516 #endif
1502 } 1517 }
1503 } 1518 }
1504 1519
1505 void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph ) 1520 void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph )
1506 { 1521 {
1507 // check to see if the embolden bit is set 1522 // check to see if the embolden bit is set
1508 if (0 == (fRec.fFlags & SkScalerContext::kEmbolden_Flag)) { 1523 if (0 == (fRec.fFlags & SkScalerContext::kEmbolden_Flag)) {
1509 return; 1524 return;
1510 } 1525 }
1511 1526
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 *style = (SkTypeface::Style) tempStyle; 1742 *style = (SkTypeface::Style) tempStyle;
1728 } 1743 }
1729 if (isFixedPitch) { 1744 if (isFixedPitch) {
1730 *isFixedPitch = FT_IS_FIXED_WIDTH(face); 1745 *isFixedPitch = FT_IS_FIXED_WIDTH(face);
1731 } 1746 }
1732 1747
1733 FT_Done_Face(face); 1748 FT_Done_Face(face);
1734 FT_Done_FreeType(library); 1749 FT_Done_FreeType(library);
1735 return true; 1750 return true;
1736 } 1751 }
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698