Hide Harfbuzz from the outer world

Don't export, don't generate private headers, don't mention HB in API.

Change-Id: I048ebd178bf4afaf9fda710a00933b95274cf910
Reviewed-by: Josh Faust <jfaust@suitabletech.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Konstantin Ritt 2013-03-10 10:55:27 +02:00 committed by The Qt Project
parent cfa663d62b
commit 0194fa135b
11 changed files with 231 additions and 115 deletions

View File

@ -1,5 +1,3 @@
DEFINES += QT_COMPILES_IN_HARFBUZZ
contains(QT_CONFIG, system-freetype) {
LIBS += -lfreetype
}

View File

@ -54,7 +54,230 @@
#define QHARFBUZZ_P_H
#include <QtCore/qchar.h>
#include <private/harfbuzz-shaper.h>
#if defined(QT_BUILD_CORE_LIB)
# include <harfbuzz-shaper.h>
#else
// a minimal set of HB types required for Qt libs other than Core
extern "C" {
typedef enum {
/* no error */
HB_Err_Ok = 0x0000,
HB_Err_Not_Covered = 0xFFFF,
/* _hb_err() is called whenever returning the following errors,
* and in a couple places for HB_Err_Not_Covered too. */
/* programmer error */
HB_Err_Invalid_Argument = 0x1A66,
/* font error */
HB_Err_Invalid_SubTable_Format = 0x157F,
HB_Err_Invalid_SubTable = 0x1570,
HB_Err_Read_Error = 0x6EAD,
/* system error */
HB_Err_Out_Of_Memory = 0xDEAD
} HB_Error;
typedef QT_PREPEND_NAMESPACE(qint8) hb_int8;
typedef QT_PREPEND_NAMESPACE(quint8) hb_uint8;
typedef QT_PREPEND_NAMESPACE(qint16) hb_int16;
typedef QT_PREPEND_NAMESPACE(quint16) hb_uint16;
typedef QT_PREPEND_NAMESPACE(qint32) hb_int32;
typedef QT_PREPEND_NAMESPACE(quint32) hb_uint32;
typedef hb_uint8 HB_Bool;
typedef hb_uint8 HB_Byte;
typedef hb_uint16 HB_UShort;
typedef hb_uint32 HB_UInt;
typedef hb_int8 HB_Char;
typedef hb_int16 HB_Short;
typedef hb_int32 HB_Int;
typedef hb_uint16 HB_UChar16;
typedef hb_uint32 HB_UChar32;
typedef hb_uint32 HB_Glyph;
typedef hb_int32 HB_Fixed; /* 26.6 */
typedef hb_int32 HB_16Dot16; /* 16.16 */
typedef hb_uint32 HB_Tag;
typedef struct {
HB_Fixed x;
HB_Fixed y;
} HB_FixedPoint;
typedef enum {
HB_Script_Common,
HB_Script_Greek,
HB_Script_Cyrillic,
HB_Script_Armenian,
HB_Script_Hebrew,
HB_Script_Arabic,
HB_Script_Syriac,
HB_Script_Thaana,
HB_Script_Devanagari,
HB_Script_Bengali,
HB_Script_Gurmukhi,
HB_Script_Gujarati,
HB_Script_Oriya,
HB_Script_Tamil,
HB_Script_Telugu,
HB_Script_Kannada,
HB_Script_Malayalam,
HB_Script_Sinhala,
HB_Script_Thai,
HB_Script_Lao,
HB_Script_Tibetan,
HB_Script_Myanmar,
HB_Script_Georgian,
HB_Script_Hangul,
HB_Script_Ogham,
HB_Script_Runic,
HB_Script_Khmer,
HB_Script_Nko,
HB_Script_Inherited,
HB_ScriptCount = HB_Script_Inherited
} HB_Script;
typedef enum {
HB_NoJustification= 0, /* Justification can't be applied after this glyph */
HB_Arabic_Space = 1, /* This glyph represents a space inside arabic text */
HB_Character = 2, /* Inter-character justification point follows this glyph */
HB_Space = 4, /* This glyph represents a blank outside an Arabic run */
HB_Arabic_Normal = 7, /* Normal Middle-Of-Word glyph that connects to the right (begin) */
HB_Arabic_Waw = 8, /* Next character is final form of Waw/Ain/Qaf/Fa */
HB_Arabic_BaRa = 9, /* Next two chars are Ba + Ra/Ya/AlefMaksura */
HB_Arabic_Alef = 10, /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */
HB_Arabic_HaaDal = 11, /* Next character is final form of Haa/Dal/Taa Marbutah */
HB_Arabic_Seen = 12, /* Initial or Medial form Of Seen/Sad */
HB_Arabic_Kashida = 13 /* Kashida(U+640) in middle of word */
} HB_JustificationClass;
#ifdef __xlC__
typedef unsigned hb_bitfield;
#else
typedef hb_uint8 hb_bitfield;
#endif
typedef struct {
hb_bitfield justification :4; /* Justification class */
hb_bitfield clusterStart :1; /* First glyph of representation of cluster */
hb_bitfield mark :1; /* needs to be positioned around base char */
hb_bitfield zeroWidth :1; /* ZWJ, ZWNJ etc, with no width */
hb_bitfield dontPrint :1;
hb_bitfield combiningClass :8;
} HB_GlyphAttributes;
typedef void * HB_GDEF;
typedef void * HB_GSUB;
typedef void * HB_GPOS;
typedef void * HB_Buffer;
typedef HB_Error (*HB_GetFontTableFunc)(void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length);
typedef struct HB_FaceRec_ {
HB_Bool isSymbolFont;
HB_GDEF gdef;
HB_GSUB gsub;
HB_GPOS gpos;
HB_Bool supported_scripts[HB_ScriptCount];
HB_Buffer buffer;
HB_Script current_script;
int current_flags; /* HB_ShaperFlags */
HB_Bool has_opentype_kerning;
HB_Bool glyphs_substituted;
HB_GlyphAttributes *tmpAttributes;
unsigned int *tmpLogClusters;
int length;
int orig_nglyphs;
void *font_for_init;
HB_GetFontTableFunc get_font_table_func;
} HB_FaceRec;
typedef struct {
HB_Fixed x, y;
HB_Fixed width, height;
HB_Fixed xOffset, yOffset;
} HB_GlyphMetrics;
typedef enum {
HB_FontAscent
} HB_FontMetric;
struct HB_Font_;
typedef struct HB_Font_ *HB_Font;
typedef struct HB_FaceRec_ *HB_Face;
typedef struct {
HB_Bool (*convertStringToGlyphIndices)(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft);
void (*getGlyphAdvances)(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags /*HB_ShaperFlag*/);
HB_Bool (*canRender)(HB_Font font, const HB_UChar16 *string, hb_uint32 length);
/* implementation needs to make sure to load a scaled glyph, so /no/ FT_LOAD_NO_SCALE */
HB_Error (*getPointInOutline)(HB_Font font, HB_Glyph glyph, int flags /*HB_ShaperFlag*/, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);
void (*getGlyphMetrics)(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics);
HB_Fixed (*getFontMetric)(HB_Font font, HB_FontMetric metric);
} HB_FontClass;
typedef struct HB_Font_ {
const HB_FontClass *klass;
/* Metrics */
HB_UShort x_ppem, y_ppem;
HB_16Dot16 x_scale, y_scale;
void *userData;
} HB_FontRec;
typedef enum {
HB_LeftToRight = 0,
HB_RightToLeft = 1
} HB_StringToGlyphsFlags;
typedef enum {
HB_ShaperFlag_Default = 0,
HB_ShaperFlag_NoKerning = 1,
HB_ShaperFlag_UseDesignMetrics = 2
} HB_ShaperFlag;
typedef struct
{
hb_uint32 pos;
hb_uint32 length;
HB_Script script;
hb_uint8 bidiLevel;
} HB_ScriptItem;
typedef struct HB_ShaperItem_ HB_ShaperItem;
struct HB_ShaperItem_ {
const HB_UChar16 *string; /* input: the Unicode UTF16 text to be shaped */
hb_uint32 stringLength; /* input: the length of the input in 16-bit words */
HB_ScriptItem item; /* input: the current run to be shaped: a run of text all in the same script that is a substring of <string> */
HB_Font font; /* input: the font: scale, units and function pointers supplying glyph indices and metrics */
HB_Face face; /* input: the shaper state; current script, access to the OpenType tables , etc. */
int shaperFlags; /* input (unused) should be set to 0; intended to support flags defined in HB_ShaperFlag */
HB_Bool glyphIndicesPresent; /* input: true if the <glyphs> array contains glyph indices ready to be shaped */
hb_uint32 initialGlyphCount; /* input: if glyphIndicesPresent is true, the number of glyph indices in the <glyphs> array */
hb_uint32 num_glyphs; /* input: capacity of output arrays <glyphs>, <attributes>, <advances>, <offsets>, and <log_clusters>; */
/* output: required capacity (may be larger than actual capacity) */
HB_Glyph *glyphs; /* output: <num_glyphs> indices of shaped glyphs */
HB_GlyphAttributes *attributes; /* output: <num_glyphs> glyph attributes */
HB_Fixed *advances; /* output: <num_glyphs> advances */
HB_FixedPoint *offsets; /* output: <num_glyphs> offsets */
unsigned short *log_clusters; /* output: for each output glyph, the index in the input of the start of its logical cluster */
/* internal */
HB_Bool kerning_applied; /* output: true if kerning was applied by the shaper */
};
}
#endif // QT_BUILD_CORE_LIB
QT_BEGIN_NAMESPACE
@ -144,4 +367,4 @@ Q_DECLARE_TYPEINFO(HB_FixedPoint, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
#endif
#endif // QHARFBUZZ_P_H

View File

@ -44,8 +44,7 @@
#include "qunicodetables_p.h"
#include "qvarlengtharray.h"
#include <private/harfbuzz-shaper.h>
#include <private/qharfbuzz_p.h>
#include "qharfbuzz_p.h"
#define FLAG(x) (1 << (x))

View File

@ -134,7 +134,7 @@ pcre {
LIBS_PRIVATE += -lpcre16
}
DEFINES += HB_EXPORT=Q_CORE_EXPORT
INCLUDEPATH += ../3rdparty/harfbuzz/src
HEADERS += ../3rdparty/harfbuzz/src/harfbuzz.h
SOURCES += ../3rdparty/harfbuzz/src/harfbuzz-buffer.c \
../3rdparty/harfbuzz/src/harfbuzz-gdef.c \

View File

@ -1,95 +0,0 @@
/*
* Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies)
* Copyright (C) 2007 Red Hat, Inc.
*
* This code is a modified version of some part of HarfBuzz,
* an OpenType Layout engine library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Red Hat Author(s): Behdad Esfahbod
*/
#ifndef QHARFBUZZ_COPY_P_H
#define QHARFBUZZ_COPY_P_H
/*
The purpose of this header file is to allow inclusion of the private
headers for font and text classes without having to pull in the full
harfbuzz library under QTDIR/src/3rdparty/harfbuzz/src
*/
#if defined(QT_BUILD_GUI_LIB) || defined(QT_COMPILES_IN_HARFBUZZ)
#include <private/qharfbuzz_p.h>
#else
extern "C" {
#ifdef __xlC__
typedef unsigned hb_bitfield;
#else
typedef QT_PREPEND_NAMESPACE(quint8) hb_bitfield;
#endif
typedef enum {
/* no error */
HB_Err_Ok = 0x0000,
HB_Err_Not_Covered = 0xFFFF,
/* _hb_err() is called whenever returning the following errors,
* and in a couple places for HB_Err_Not_Covered too. */
/* programmer error */
HB_Err_Invalid_Argument = 0x1A66,
/* font error */
HB_Err_Invalid_SubTable_Format = 0x157F,
HB_Err_Invalid_SubTable = 0x1570,
HB_Err_Read_Error = 0x6EAD,
/* system error */
HB_Err_Out_Of_Memory = 0xDEAD
} HB_Error;
typedef QT_PREPEND_NAMESPACE(quint32) HB_Glyph;
typedef void * HB_Font;
typedef void * HB_Face;
typedef void * HB_FontRec;
typedef QT_PREPEND_NAMESPACE(quint32) hb_uint32;
typedef QT_PREPEND_NAMESPACE(qint32) HB_Fixed;
typedef struct {
HB_Fixed x;
HB_Fixed y;
} HB_FixedPoint;
// The GlyphAttrbutes class is used inline so it needs to be complete.
typedef struct {
hb_bitfield justification :4; /* Justification class */
hb_bitfield clusterStart :1; /* First glyph of representation of cluster */
hb_bitfield mark :1; /* needs to be positioned around base char */
hb_bitfield zeroWidth :1; /* ZWJ, ZWNJ etc, with no width */
hb_bitfield dontPrint :1;
hb_bitfield combiningClass :8;
} HB_GlyphAttributes;
}
#endif // ifdef QT_BUILD_GUI_LIB
#endif // QHARFBUZZ_COPY_P_H

View File

@ -42,7 +42,6 @@ HEADERS += \
text/qrawfont_p.h \
text/qglyphrun.h \
text/qglyphrun_p.h \
text/qharfbuzz_copy_p.h \
text/qdistancefield_p.h
SOURCES += \

View File

@ -1,5 +1,3 @@
DEFINES += QT_COMPILES_IN_HARFBUZZ
!win32|contains(QT_CONFIG, freetype):!mac {
include($$PWD/basic/basic.pri)
}

View File

@ -102,12 +102,8 @@ contains(QT_CONFIG, opengles2) {
}
}
# Enable access to HB_Face in harfbuzz includes included by qfontengine_p.h.
DEFINES *= QT_COMPILES_IN_HARFBUZZ
contains(QT_CONFIG, freetype) {
DEFINES *= QT_NO_FONTCONFIG
DEFINES *= QT_COMPILES_IN_HARFBUZZ
QT_FREETYPE_DIR = $$QT_SOURCE_TREE/src/3rdparty/freetype
HEADERS += \

View File

@ -3,7 +3,7 @@
"QtWidgets" => "$basedir/src/widgets",
"QtPrintSupport" => "$basedir/src/printsupport",
"QtOpenGL" => "$basedir/src/opengl",
"QtCore" => "$basedir/src/corelib;^$basedir/src/3rdparty/harfbuzz/src",
"QtCore" => "$basedir/src/corelib",
"QtXml" => "$basedir/src/xml",
"QtSql" => "$basedir/src/sql",
"QtNetwork" => "$basedir/src/network",
@ -57,10 +57,9 @@
my @angle_headers = ('egl.h', 'eglext.h', 'eglplatform.h', 'gl2.h', 'gl2ext.h', 'gl2platform.h', 'ShaderLang.h', 'khrplatform.h');
my @internal_zlib_headers = ( "crc32.h", "deflate.h", "gzguts.h", "inffast.h", "inffixed.h", "inflate.h", "inftrees.h", "trees.h", "zutil.h" );
my @zlib_headers = ( "zconf.h", "zlib.h" );
my @harfbuzz_headers = ( "harfbuzz-buffer-private.h", "harfbuzz-buffer.h", "harfbuzz-dump.h", "harfbuzz-external.h", "harfbuzz-gdef-private.h", "harfbuzz-gdef.h", "harfbuzz-global.h", "harfbuzz-gpos-private.h", "harfbuzz-gpos.h", "harfbuzz-gsub-private.h", "harfbuzz-gsub.h", "harfbuzz-impl.h", "harfbuzz-open-private.h", "harfbuzz-open.h", "harfbuzz-shape.h", "harfbuzz-shaper-private.h", "harfbuzz-shaper.h", "harfbuzz-stream-private.h", "harfbuzz-stream.h", "harfbuzz.h" );
@ignore_headers = ( @internal_zlib_headers );
@ignore_for_include_check = ( "qsystemdetection.h", "qcompilerdetection.h", "qprocessordetection.h", @zlib_headers, @angle_headers, @harfbuzz_headers);
@ignore_for_qt_begin_namespace_check = ( "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qatomic_arch.h", "qatomic_windowsce.h", "qt_windows.h", "qatomic_macosx.h", @zlib_headers, @angle_headers, @harfbuzz_headers);
@ignore_for_include_check = ( "qsystemdetection.h", "qcompilerdetection.h", "qprocessordetection.h", @zlib_headers, @angle_headers);
@ignore_for_qt_begin_namespace_check = ( "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qatomic_arch.h", "qatomic_windowsce.h", "qt_windows.h", "qatomic_macosx.h", @zlib_headers, @angle_headers);
%inject_headers = ( "$basedir/src/corelib/global" => [ "qconfig.h" ] );
# Module dependencies.
# Every module that is required to build this module should have one entry.

View File

@ -3,5 +3,4 @@ TARGET = tst_qtextlayout
QT += core-private gui-private testlib
HEADERS +=
SOURCES += tst_qtextlayout.cpp
DEFINES += QT_COMPILES_IN_HARFBUZZ
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0

View File

@ -1,5 +1,5 @@
CONFIG -= moc
QT += core-private # for harfbuzz
QT += core-private
INCLUDEPATH += . /usr/include/freetype2
SOURCES += main.cpp