blob: 99b389a7ad4a8660265221eef6b25fb7798e40de [file] [log] [blame]
Fabrice Di Meglio9f82b582011-03-08 12:02:59 -08001/*
2 * Copyright 2011, The Android Open Source Project
3 * Copyright 2011, Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef HarfbuzzSkia_h
28#define HarfbuzzSkia_h
29
Fabrice Di Meglioeee49c62011-03-24 17:21:23 -070030#include "SkScalar.h"
Fabrice Di Meglio9f82b582011-03-08 12:02:59 -080031#include "SkTypeface.h"
Fabrice Di Meglioeee49c62011-03-24 17:21:23 -070032#include "SkPaint.h"
Fabrice Di Meglio9f82b582011-03-08 12:02:59 -080033
34extern "C" {
35#include "harfbuzz-shaper.h"
36}
37
38namespace android {
Fabrice Di Meglio9f82b582011-03-08 12:02:59 -080039
Fabrice Di Meglioeee49c62011-03-24 17:21:23 -070040static inline float HBFixedToFloat(HB_Fixed v) {
41 // Harfbuzz uses 26.6 fixed point values for pixel offsets
42 return v * (1.0f / 64);
43}
44
45static inline HB_Fixed SkScalarToHBFixed(SkScalar value) {
46 // HB_Fixed is a 26.6 fixed point format.
47 return SkScalarToFloat(value) * 64.0f;
48}
49
50typedef struct {
51 SkTypeface* typeFace;
52 SkScalar textSize;
53 SkScalar textSkewX;
54 SkScalar textScaleX;
55 uint32_t flags;
56 SkPaint::Hinting hinting;
57} FontData;
58
59HB_Error harfbuzzSkiaGetTable(void* voidface, const HB_Tag, HB_Byte* buffer, HB_UInt* len);
60extern const HB_FontClass harfbuzzSkiaClass;
61
Fabrice Di Meglio9f82b582011-03-08 12:02:59 -080062} // namespace android
63
64#endif