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

Side by Side Diff: include/core/SkPaint.h

Issue 152073003: Adding code to calculate Underline Thickness from Font Metrics, this will be useful when Skia is us… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixing comments, adding bitfield to FontMetrics Created 6 years, 10 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
« no previous file with comments | « no previous file | src/core/SkPaint.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 /* 3 /*
4 * Copyright 2006 The Android Open Source Project 4 * Copyright 2006 The Android Open Source Project
5 * 5 *
6 * Use of this source code is governed by a BSD-style license that can be 6 * Use of this source code is governed by a BSD-style license that can be
7 * found in the LICENSE file. 7 * found in the LICENSE file.
8 */ 8 */
9 9
10 10
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 kUTF8_TextEncoding, //!< the text parameters are UTF8 723 kUTF8_TextEncoding, //!< the text parameters are UTF8
724 kUTF16_TextEncoding, //!< the text parameters are UTF16 724 kUTF16_TextEncoding, //!< the text parameters are UTF16
725 kUTF32_TextEncoding, //!< the text parameters are UTF32 725 kUTF32_TextEncoding, //!< the text parameters are UTF32
726 kGlyphID_TextEncoding //!< the text parameters are glyph indices 726 kGlyphID_TextEncoding //!< the text parameters are glyph indices
727 }; 727 };
728 728
729 TextEncoding getTextEncoding() const { return (TextEncoding)fTextEncoding; } 729 TextEncoding getTextEncoding() const { return (TextEncoding)fTextEncoding; }
730 730
731 void setTextEncoding(TextEncoding encoding); 731 void setTextEncoding(TextEncoding encoding);
732 732
733 /** Describes defined to identify which values are unknown, later can be
734 used for other uses
735 */
736 enum FontMetricsBitSet {
reed1 2014/02/12 17:29:08 Skia convention would name this FontMetricsFlags,
reed1 2014/02/12 17:29:08 Possibly we could place this enum inside FontMetri
h.joshi 2014/02/13 02:23:52 Okey, will change enum variable names. On 2014/02
h.joshi 2014/02/13 02:23:52 Okey, will shift emum inside FontMetrics structure
737 kFontMetrics_Top = 1 << 1, //!< Bit flag for FontMetric s fTop
738 kFontMetrics_Ascent = 1 << 2, //!< Bit flag for FontMetric s Ascent
739 kFontMetrics_Descent = 1 << 3, //!< Bit flag for FontMetric s Descent
740 kFontMetrics_Bottom = 1 << 4, //!< Bit flag for FontMetric s Bottom
reed1 2014/02/12 17:29:08 Do we really need/want a bit for every field? I th
h.joshi 2014/02/13 02:43:20 Will remove comments from enum. Underline will get
741 kFontMetrics_Leading = 1 << 5, //!< Bit flag for FontMetric s Leading
742 kFontMetrics_AvgCharWidth = 1 << 6, //!< Bit flag for FontMetric s Average Char Width
743 kFontMetrics_MaxCharWidth = 1 << 7, //!< Bit flag for FontMetric s Max Char Width
744 kFontMetrics_XMin = 1 << 8, //!< Bit flag for FontMetric s x - min
745 kFontMetrics_XMax = 1 << 9, //!< Bit flag for FontMetric s x - max
746 kFontMetrics_XHeight = 1 << 10, //!< Bit flag for FontMetric s x - height
747 kFontMetrics_CapHeight = 1 << 11, //!< Bit flag for FontMetric s Cap Height
748 kFontMetrics_UnderlineThickness = 1 << 12, //!< Bit flag for FontMetric s Underline Thickness
749 kFontMetrics_UnderlinePosition = 1 << 13, //!< Bit flag for FontMetric s Underline Position
750 kFontMetrics_Max = 0xFFFF, //!< Max Bit flag
reed1 2014/02/12 17:29:08 Why do we need the Max?
h.joshi 2014/02/13 02:23:52 Just added to signify for max/default value, think
751 };
752
733 struct FontMetrics { 753 struct FontMetrics {
754 uint16_t fFontMetricsFlag; //!< Bit field to identify which val ues are unknown
reed1 2014/02/12 17:29:08 definitely make this uint32_t (or possibly 64bit)
h.joshi 2014/02/13 02:23:52 Okey will make it 32 bit. On 2014/02/12 17:29:08,
734 SkScalar fTop; //!< The greatest distance above the baseline fo r any glyph (will be <= 0) 755 SkScalar fTop; //!< The greatest distance above the baseline fo r any glyph (will be <= 0)
735 SkScalar fAscent; //!< The recommended distance above the baseline (will be <= 0) 756 SkScalar fAscent; //!< The recommended distance above the baseline (will be <= 0)
736 SkScalar fDescent; //!< The recommended distance below the baseline (will be >= 0) 757 SkScalar fDescent; //!< The recommended distance below the baseline (will be >= 0)
737 SkScalar fBottom; //!< The greatest distance below the baseline fo r any glyph (will be >= 0) 758 SkScalar fBottom; //!< The greatest distance below the baseline fo r any glyph (will be >= 0)
738 SkScalar fLeading; //!< The recommended distance to add between lin es of text (will be >= 0) 759 SkScalar fLeading; //!< The recommended distance to add between lin es of text (will be >= 0)
739 SkScalar fAvgCharWidth; //!< the average charactor width (>= 0) 760 SkScalar fAvgCharWidth; //!< the average charactor width (>= 0)
740 SkScalar fMaxCharWidth; //!< the max charactor width (>= 0) 761 SkScalar fMaxCharWidth; //!< the max charactor width (>= 0)
741 SkScalar fXMin; //!< The minimum bounding box x value for all gl yphs 762 SkScalar fXMin; //!< The minimum bounding box x value for all gl yphs
742 SkScalar fXMax; //!< The maximum bounding box x value for all gl yphs 763 SkScalar fXMax; //!< The maximum bounding box x value for all gl yphs
743 SkScalar fXHeight; //!< The height of an 'x' in px, or 0 if no 'x' in face 764 SkScalar fXHeight; //!< The height of an 'x' in px, or 0 if no 'x' in face
744 SkScalar fCapHeight; //!< The cap height (> 0), or 0 if cannot be de termined. 765 SkScalar fCapHeight; //!< The cap height (> 0), or 0 if cannot be de termined.
766 SkScalar fUnderlineThickness; //!< underline thickness, or 0 if canno t be determined
767 SkScalar fUnderlinePosition; //!< underline position, or 0 if cannot be determined
745 }; 768 };
746 769
770 /** Method to get bit set for Font Metrics
771 @param fObject Pointer of FontMetrics object
772 @param bitSet bit whose value we want to know is set or not
773 @param retrun true if FontMetrics bit i set false otherwise
774 */
775 bool isFontMetricsBitSet(FontMetrics * fObject, FontMetricsBitSet bitSet) co nst;
776
747 /** Return the recommend spacing between lines (which will be 777 /** Return the recommend spacing between lines (which will be
748 fDescent - fAscent + fLeading). 778 fDescent - fAscent + fLeading).
749 If metrics is not null, return in it the font metrics for the 779 If metrics is not null, return in it the font metrics for the
750 typeface/pointsize/etc. currently set in the paint. 780 typeface/pointsize/etc. currently set in the paint.
751 @param metrics If not null, returns the font metrics for the 781 @param metrics If not null, returns the font metrics for the
752 current typeface/pointsize/etc setting in this 782 current typeface/pointsize/etc setting in this
753 paint. 783 paint.
754 @param scale If not 0, return width as if the canvas were scaled 784 @param scale If not 0, return width as if the canvas were scaled
755 by this value 785 by this value
756 @param return the recommended spacing between lines 786 @param return the recommended spacing between lines
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 #ifdef SK_BUILD_FOR_ANDROID 1109 #ifdef SK_BUILD_FOR_ANDROID
1080 SkPaintOptionsAndroid fPaintOptionsAndroid; 1110 SkPaintOptionsAndroid fPaintOptionsAndroid;
1081 1111
1082 // In order for the == operator to work properly this must be the last field 1112 // In order for the == operator to work properly this must be the last field
1083 // in the struct so that we can do a memcmp to this field's offset. 1113 // in the struct so that we can do a memcmp to this field's offset.
1084 uint32_t fGenerationID; 1114 uint32_t fGenerationID;
1085 #endif 1115 #endif
1086 }; 1116 };
1087 1117
1088 #endif 1118 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698