| Index: include/core/SkFont.h
|
| diff --git a/include/core/SkFont.h b/include/core/SkFont.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..41e4fe8ad8b08a58b90aa85e548d375297c58462
|
| --- /dev/null
|
| +++ b/include/core/SkFont.h
|
| @@ -0,0 +1,98 @@
|
| +/*
|
| + * 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 SkPaint;
|
| +class SkTypeface;
|
| +
|
| +enum SkTextEncoding {
|
| + kUTF8_SkTextEncoding,
|
| + kUTF16_SkTextEncoding,
|
| + kUTF32_SkTextEncoding,
|
| + kGlyphID_SkTextEncoding,
|
| +};
|
| +
|
| +class SkFont : public SkRefCnt {
|
| +public:
|
| + enum Flags {
|
| + /**
|
| + * Use the system's automatic hinting mechanism to hint the typeface.
|
| + * 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;
|
| + * 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,
|
| + kEmbolden_Flag = 1 << 6,
|
| + };
|
| +
|
| + enum MaskType {
|
| + kBW_MaskType,
|
| + kA8_MaskType,
|
| + kLCD_MaskType,
|
| + };
|
| +
|
| + 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; }
|
| + MaskType getMaskType() const {
|
| + return (MaskType)fMaskType;
|
| + }
|
| +
|
| + 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, MaskType, uint32_t flags);
|
| + static SkFont* Create(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX,
|
| + MaskType, uint32_t flags);
|
| + static SkFont* Create(const SkFont&, SkScalar newSize);
|
| +
|
| + static SkFont* Testing_CreateFromPaint(const SkPaint&);
|
| +
|
| +private:
|
| + enum {
|
| + kAllFlags = 0x3F,
|
| + };
|
| +
|
| + SkFont(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX, MaskType, uint32_t flags);
|
| + virtual ~SkFont();
|
| +
|
| + SkTypeface* fTypeface;
|
| + SkScalar fSize;
|
| + SkScalar fScaleX;
|
| + SkScalar fSkewX;
|
| + uint16_t fFlags;
|
| + uint8_t fMaskType;
|
| + uint8_t fPad;
|
| +};
|
| +
|
|
|