19f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio/*
29f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * Copyright 2011, The Android Open Source Project
39f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * Copyright 2011, Google Inc. All rights reserved.
49f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio *
59f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * Redistribution and use in source and binary forms, with or without
69f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * modification, are permitted provided that the following conditions
79f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * are met:
89f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio *  * Redistributions of source code must retain the above copyright
99f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio *    notice, this list of conditions and the following disclaimer.
109f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio *  * Redistributions in binary form must reproduce the above copyright
119f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio *    notice, this list of conditions and the following disclaimer in the
129f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio *    documentation and/or other materials provided with the distribution.
139f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio *
149f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
159f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
169f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
179f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
189f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
199f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
209f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
219f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
229f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
239f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
249f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
259f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio */
269f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio
279f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio#ifndef HarfbuzzSkia_h
289f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio#define HarfbuzzSkia_h
299f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio
30eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio#include "SkScalar.h"
319f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio#include "SkTypeface.h"
32eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio#include "SkPaint.h"
339f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio
349f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglioextern "C" {
359f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio#include "harfbuzz-shaper.h"
369f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio}
379f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio
389f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglionamespace android {
39eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio
40eee49c699c035ffba188417489f40d34f587d65cFabrice Di Megliostatic inline float HBFixedToFloat(HB_Fixed v) {
41eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio    // Harfbuzz uses 26.6 fixed point values for pixel offsets
42eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio    return v * (1.0f / 64);
43eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio}
44eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio
45eee49c699c035ffba188417489f40d34f587d65cFabrice Di Megliostatic inline HB_Fixed SkScalarToHBFixed(SkScalar value) {
46eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio    // HB_Fixed is a 26.6 fixed point format.
47eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio    return SkScalarToFloat(value) * 64.0f;
48eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio}
49eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio
50eee49c699c035ffba188417489f40d34f587d65cFabrice Di MeglioHB_Error harfbuzzSkiaGetTable(void* voidface, const HB_Tag, HB_Byte* buffer, HB_UInt* len);
51eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglioextern const HB_FontClass harfbuzzSkiaClass;
52eee49c699c035ffba188417489f40d34f587d65cFabrice Di Meglio
539f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio}  // namespace android
549f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio
559f82b580d744ce4baf057b061994394dcf239eedFabrice Di Meglio#endif
56