Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
2 /*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
10 #ifndef SkAutoKern_DEFINED
11 #define SkAutoKern_DEFINED
13 #include "SkGlyph.h"
15 #define SkAutoKern_AdjustF(prev, next) (((next) - (prev) + 32) >> 6 << 16)
16 #define SkAutoKern_AdjustS(prev, next) SkIntToScalar(((next) - (prev) + 32) >> 6)
18 /* this is a helper class to perform auto-kerning
19 * the adjust() method returns a SkFixed corresponding
20 * to a +1/0/-1 pixel adjustment
21 */
23 class SkAutoKern {
24 public:
25 SkAutoKern() : fPrevRsbDelta(0) {}
27 SkFixed adjust(const SkGlyph& glyph)
28 {
29 // if (SkAbs32(glyph.fLsbDelta) > 47 || SkAbs32(glyph.fRsbDelta) > 47)
30 // printf("------- %d> L %d R %d\n", glyph.f_GlyphID, glyph.fLsbDelta, glyph.fRsbDelta);
32 #if 0
33 int distort = fPrevRsbDelta - glyph.fLsbDelta;
35 fPrevRsbDelta = glyph.fRsbDelta;
37 if (distort >= 32)
38 return -SK_Fixed1;
39 else if (distort < -32)
40 return +SK_Fixed1;
41 else
42 return 0;
43 #else
44 SkFixed adjust = SkAutoKern_AdjustF(fPrevRsbDelta, glyph.fLsbDelta);
45 fPrevRsbDelta = glyph.fRsbDelta;
46 return adjust;
47 #endif
48 }
49 private:
50 int fPrevRsbDelta;
51 };
53 #endif