 Chromium Code Reviews
 Chromium Code Reviews| Index: include/core/SkFont.h | 
| diff --git a/include/core/SkFont.h b/include/core/SkFont.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..16fb714e4ae760cc24f373a6b5623236f5faccdc | 
| --- /dev/null | 
| +++ b/include/core/SkFont.h | 
| @@ -0,0 +1,86 @@ | 
| +/* | 
| + * Copyright 2014 Google Inc. | 
| + * | 
| + * Use of this source code is governed by a BSD-style license that can be | 
| + * found in the LICENSE file. | 
| + */ | 
| + | 
| +#include "SkRefCnt.h" | 
| +#include "SkScalar.h" | 
| + | 
| +class SkTypeface; | 
| + | 
| +enum SkTextEncoding { | 
| + kUTF8_SkTextEncoding, | 
| + kUTF16_SkTextEncoding, | 
| + kUTF32_SkTextEncoding, | 
| + kGlyphID_SkTextEncoding, | 
| +}; | 
| + | 
| +class SkFont : public SkRefCnt { | 
| +public: | 
| + enum Flags { | 
| + /** | 
| + * Us the system's automatic hinting mechanism to hint the typeface. | 
| 
bungeman-skia
2014/03/26 16:23:40
nit: s/Us/Use
 
reed1
2014/03/26 18:05:00
Done.
 | 
| + * If both bytecode and auto hints are specified, attempt to use the bytecodes first. | 
| + * If that fails (e.g. there are no codes), then attempt to autohint. | 
| + */ | 
| + kEnableAutoHints_Flag = 1 << 0, | 
| + | 
| + /** | 
| + * If the typeface contains explicit bytecodes for hinting, use them. | 
| + * If both bytecode and auto hints are specified, attempt to use the bytecodes first. | 
| 
bungeman-skia
2014/03/26 16:23:40
nit: semicolon at the end of this to link to the n
 
reed1
2014/03/26 18:05:00
Done.
 | 
| + * If that fails (e.g. there are no codes), then attempt to autohint. | 
| + */ | 
| + kEnableByteCodeHints_Flag = 1 << 1, | 
| + | 
| + /** | 
| + * Use rounded metric values (e.g. advance). | 
| + * If either auto or bytecode hinting was used, apply those results to the metrics of the | 
| + * glyphs as well. If no hinting was applied, the metrics will just be rounded to the | 
| + * nearest integer. | 
| + * | 
| + * This applies to calls that return metrics (e.g. measureText) and to drawing the glyphs | 
| + * (see SkCanvas drawText and drawPosText). | 
| + */ | 
| + kUseNonlinearMetrics_Flag = 1 << 2, | 
| + | 
| + kVertical_Flag = 1 << 3, | 
| + kEmbeddedBitmaps_Flag = 1 << 4, | 
| + kGenA8FromLCD_Flag = 1 << 5, | 
| + kLCD_Mask_Flag = 1 << 6, | 
| 
bungeman-skia
2014/03/26 16:23:40
Since we're changing up all of this anyway, I'd li
 
reed1
2014/03/26 18:05:00
Trying yet another way to organize mask types...
 | 
| + kEmbolden_Flag = 1 << 7, | 
| + }; | 
| + | 
| + | 
| + SkTypeface* getTypeface() const { return fTypeface; } | 
| + SkScalar getSize() const { return fSize; } | 
| + SkScalar getScaleX() const { return fScaleX; } | 
| + SkScalar getSkewX() const { return fSkewX; } | 
| + uint32_t getFlags() const { return fFlags; } | 
| + | 
| + int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding, | 
| + uint16_t glyphs[], int maxGlyphCount) const; | 
| + | 
| + SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding) const; | 
| + | 
| + static SkFont* Create(SkTypeface*, SkScalar size, uint32_t flags); | 
| + static SkFont* Create(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX, | 
| + uint32_t flags); | 
| + static SkFont* Create(const SkFont&, SkScalar newSize); | 
| + | 
| +private: | 
| + enum { | 
| + kAllFlags = 0xFF, | 
| + }; | 
| + | 
| + SkFont(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX, uint32_t flags); | 
| + virtual ~SkFont(); | 
| + | 
| + SkTypeface* fTypeface; | 
| + SkScalar fSize; | 
| + SkScalar fScaleX; | 
| + SkScalar fSkewX; | 
| + uint32_t fFlags; | 
| +}; | 
| + |