Added ICU library
This commit is contained in:
550
project/jni/icuuc/include/layout/LEFontInstance.h
Normal file
550
project/jni/icuuc/include/layout/LEFontInstance.h
Normal file
@@ -0,0 +1,550 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LEFONTINSTANCE_H
|
||||
#define __LEFONTINSTANCE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Layout Engine Font Instance object
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Instances of this class are used by <code>LEFontInstance::mapCharsToGlyphs</code> and
|
||||
* <code>LEFontInstance::mapCharToGlyph</code> to adjust character codes before the character
|
||||
* to glyph mapping process. Examples of this are filtering out control characters
|
||||
* and character mirroring - replacing a character which has both a left and a right
|
||||
* hand form with the opposite form.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class LECharMapper /* not : public UObject because this is an interface/mixin class */
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual ~LECharMapper();
|
||||
|
||||
/**
|
||||
* This method does the adjustments.
|
||||
*
|
||||
* @param ch - the input character
|
||||
*
|
||||
* @return the adjusted character
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual LEUnicode32 mapChar(LEUnicode32 ch) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a forward reference to the class which holds the per-glyph
|
||||
* storage.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
class LEGlyphStorage;
|
||||
|
||||
/**
|
||||
* This is a virtual base class that serves as the interface between a LayoutEngine
|
||||
* and the platform font environment. It allows a LayoutEngine to access font tables, do
|
||||
* character to glyph mapping, and obtain metrics information without knowing any platform
|
||||
* specific details. There are also a few utility methods for converting between points,
|
||||
* pixels and funits. (font design units)
|
||||
*
|
||||
* An instance of an <code>LEFontInstance</code> represents a font at a particular point
|
||||
* size. Each instance can represent either a single physical font, or a composite font.
|
||||
* A composite font is a collection of physical fonts, each of which contains a subset of
|
||||
* the characters contained in the composite font.
|
||||
*
|
||||
* Note: with the exception of <code>getSubFont</code>, the methods in this class only
|
||||
* make sense for a physical font. If you have an <code>LEFontInstance</code> which
|
||||
* represents a composite font you should only call the methods below which have
|
||||
* an <code>LEGlyphID</code>, an <code>LEUnicode</code> or an <code>LEUnicode32</code>
|
||||
* as one of the arguments because these can be used to select a particular subfont.
|
||||
*
|
||||
* Subclasses which implement composite fonts should supply an implementation of these
|
||||
* methods with some default behavior such as returning constant values, or using the
|
||||
* values from the first subfont.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
class U_LAYOUT_API LEFontInstance : public UObject
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* This virtual destructor is here so that the subclass
|
||||
* destructors can be invoked through the base class.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual ~LEFontInstance();
|
||||
|
||||
/**
|
||||
* Get a physical font which can render the given text. For composite fonts,
|
||||
* if there is no single physical font which can render all of the text,
|
||||
* return a physical font which can render an initial substring of the text,
|
||||
* and set the <code>offset</code> parameter to the end of that substring.
|
||||
*
|
||||
* Internally, the LayoutEngine works with runs of text all in the same
|
||||
* font and script, so it is best to call this method with text which is
|
||||
* in a single script, passing the script code in as a hint. If you don't
|
||||
* know the script of the text, you can use zero, which is the script code
|
||||
* for characters used in more than one script.
|
||||
*
|
||||
* The default implementation of this method is intended for instances of
|
||||
* <code>LEFontInstance</code> which represent a physical font. It returns
|
||||
* <code>this</code> and indicates that the entire string can be rendered.
|
||||
*
|
||||
* This method will return a valid <code>LEFontInstance</code> unless you
|
||||
* have passed illegal parameters, or an internal error has been encountered.
|
||||
* For composite fonts, it may return the warning <code>LE_NO_SUBFONT_WARNING</code>
|
||||
* to indicate that the returned font may not be able to render all of
|
||||
* the text. Whenever a valid font is returned, the <code>offset</code> parameter
|
||||
* will be advanced by at least one.
|
||||
*
|
||||
* Subclasses which implement composite fonts must override this method.
|
||||
* Where it makes sense, they should use the script code as a hint to render
|
||||
* characters from the COMMON script in the font which is used for the given
|
||||
* script. For example, if the input text is a series of Arabic words separated
|
||||
* by spaces, and the script code passed in is <code>arabScriptCode</code> you
|
||||
* should return the font used for Arabic characters for all of the input text,
|
||||
* including the spaces. If, on the other hand, the input text contains characters
|
||||
* which cannot be rendered by the font used for Arabic characters, but which can
|
||||
* be rendered by another font, you should return that font for those characters.
|
||||
*
|
||||
* @param chars - the array of Unicode characters.
|
||||
* @param offset - a pointer to the starting offset in the text. On exit this
|
||||
* will be set the the limit offset of the text which can be
|
||||
* rendered using the returned font.
|
||||
* @param limit - the limit offset for the input text.
|
||||
* @param script - the script hint.
|
||||
* @param success - set to an error code if the arguments are illegal, or no font
|
||||
* can be returned for some reason. May also be set to
|
||||
* <code>LE_NO_SUBFONT_WARNING</code> if the subfont which
|
||||
* was returned cannot render all of the text.
|
||||
*
|
||||
* @return an <code>LEFontInstance</code> for the sub font which can render the characters, or
|
||||
* <code>NULL</code> if there is an error.
|
||||
*
|
||||
* @see LEScripts.h
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const;
|
||||
|
||||
//
|
||||
// Font file access
|
||||
//
|
||||
|
||||
/**
|
||||
* This method reads a table from the font. Note that in general,
|
||||
* it only makes sense to call this method on an <code>LEFontInstance</code>
|
||||
* which represents a physical font - i.e. one which has been returned by
|
||||
* <code>getSubFont()</code>. This is because each subfont in a composite font
|
||||
* will have different tables, and there's no way to know which subfont to access.
|
||||
*
|
||||
* Subclasses which represent composite fonts should always return <code>NULL</code>.
|
||||
*
|
||||
* Note that implementing this function does not allow for range checking.
|
||||
* Subclasses that desire the safety of range checking must implement the
|
||||
* variation which has a length parameter.
|
||||
*
|
||||
* @param tableTag - the four byte table tag. (e.g. 'cmap')
|
||||
*
|
||||
* @return the address of the table in memory, or <code>NULL</code>
|
||||
* if the table doesn't exist.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual const void *getFontTable(LETag tableTag) const = 0;
|
||||
|
||||
/**
|
||||
* This method reads a table from the font. Note that in general,
|
||||
* it only makes sense to call this method on an <code>LEFontInstance</code>
|
||||
* which represents a physical font - i.e. one which has been returned by
|
||||
* <code>getSubFont()</code>. This is because each subfont in a composite font
|
||||
* will have different tables, and there's no way to know which subfont to access.
|
||||
*
|
||||
* Subclasses which represent composite fonts should always return <code>NULL</code>.
|
||||
*
|
||||
* This version sets a length, for range checking.
|
||||
* Note that range checking can only be accomplished if this function is
|
||||
* implemented in subclasses.
|
||||
*
|
||||
* @param tableTag - the four byte table tag. (e.g. 'cmap')
|
||||
* @param length - ignored on entry, on exit will be the length of the table if known, or -1 if unknown.
|
||||
* @return the address of the table in memory, or <code>NULL</code>
|
||||
* if the table doesn't exist.
|
||||
* @draft ICU 52
|
||||
*/
|
||||
virtual const void* getFontTable(LETag tableTag, size_t &length) const { length=-1; return getFontTable(tableTag); } /* -1 = unknown length */
|
||||
|
||||
/**
|
||||
* This method is used to determine if the font can
|
||||
* render the given character. This can usually be done
|
||||
* by looking the character up in the font's character
|
||||
* to glyph mapping.
|
||||
*
|
||||
* The default implementation of this method will return
|
||||
* <code>TRUE</code> if <code>mapCharToGlyph(ch)</code>
|
||||
* returns a non-zero value.
|
||||
*
|
||||
* @param ch - the character to be tested
|
||||
*
|
||||
* @return <code>TRUE</code> if the font can render ch.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_bool canDisplay(LEUnicode32 ch) const;
|
||||
|
||||
/**
|
||||
* This method returns the number of design units in
|
||||
* the font's EM square.
|
||||
*
|
||||
* @return the number of design units pre EM.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual le_int32 getUnitsPerEM() const = 0;
|
||||
|
||||
/**
|
||||
* This method maps an array of character codes to an array of glyph
|
||||
* indices, using the font's character to glyph map.
|
||||
*
|
||||
* The default implementation iterates over all of the characters and calls
|
||||
* <code>mapCharToGlyph(ch, mapper)</code> on each one. It also handles surrogate
|
||||
* characters, storing the glyph ID for the high surrogate, and a deleted glyph (0xFFFF)
|
||||
* for the low surrogate.
|
||||
*
|
||||
* Most sublcasses will not need to implement this method.
|
||||
*
|
||||
* @param chars - the character array
|
||||
* @param offset - the index of the first character
|
||||
* @param count - the number of characters
|
||||
* @param reverse - if <code>TRUE</code>, store the glyph indices in reverse order.
|
||||
* @param mapper - the character mapper.
|
||||
* @param filterZeroWidth - <code>TRUE</code> if ZWJ / ZWNJ characters should map to a glyph w/ no contours.
|
||||
* @param glyphStorage - the object which contains the output glyph array
|
||||
*
|
||||
* @see LECharMapper
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage) const;
|
||||
|
||||
/**
|
||||
* This method maps a single character to a glyph index, using the
|
||||
* font's character to glyph map. The default implementation of this
|
||||
* method calls the mapper, and then calls <code>mapCharToGlyph(mappedCh)</code>.
|
||||
*
|
||||
* @param ch - the character
|
||||
* @param mapper - the character mapper
|
||||
* @param filterZeroWidth - <code>TRUE</code> if ZWJ / ZWNJ characters should map to a glyph w/ no contours.
|
||||
*
|
||||
* @return the glyph index
|
||||
*
|
||||
* @see LECharMapper
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
|
||||
|
||||
/**
|
||||
* This method maps a single character to a glyph index, using the
|
||||
* font's character to glyph map. The default implementation of this
|
||||
* method calls the mapper, and then calls <code>mapCharToGlyph(mappedCh)</code>.
|
||||
*
|
||||
* @param ch - the character
|
||||
* @param mapper - the character mapper
|
||||
*
|
||||
* @return the glyph index
|
||||
*
|
||||
* @see LECharMapper
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
|
||||
|
||||
/**
|
||||
* This method maps a single character to a glyph index, using the
|
||||
* font's character to glyph map. There is no default implementation
|
||||
* of this method because it requires information about the platform
|
||||
* font implementation.
|
||||
*
|
||||
* @param ch - the character
|
||||
*
|
||||
* @return the glyph index
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0;
|
||||
|
||||
//
|
||||
// Metrics
|
||||
//
|
||||
|
||||
/**
|
||||
* This method gets the X and Y advance of a particular glyph, in pixels.
|
||||
*
|
||||
* @param glyph - the glyph index
|
||||
* @param advance - the X and Y pixel values will be stored here
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
|
||||
|
||||
/**
|
||||
* This method gets the hinted X and Y pixel coordinates of a particular
|
||||
* point in the outline of the given glyph.
|
||||
*
|
||||
* @param glyph - the glyph index
|
||||
* @param pointNumber - the number of the point
|
||||
* @param point - the point's X and Y pixel values will be stored here
|
||||
*
|
||||
* @return <code>TRUE</code> if the point coordinates could be stored.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
|
||||
|
||||
/**
|
||||
* This method returns the width of the font's EM square
|
||||
* in pixels.
|
||||
*
|
||||
* @return the pixel width of the EM square
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual float getXPixelsPerEm() const = 0;
|
||||
|
||||
/**
|
||||
* This method returns the height of the font's EM square
|
||||
* in pixels.
|
||||
*
|
||||
* @return the pixel height of the EM square
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual float getYPixelsPerEm() const = 0;
|
||||
|
||||
/**
|
||||
* This method converts font design units in the
|
||||
* X direction to points.
|
||||
*
|
||||
* @param xUnits - design units in the X direction
|
||||
*
|
||||
* @return points in the X direction
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual float xUnitsToPoints(float xUnits) const;
|
||||
|
||||
/**
|
||||
* This method converts font design units in the
|
||||
* Y direction to points.
|
||||
*
|
||||
* @param yUnits - design units in the Y direction
|
||||
*
|
||||
* @return points in the Y direction
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual float yUnitsToPoints(float yUnits) const;
|
||||
|
||||
/**
|
||||
* This method converts font design units to points.
|
||||
*
|
||||
* @param units - X and Y design units
|
||||
* @param points - set to X and Y points
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual void unitsToPoints(LEPoint &units, LEPoint &points) const;
|
||||
|
||||
/**
|
||||
* This method converts pixels in the
|
||||
* X direction to font design units.
|
||||
*
|
||||
* @param xPixels - pixels in the X direction
|
||||
*
|
||||
* @return font design units in the X direction
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual float xPixelsToUnits(float xPixels) const;
|
||||
|
||||
/**
|
||||
* This method converts pixels in the
|
||||
* Y direction to font design units.
|
||||
*
|
||||
* @param yPixels - pixels in the Y direction
|
||||
*
|
||||
* @return font design units in the Y direction
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual float yPixelsToUnits(float yPixels) const;
|
||||
|
||||
/**
|
||||
* This method converts pixels to font design units.
|
||||
*
|
||||
* @param pixels - X and Y pixel
|
||||
* @param units - set to X and Y font design units
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual void pixelsToUnits(LEPoint &pixels, LEPoint &units) const;
|
||||
|
||||
/**
|
||||
* Get the X scale factor from the font's transform. The default
|
||||
* implementation of <code>transformFunits()</code> will call this method.
|
||||
*
|
||||
* @return the X scale factor.
|
||||
*
|
||||
*
|
||||
* @see transformFunits
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual float getScaleFactorX() const = 0;
|
||||
|
||||
/**
|
||||
* Get the Y scale factor from the font's transform. The default
|
||||
* implementation of <code>transformFunits()</code> will call this method.
|
||||
*
|
||||
* @return the Yscale factor.
|
||||
*
|
||||
* @see transformFunits
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual float getScaleFactorY() const = 0;
|
||||
|
||||
/**
|
||||
* This method transforms an X, Y point in font design units to a
|
||||
* pixel coordinate, applying the font's transform. The default
|
||||
* implementation of this method calls <code>getScaleFactorX()</code>
|
||||
* and <code>getScaleFactorY()</code>.
|
||||
*
|
||||
* @param xFunits - the X coordinate in font design units
|
||||
* @param yFunits - the Y coordinate in font design units
|
||||
* @param pixels - the tranformed co-ordinate in pixels
|
||||
*
|
||||
* @see getScaleFactorX
|
||||
* @see getScaleFactorY
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
|
||||
|
||||
/**
|
||||
* This is a convenience method used to convert
|
||||
* values in a 16.16 fixed point format to floating point.
|
||||
*
|
||||
* @param fixed - the fixed point value
|
||||
*
|
||||
* @return the floating point value
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
static inline float fixedToFloat(le_int32 fixed);
|
||||
|
||||
/**
|
||||
* This is a convenience method used to convert
|
||||
* floating point values to 16.16 fixed point format.
|
||||
*
|
||||
* @param theFloat - the floating point value
|
||||
*
|
||||
* @return the fixed point value
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
static inline le_int32 floatToFixed(float theFloat);
|
||||
|
||||
//
|
||||
// These methods won't ever be called by the LayoutEngine,
|
||||
// but are useful for clients of <code>LEFontInstance</code> who
|
||||
// need to render text.
|
||||
//
|
||||
|
||||
/**
|
||||
* Get the font's ascent.
|
||||
*
|
||||
* @return the font's ascent, in points. This value
|
||||
* will always be positive.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getAscent() const = 0;
|
||||
|
||||
/**
|
||||
* Get the font's descent.
|
||||
*
|
||||
* @return the font's descent, in points. This value
|
||||
* will always be positive.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getDescent() const = 0;
|
||||
|
||||
/**
|
||||
* Get the font's leading.
|
||||
*
|
||||
* @return the font's leading, in points. This value
|
||||
* will always be positive.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getLeading() const = 0;
|
||||
|
||||
/**
|
||||
* Get the line height required to display text in
|
||||
* this font. The default implementation of this method
|
||||
* returns the sum of the ascent, descent, and leading.
|
||||
*
|
||||
* @return the line height, in points. This vaule will
|
||||
* always be positive.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getLineHeight() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static UClassID getStaticClassID();
|
||||
|
||||
};
|
||||
|
||||
inline float LEFontInstance::fixedToFloat(le_int32 fixed)
|
||||
{
|
||||
return (float) (fixed / 65536.0);
|
||||
}
|
||||
|
||||
inline le_int32 LEFontInstance::floatToFixed(float theFloat)
|
||||
{
|
||||
return (le_int32) (theFloat * 65536.0);
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
45
project/jni/icuuc/include/layout/LEGlyphFilter.h
Normal file
45
project/jni/icuuc/include/layout/LEGlyphFilter.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LEGLYPHFILTER__H
|
||||
#define __LEGLYPHFILTER__H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* This is a helper class that is used to
|
||||
* recognize a set of glyph indices.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class LEGlyphFilter /* not : public UObject because this is an interface/mixin class */ {
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @internal
|
||||
*/
|
||||
virtual ~LEGlyphFilter();
|
||||
|
||||
/**
|
||||
* This method is used to test a particular
|
||||
* glyph index to see if it is in the set
|
||||
* recognized by the filter.
|
||||
*
|
||||
* @param glyph - the glyph index to be tested
|
||||
*
|
||||
* @return TRUE if the glyph index is in the set.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual le_bool accept(LEGlyphID glyph) const = 0;
|
||||
};
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
546
project/jni/icuuc/include/layout/LEGlyphStorage.h
Normal file
546
project/jni/icuuc/include/layout/LEGlyphStorage.h
Normal file
@@ -0,0 +1,546 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1998-2010, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __LEGLYPHSTORAGE_H
|
||||
#define __LEGLYPHSTORAGE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
#include "LEInsertionList.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: This class encapsulates the per-glyph storage used by the ICU LayoutEngine.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This class encapsulates the per-glyph storage used by the ICU LayoutEngine.
|
||||
* For each glyph it holds the glyph ID, the index of the backing store character
|
||||
* which produced the glyph, the X and Y position of the glyph and an auxillary data
|
||||
* pointer.
|
||||
*
|
||||
* The storage is growable using the <code>LEInsertionList</code> class.
|
||||
*
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
class U_LAYOUT_API LEGlyphStorage : public UObject, protected LEInsertionCallback
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The number of entries in the per-glyph arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fGlyphCount;
|
||||
|
||||
/**
|
||||
* The glyph ID array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEGlyphID *fGlyphs;
|
||||
|
||||
/**
|
||||
* The char indices array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 *fCharIndices;
|
||||
|
||||
/**
|
||||
* The glyph positions array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
float *fPositions;
|
||||
|
||||
/**
|
||||
* The auxillary data array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_uint32 *fAuxData;
|
||||
|
||||
|
||||
/**
|
||||
* The insertion list, used to grow the above arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEInsertionList *fInsertionList;
|
||||
|
||||
/**
|
||||
* The source index while growing the data arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fSrcIndex;
|
||||
|
||||
/**
|
||||
* The destination index used while growing the data arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fDestIndex;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This implements <code>LEInsertionCallback</code>. The <code>LEInsertionList</code>
|
||||
* will call this method once for each insertion.
|
||||
*
|
||||
* @param atPosition the position of the insertion
|
||||
* @param count the number of glyphs being inserted
|
||||
* @param newGlyphs the address of the new glyph IDs
|
||||
*
|
||||
* @return <code>true</code> if <code>LEInsertionList</code> should stop
|
||||
* processing the insertion list after this insertion.
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Allocates an empty <code>LEGlyphStorage</code> object. You must call
|
||||
* <code>allocateGlyphArray, allocatePositions and allocateAuxData</code>
|
||||
* to allocate the data.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
LEGlyphStorage();
|
||||
|
||||
/**
|
||||
* The destructor. This will deallocate all of the arrays.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
~LEGlyphStorage();
|
||||
|
||||
/**
|
||||
* This method returns the number of glyphs in the glyph array.
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
inline le_int32 getGlyphCount() const;
|
||||
|
||||
/**
|
||||
* This method copies the glyph array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold all
|
||||
* the glyphs.
|
||||
*
|
||||
* @param glyphs - the destiniation glyph array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the glyph array into a caller supplied array,
|
||||
* ORing in extra bits. (This functionality is needed by the JDK,
|
||||
* which uses 32 bits pre glyph idex, with the high 16 bits encoding
|
||||
* the composite font slot number)
|
||||
*
|
||||
* @param glyphs - the destination (32 bit) glyph array
|
||||
* @param extraBits - this value will be ORed with each glyph index
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param indexBase - an offset which will be added to each index
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the position array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold an
|
||||
* X and Y position for each glyph, plus an extra X and Y for the
|
||||
* advance of the last glyph.
|
||||
*
|
||||
* @param positions - the destiniation position array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void getGlyphPositions(float positions[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method returns the X and Y position of the glyph at
|
||||
* the given index.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param glyphIndex - the index of the glyph
|
||||
*
|
||||
* Output parameters:
|
||||
* @param x - the glyph's X position
|
||||
* @param y - the glyph's Y position
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method allocates the glyph array, the char indices array and the insertion list. You
|
||||
* must call this method before using the object. This method also initializes the char indices
|
||||
* array.
|
||||
*
|
||||
* @param initialGlyphCount the initial size of the glyph and char indices arrays.
|
||||
* @param rightToLeft <code>true</code> if the original input text is right to left.
|
||||
* @param success set to an error code if the storage cannot be allocated of if the initial
|
||||
* glyph count is not positive.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void allocateGlyphArray(le_int32 initialGlyphCount, le_bool rightToLeft, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method allocates the storage for the glyph positions. It allocates one extra X, Y
|
||||
* position pair for the position just after the last glyph.
|
||||
*
|
||||
* @param success set to an error code if the positions array cannot be allocated.
|
||||
*
|
||||
* @return the number of X, Y position pairs allocated.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
le_int32 allocatePositions(LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method allocates the storage for the auxillary glyph data.
|
||||
*
|
||||
* @param success set to an error code if the aulillary data array cannot be allocated.
|
||||
*
|
||||
* @return the size of the auxillary data array.
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
le_int32 allocateAuxData(LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Copy the entire auxillary data array.
|
||||
*
|
||||
* @param auxData the auxillary data array will be copied to this address
|
||||
* @param success set to an error code if the data cannot be copied
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
void getAuxData(le_uint32 auxData[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* Get the glyph ID for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index into the glyph array
|
||||
* @param success set to an error code if the glyph ID cannot be retrieved.
|
||||
*
|
||||
* @return the glyph ID
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
LEGlyphID getGlyphID(le_int32 glyphIndex, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* Get the char index for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index into the glyph array
|
||||
* @param success set to an error code if the char index cannot be retrieved.
|
||||
*
|
||||
* @return the character index
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
le_int32 getCharIndex(le_int32 glyphIndex, LEErrorCode &success) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get the auxillary data for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index into the glyph array
|
||||
* @param success set to an error code if the auxillary data cannot be retrieved.
|
||||
*
|
||||
* @return the auxillary data
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
le_uint32 getAuxData(le_int32 glyphIndex, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This operator allows direct access to the glyph array
|
||||
* using the index operator.
|
||||
*
|
||||
* @param glyphIndex the index into the glyph array
|
||||
*
|
||||
* @return a reference to the given location in the glyph array
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
inline LEGlyphID &operator[](le_int32 glyphIndex) const;
|
||||
|
||||
/**
|
||||
* Call this method to replace a single glyph in the glyph array
|
||||
* with multiple glyphs. This method uses the <code>LEInsertionList</code>
|
||||
* to do the insertion. It returns the address of storage where the new
|
||||
* glyph IDs can be stored. They will not actually be inserted into the
|
||||
* glyph array until <code>applyInsertions</code> is called.
|
||||
*
|
||||
* @param atIndex the index of the glyph to be replaced
|
||||
* @param insertCount the number of glyphs to replace it with
|
||||
* @param success set to an error code if the auxillary data cannot be retrieved.
|
||||
*
|
||||
* @return the address at which to store the replacement glyphs.
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
LEGlyphID *insertGlyphs(le_int32 atIndex, le_int32 insertCount, LEErrorCode& success);
|
||||
|
||||
/**
|
||||
* Call this method to replace a single glyph in the glyph array
|
||||
* with multiple glyphs. This method uses the <code>LEInsertionList</code>
|
||||
* to do the insertion. It returns the address of storage where the new
|
||||
* glyph IDs can be stored. They will not actually be inserted into the
|
||||
* glyph array until <code>applyInsertions</code> is called.
|
||||
*
|
||||
* Note: Don't use this version, use the other version of this function which has an error code.
|
||||
*
|
||||
* @param atIndex the index of the glyph to be replaced
|
||||
* @param insertCount the number of glyphs to replace it with
|
||||
*
|
||||
* @return the address at which to store the replacement glyphs.
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
LEGlyphID *insertGlyphs(le_int32 atIndex, le_int32 insertCount);
|
||||
|
||||
/**
|
||||
* This method is used to reposition glyphs during Indic v2 processing. It moves
|
||||
* all of the relevant glyph information ( glyph, indices, positions, and auxData ),
|
||||
* from the source position to the target position, and also allows for a marker bit
|
||||
* to be set in the target glyph's auxData so that it won't be reprocessed later in the
|
||||
* cycle.
|
||||
*
|
||||
* @param fromPosition - position of the glyph to be moved
|
||||
* @param toPosition - target position of the glyph
|
||||
* @param marker marker bit
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
void moveGlyph(le_int32 fromPosition, le_int32 toPosition, le_uint32 marker);
|
||||
|
||||
/**
|
||||
* This method causes all of the glyph insertions recorded by
|
||||
* <code>insertGlyphs</code> to be applied to the glyph array. The
|
||||
* new slots in the char indices and the auxillary data arrays
|
||||
* will be filled in with the values for the glyph being replaced.
|
||||
*
|
||||
* @return the new size of the glyph array
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
le_int32 applyInsertions();
|
||||
|
||||
/**
|
||||
* Set the glyph ID for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param glyphID the new glyph ID
|
||||
* @param success will be set to an error code if the glyph ID cannot be set.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void setGlyphID(le_int32 glyphIndex, LEGlyphID glyphID, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Set the char index for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param charIndex the new char index
|
||||
* @param success will be set to an error code if the char index cannot be set.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void setCharIndex(le_int32 glyphIndex, le_int32 charIndex, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Set the X, Y position for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param x the new X position
|
||||
* @param y the new Y position
|
||||
* @param success will be set to an error code if the position cannot be set.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void setPosition(le_int32 glyphIndex, float x, float y, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Adjust the X, Y position for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param xAdjust the adjustment to the glyph's X position
|
||||
* @param yAdjust the adjustment to the glyph's Y position
|
||||
* @param success will be set to an error code if the glyph's position cannot be adjusted.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void adjustPosition(le_int32 glyphIndex, float xAdjust, float yAdjust, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Set the auxillary data for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param auxData the new auxillary data
|
||||
* @param success will be set to an error code if the auxillary data cannot be set.
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
void setAuxData(le_int32 glyphIndex, le_uint32 auxData, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Delete the glyph array and replace it with the one
|
||||
* in <code>from</code>. Set the glyph array pointer
|
||||
* in <code>from</code> to <code>NULL</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new glyph array.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void adoptGlyphArray(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Delete the char indices array and replace it with the one
|
||||
* in <code>from</code>. Set the char indices array pointer
|
||||
* in <code>from</code> to <code>NULL</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new char indices array.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void adoptCharIndicesArray(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Delete the position array and replace it with the one
|
||||
* in <code>from</code>. Set the position array pointer
|
||||
* in <code>from</code> to <code>NULL</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new position array.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void adoptPositionArray(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Delete the auxillary data array and replace it with the one
|
||||
* in <code>from</code>. Set the auxillary data array pointer
|
||||
* in <code>from</code> to <code>NULL</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new auxillary data array.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void adoptAuxDataArray(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Change the glyph count of this object to be the same
|
||||
* as the one in <code>from</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new glyph count.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void adoptGlyphCount(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Change the glyph count of this object to the given value.
|
||||
*
|
||||
* @param newGlyphCount the new glyph count.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void adoptGlyphCount(le_int32 newGlyphCount);
|
||||
|
||||
/**
|
||||
* This method frees the glyph, character index, position and
|
||||
* auxillary data arrays so that the LayoutEngine can be reused
|
||||
* to layout a different characer array. (This method is also called
|
||||
* by the destructor)
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
static UClassID getStaticClassID();
|
||||
};
|
||||
|
||||
inline le_int32 LEGlyphStorage::getGlyphCount() const
|
||||
{
|
||||
return fGlyphCount;
|
||||
}
|
||||
|
||||
inline LEGlyphID &LEGlyphStorage::operator[](le_int32 glyphIndex) const
|
||||
{
|
||||
return fGlyphs[glyphIndex];
|
||||
}
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
177
project/jni/icuuc/include/layout/LEInsertionList.h
Normal file
177
project/jni/icuuc/include/layout/LEInsertionList.h
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1998-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __LEINSERTIONLIST_H
|
||||
#define __LEINSERTIONLIST_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
struct InsertionRecord;
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* This class encapsulates the callback used by <code>LEInsertionList</code>
|
||||
* to apply an insertion from the insertion list.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class U_LAYOUT_API LEInsertionCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This method will be called by <code>LEInsertionList::applyInsertions</code> for each
|
||||
* entry on the insertion list.
|
||||
*
|
||||
* @param atPosition the position of the insertion
|
||||
* @param count the number of glyphs to insert
|
||||
* @param newGlyphs the address of the glyphs to insert
|
||||
*
|
||||
* @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should
|
||||
* stop after applying this insertion.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]) = 0;
|
||||
|
||||
/**
|
||||
* The destructor
|
||||
*/
|
||||
virtual ~LEInsertionCallback();
|
||||
};
|
||||
|
||||
/**
|
||||
* This class is used to keep track of insertions to an array of
|
||||
* <code>LEGlyphIDs</code>. The insertions are kept on a linked
|
||||
* list of <code>InsertionRecords</code> so that the glyph array
|
||||
* doesn't have to be grown for each insertion. The insertions are
|
||||
* stored on the list from leftmost to rightmost to make it easier
|
||||
* to do the insertions.
|
||||
*
|
||||
* The insertions are applied to the array by calling the
|
||||
* <code>applyInsertions</code> method, which calls a client
|
||||
* supplied <code>LEInsertionCallback</code> object to actually
|
||||
* apply the individual insertions.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class LEInsertionList : public UObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct an empty insertion list.
|
||||
*
|
||||
* @param rightToLeft <code>TRUE</code> if the glyphs are stored
|
||||
* in the array in right to left order.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEInsertionList(le_bool rightToLeft);
|
||||
|
||||
/**
|
||||
* The destructor.
|
||||
*/
|
||||
~LEInsertionList();
|
||||
|
||||
/**
|
||||
* Add an entry to the insertion list.
|
||||
*
|
||||
* @param position the glyph at this position in the array will be
|
||||
* replaced by the new glyphs.
|
||||
* @param count the number of new glyphs
|
||||
* @param success set to an error code if the auxillary data cannot be retrieved.
|
||||
*
|
||||
* @return the address of an array in which to store the new glyphs. This will
|
||||
* <em>not</em> be in the glyph array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEGlyphID *insert(le_int32 position, le_int32 count, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Return the number of new glyphs that have been inserted.
|
||||
*
|
||||
* @return the number of new glyphs which have been inserted
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 getGrowAmount();
|
||||
|
||||
/**
|
||||
* Call the <code>LEInsertionCallback</code> once for each
|
||||
* entry on the insertion list.
|
||||
*
|
||||
* @param callback the <code>LEInsertionCallback</code> to call for each insertion.
|
||||
*
|
||||
* @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to
|
||||
* terminate the insertion list processing.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_bool applyInsertions(LEInsertionCallback *callback);
|
||||
|
||||
/**
|
||||
* Empty the insertion list and free all associated
|
||||
* storage.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
static UClassID getStaticClassID();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The head of the insertion list.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
InsertionRecord *head;
|
||||
|
||||
/**
|
||||
* The tail of the insertion list.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
InsertionRecord *tail;
|
||||
|
||||
/**
|
||||
* The total number of new glyphs on the insertion list.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 growAmount;
|
||||
|
||||
/**
|
||||
* Set to <code>TRUE</code> if the glyphs are in right
|
||||
* to left order. Since we want the rightmost insertion
|
||||
* to be first on the list, we need to append the
|
||||
* insertions in this case. Otherwise they're prepended.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_bool append;
|
||||
};
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
111
project/jni/icuuc/include/layout/LELanguages.h
Normal file
111
project/jni/icuuc/include/layout/LELanguages.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2010. All Rights Reserved.
|
||||
*
|
||||
* WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS
|
||||
* YOU REALLY KNOW WHAT YOU'RE DOING.
|
||||
*
|
||||
* Generated on: 10/26/2010 02:53:33 PM PDT
|
||||
*/
|
||||
|
||||
#ifndef __LELANGUAGES_H
|
||||
#define __LELANGUAGES_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: List of language codes for LayoutEngine
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* A provisional list of language codes. For now,
|
||||
* this is just a list of languages which the LayoutEngine
|
||||
* supports.
|
||||
*
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
|
||||
enum LanguageCodes {
|
||||
nullLanguageCode = 0,
|
||||
araLanguageCode = 1,
|
||||
asmLanguageCode = 2,
|
||||
benLanguageCode = 3,
|
||||
farLanguageCode = 4,
|
||||
gujLanguageCode = 5,
|
||||
hinLanguageCode = 6,
|
||||
iwrLanguageCode = 7,
|
||||
jiiLanguageCode = 8,
|
||||
janLanguageCode = 9,
|
||||
kanLanguageCode = 10,
|
||||
kokLanguageCode = 11,
|
||||
korLanguageCode = 12,
|
||||
kshLanguageCode = 13,
|
||||
malLanguageCode = 14,
|
||||
marLanguageCode = 15,
|
||||
mlrLanguageCode = 16,
|
||||
mniLanguageCode = 17,
|
||||
oriLanguageCode = 18,
|
||||
sanLanguageCode = 19,
|
||||
sndLanguageCode = 20,
|
||||
snhLanguageCode = 21,
|
||||
syrLanguageCode = 22,
|
||||
tamLanguageCode = 23,
|
||||
telLanguageCode = 24,
|
||||
thaLanguageCode = 25,
|
||||
urdLanguageCode = 26,
|
||||
zhpLanguageCode = 27,
|
||||
zhsLanguageCode = 28,
|
||||
zhtLanguageCode = 29,
|
||||
|
||||
/** New language codes added 03/13/2008 @stable ICU 4.0 */
|
||||
afkLanguageCode = 30,
|
||||
belLanguageCode = 31,
|
||||
bgrLanguageCode = 32,
|
||||
catLanguageCode = 33,
|
||||
cheLanguageCode = 34,
|
||||
copLanguageCode = 35,
|
||||
csyLanguageCode = 36,
|
||||
danLanguageCode = 37,
|
||||
deuLanguageCode = 38,
|
||||
dznLanguageCode = 39,
|
||||
ellLanguageCode = 40,
|
||||
engLanguageCode = 41,
|
||||
espLanguageCode = 42,
|
||||
etiLanguageCode = 43,
|
||||
euqLanguageCode = 44,
|
||||
finLanguageCode = 45,
|
||||
fraLanguageCode = 46,
|
||||
gaeLanguageCode = 47,
|
||||
hauLanguageCode = 48,
|
||||
hrvLanguageCode = 49,
|
||||
hunLanguageCode = 50,
|
||||
hyeLanguageCode = 51,
|
||||
indLanguageCode = 52,
|
||||
itaLanguageCode = 53,
|
||||
khmLanguageCode = 54,
|
||||
mngLanguageCode = 55,
|
||||
mtsLanguageCode = 56,
|
||||
nepLanguageCode = 57,
|
||||
nldLanguageCode = 58,
|
||||
pasLanguageCode = 59,
|
||||
plkLanguageCode = 60,
|
||||
ptgLanguageCode = 61,
|
||||
romLanguageCode = 62,
|
||||
rusLanguageCode = 63,
|
||||
skyLanguageCode = 64,
|
||||
slvLanguageCode = 65,
|
||||
sqiLanguageCode = 66,
|
||||
srbLanguageCode = 67,
|
||||
sveLanguageCode = 68,
|
||||
tibLanguageCode = 69,
|
||||
trkLanguageCode = 70,
|
||||
welLanguageCode = 71,
|
||||
|
||||
languageCodeCount = 72
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
253
project/jni/icuuc/include/layout/LEScripts.h
Normal file
253
project/jni/icuuc/include/layout/LEScripts.h
Normal file
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2013. All Rights Reserved.
|
||||
*
|
||||
* WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS
|
||||
* YOU REALLY KNOW WHAT YOU'RE DOING.
|
||||
*
|
||||
* Generated on: 11/01/2011 04:08:09 PM PDT
|
||||
*/
|
||||
|
||||
#ifndef __LESCRIPTS_H
|
||||
#define __LESCRIPTS_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Constants for Unicode script values
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Constants for Unicode script values, generated using
|
||||
* ICU4J's <code>UScript</code> class.
|
||||
*
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
|
||||
enum ScriptCodes {
|
||||
zyyyScriptCode = 0,
|
||||
zinhScriptCode = 1,
|
||||
qaaiScriptCode = zinhScriptCode, /* manually added alias, for API stability */
|
||||
arabScriptCode = 2,
|
||||
armnScriptCode = 3,
|
||||
bengScriptCode = 4,
|
||||
bopoScriptCode = 5,
|
||||
cherScriptCode = 6,
|
||||
coptScriptCode = 7,
|
||||
cyrlScriptCode = 8,
|
||||
dsrtScriptCode = 9,
|
||||
devaScriptCode = 10,
|
||||
ethiScriptCode = 11,
|
||||
georScriptCode = 12,
|
||||
gothScriptCode = 13,
|
||||
grekScriptCode = 14,
|
||||
gujrScriptCode = 15,
|
||||
guruScriptCode = 16,
|
||||
haniScriptCode = 17,
|
||||
hangScriptCode = 18,
|
||||
hebrScriptCode = 19,
|
||||
hiraScriptCode = 20,
|
||||
kndaScriptCode = 21,
|
||||
kanaScriptCode = 22,
|
||||
khmrScriptCode = 23,
|
||||
laooScriptCode = 24,
|
||||
latnScriptCode = 25,
|
||||
mlymScriptCode = 26,
|
||||
mongScriptCode = 27,
|
||||
mymrScriptCode = 28,
|
||||
ogamScriptCode = 29,
|
||||
italScriptCode = 30,
|
||||
oryaScriptCode = 31,
|
||||
runrScriptCode = 32,
|
||||
sinhScriptCode = 33,
|
||||
syrcScriptCode = 34,
|
||||
tamlScriptCode = 35,
|
||||
teluScriptCode = 36,
|
||||
thaaScriptCode = 37,
|
||||
thaiScriptCode = 38,
|
||||
tibtScriptCode = 39,
|
||||
/**
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
|
||||
cansScriptCode = 40,
|
||||
/**
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
|
||||
yiiiScriptCode = 41,
|
||||
tglgScriptCode = 42,
|
||||
hanoScriptCode = 43,
|
||||
buhdScriptCode = 44,
|
||||
tagbScriptCode = 45,
|
||||
/**
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
|
||||
braiScriptCode = 46,
|
||||
cprtScriptCode = 47,
|
||||
limbScriptCode = 48,
|
||||
linbScriptCode = 49,
|
||||
osmaScriptCode = 50,
|
||||
shawScriptCode = 51,
|
||||
taleScriptCode = 52,
|
||||
ugarScriptCode = 53,
|
||||
/**
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
|
||||
hrktScriptCode = 54,
|
||||
/**
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
|
||||
bugiScriptCode = 55,
|
||||
glagScriptCode = 56,
|
||||
kharScriptCode = 57,
|
||||
syloScriptCode = 58,
|
||||
taluScriptCode = 59,
|
||||
tfngScriptCode = 60,
|
||||
xpeoScriptCode = 61,
|
||||
/**
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
|
||||
baliScriptCode = 62,
|
||||
batkScriptCode = 63,
|
||||
blisScriptCode = 64,
|
||||
brahScriptCode = 65,
|
||||
chamScriptCode = 66,
|
||||
cirtScriptCode = 67,
|
||||
cyrsScriptCode = 68,
|
||||
egydScriptCode = 69,
|
||||
egyhScriptCode = 70,
|
||||
egypScriptCode = 71,
|
||||
geokScriptCode = 72,
|
||||
hansScriptCode = 73,
|
||||
hantScriptCode = 74,
|
||||
hmngScriptCode = 75,
|
||||
hungScriptCode = 76,
|
||||
indsScriptCode = 77,
|
||||
javaScriptCode = 78,
|
||||
kaliScriptCode = 79,
|
||||
latfScriptCode = 80,
|
||||
latgScriptCode = 81,
|
||||
lepcScriptCode = 82,
|
||||
linaScriptCode = 83,
|
||||
mandScriptCode = 84,
|
||||
mayaScriptCode = 85,
|
||||
meroScriptCode = 86,
|
||||
nkooScriptCode = 87,
|
||||
orkhScriptCode = 88,
|
||||
permScriptCode = 89,
|
||||
phagScriptCode = 90,
|
||||
phnxScriptCode = 91,
|
||||
plrdScriptCode = 92,
|
||||
roroScriptCode = 93,
|
||||
saraScriptCode = 94,
|
||||
syreScriptCode = 95,
|
||||
syrjScriptCode = 96,
|
||||
syrnScriptCode = 97,
|
||||
tengScriptCode = 98,
|
||||
vaiiScriptCode = 99,
|
||||
vispScriptCode = 100,
|
||||
xsuxScriptCode = 101,
|
||||
zxxxScriptCode = 102,
|
||||
zzzzScriptCode = 103,
|
||||
/**
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
|
||||
cariScriptCode = 104,
|
||||
jpanScriptCode = 105,
|
||||
lanaScriptCode = 106,
|
||||
lyciScriptCode = 107,
|
||||
lydiScriptCode = 108,
|
||||
olckScriptCode = 109,
|
||||
rjngScriptCode = 110,
|
||||
saurScriptCode = 111,
|
||||
sgnwScriptCode = 112,
|
||||
sundScriptCode = 113,
|
||||
moonScriptCode = 114,
|
||||
mteiScriptCode = 115,
|
||||
/**
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
|
||||
armiScriptCode = 116,
|
||||
avstScriptCode = 117,
|
||||
cakmScriptCode = 118,
|
||||
koreScriptCode = 119,
|
||||
kthiScriptCode = 120,
|
||||
maniScriptCode = 121,
|
||||
phliScriptCode = 122,
|
||||
phlpScriptCode = 123,
|
||||
phlvScriptCode = 124,
|
||||
prtiScriptCode = 125,
|
||||
samrScriptCode = 126,
|
||||
tavtScriptCode = 127,
|
||||
zmthScriptCode = 128,
|
||||
zsymScriptCode = 129,
|
||||
/**
|
||||
* @stable ICU 4.4
|
||||
*/
|
||||
|
||||
bamuScriptCode = 130,
|
||||
lisuScriptCode = 131,
|
||||
nkgbScriptCode = 132,
|
||||
sarbScriptCode = 133,
|
||||
/**
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
|
||||
bassScriptCode = 134,
|
||||
duplScriptCode = 135,
|
||||
elbaScriptCode = 136,
|
||||
granScriptCode = 137,
|
||||
kpelScriptCode = 138,
|
||||
lomaScriptCode = 139,
|
||||
mendScriptCode = 140,
|
||||
mercScriptCode = 141,
|
||||
narbScriptCode = 142,
|
||||
nbatScriptCode = 143,
|
||||
palmScriptCode = 144,
|
||||
sindScriptCode = 145,
|
||||
waraScriptCode = 146,
|
||||
/**
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
|
||||
afakScriptCode = 147,
|
||||
jurcScriptCode = 148,
|
||||
mrooScriptCode = 149,
|
||||
nshuScriptCode = 150,
|
||||
shrdScriptCode = 151,
|
||||
soraScriptCode = 152,
|
||||
takrScriptCode = 153,
|
||||
tangScriptCode = 154,
|
||||
woleScriptCode = 155,
|
||||
/**
|
||||
* @stable ICU 49
|
||||
*/
|
||||
|
||||
hluwScriptCode = 156, /* bump to match current ICU */
|
||||
khojScriptCode = 157,
|
||||
tirhScriptCode = 158,
|
||||
|
||||
/**
|
||||
* @stable ICU 52
|
||||
*/
|
||||
aghbScriptCode = 159,
|
||||
mahjScriptCode = 160,
|
||||
|
||||
/**
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
scriptCodeCount
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
100
project/jni/icuuc/include/layout/LESwaps.h
Normal file
100
project/jni/icuuc/include/layout/LESwaps.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LESWAPS_H
|
||||
#define __LESWAPS_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Endian independent access to data for LayoutEngine
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* A convenience macro which invokes the swapWord member function
|
||||
* from a concise call.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
#define SWAPW(value) LESwaps::swapWord((le_uint16)(value))
|
||||
|
||||
/**
|
||||
* A convenience macro which invokes the swapLong member function
|
||||
* from a concise call.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
#define SWAPL(value) LESwaps::swapLong((le_uint32)(value))
|
||||
|
||||
/**
|
||||
* This class is used to access data which stored in big endian order
|
||||
* regardless of the conventions of the platform.
|
||||
*
|
||||
* All methods are static and inline in an attempt to induce the compiler
|
||||
* to do most of the calculations at compile time.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
class U_LAYOUT_API LESwaps /* not : public UObject because all methods are static */ {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Reads a big-endian 16-bit word and returns a native-endian value.
|
||||
* No-op on a big-endian platform, byte-swaps on a little-endian platform.
|
||||
*
|
||||
* @param value - the word to be byte swapped
|
||||
*
|
||||
* @return the byte swapped word
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
static le_uint16 swapWord(le_uint16 value)
|
||||
{
|
||||
#if (defined(U_IS_BIG_ENDIAN) && U_IS_BIG_ENDIAN) || \
|
||||
(defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || \
|
||||
defined(__BIG_ENDIAN__)
|
||||
// Fastpath when we know that the platform is big-endian.
|
||||
return value;
|
||||
#else
|
||||
// Reads a big-endian value on any platform.
|
||||
const le_uint8 *p = reinterpret_cast<const le_uint8 *>(&value);
|
||||
return (le_uint16)((p[0] << 8) | p[1]);
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads a big-endian 32-bit word and returns a native-endian value.
|
||||
* No-op on a big-endian platform, byte-swaps on a little-endian platform.
|
||||
*
|
||||
* @param value - the long to be byte swapped
|
||||
*
|
||||
* @return the byte swapped long
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
static le_uint32 swapLong(le_uint32 value)
|
||||
{
|
||||
#if (defined(U_IS_BIG_ENDIAN) && U_IS_BIG_ENDIAN) || \
|
||||
(defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || \
|
||||
defined(__BIG_ENDIAN__)
|
||||
// Fastpath when we know that the platform is big-endian.
|
||||
return value;
|
||||
#else
|
||||
// Reads a big-endian value on any platform.
|
||||
const le_uint8 *p = reinterpret_cast<const le_uint8 *>(&value);
|
||||
return (le_uint32)((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
|
||||
#endif
|
||||
};
|
||||
|
||||
private:
|
||||
LESwaps() {} // private - forbid instantiation
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
418
project/jni/icuuc/include/layout/LETableReference.h
Normal file
418
project/jni/icuuc/include/layout/LETableReference.h
Normal file
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
* -*- c++ -*-
|
||||
*
|
||||
* (C) Copyright IBM Corp. and others 2013 - All Rights Reserved
|
||||
*
|
||||
* Range checking
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LETABLEREFERENCE_H
|
||||
#define __LETABLEREFERENCE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
#include "LEFontInstance.h"
|
||||
|
||||
|
||||
#define kQuestionmarkTableTag 0x3F3F3F3FUL
|
||||
#define kTildeTableTag 0x7e7e7e7eUL
|
||||
#ifdef __cplusplus
|
||||
|
||||
// internal - interface for range checking
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
#if LE_ASSERT_BAD_FONT
|
||||
class LETableReference; // fwd
|
||||
/**
|
||||
* defined in OpenTypeUtilities.cpp
|
||||
* @internal
|
||||
*/
|
||||
extern void _debug_LETableReference(const char *f, int l, const char *msg, const LETableReference *what, const void *ptr, size_t len);
|
||||
|
||||
#define LE_DEBUG_TR(x) _debug_LETableReference(__FILE__, __LINE__, x, this, NULL, 0);
|
||||
#define LE_DEBUG_TR3(x,y,z) _debug_LETableReference(__FILE__, __LINE__, x, this, (const void*)y, (size_t)z);
|
||||
#if 0
|
||||
#define LE_TRACE_TR(x) _debug_LETableReference(__FILE__, __LINE__, x, this, NULL, 0);
|
||||
#else
|
||||
#define LE_TRACE_TR(x)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define LE_DEBUG_TR(x)
|
||||
#define LE_DEBUG_TR3(x,y,z)
|
||||
#define LE_TRACE_TR(x)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class LETableReference {
|
||||
public:
|
||||
/**
|
||||
* @internal
|
||||
* Construct from a specific tag
|
||||
*/
|
||||
LETableReference(const LEFontInstance* font, LETag tableTag, LEErrorCode &success) :
|
||||
fFont(font), fTag(tableTag), fParent(NULL), fStart(NULL),fLength(LE_UINTPTR_MAX) {
|
||||
loadTable(success);
|
||||
LE_TRACE_TR("INFO: new table load")
|
||||
}
|
||||
|
||||
LETableReference(const LETableReference &parent, LEErrorCode &success) : fFont(parent.fFont), fTag(parent.fTag), fParent(&parent), fStart(parent.fStart), fLength(parent.fLength) {
|
||||
if(LE_FAILURE(success)) {
|
||||
clear();
|
||||
}
|
||||
LE_TRACE_TR("INFO: new clone")
|
||||
}
|
||||
|
||||
LETableReference(const le_uint8* data, size_t length = LE_UINTPTR_MAX) :
|
||||
fFont(NULL), fTag(kQuestionmarkTableTag), fParent(NULL), fStart(data), fLength(length) {
|
||||
LE_TRACE_TR("INFO: new raw")
|
||||
}
|
||||
LETableReference() :
|
||||
fFont(NULL), fTag(kQuestionmarkTableTag), fParent(NULL), fStart(NULL), fLength(0) {
|
||||
LE_TRACE_TR("INFO: new empty")
|
||||
}
|
||||
|
||||
~LETableReference() {
|
||||
fTag=kTildeTableTag;
|
||||
LE_TRACE_TR("INFO: new dtor")
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param length if LE_UINTPTR_MAX means "whole table"
|
||||
* subset
|
||||
*/
|
||||
LETableReference(const LETableReference &parent, size_t offset, size_t length,
|
||||
LEErrorCode &err) :
|
||||
fFont(parent.fFont), fTag(parent.fTag), fParent(&parent),
|
||||
fStart((parent.fStart)+offset), fLength(length) {
|
||||
if(LE_SUCCESS(err)) {
|
||||
if(isEmpty()) {
|
||||
//err = LE_MISSING_FONT_TABLE_ERROR;
|
||||
clear(); // it's just empty. Not an error.
|
||||
} else if(offset >= fParent->fLength) {
|
||||
LE_DEBUG_TR3("offset out of range: (%p) +%d", NULL, offset);
|
||||
err = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
clear();
|
||||
} else {
|
||||
if(fLength == LE_UINTPTR_MAX &&
|
||||
fParent->fLength != LE_UINTPTR_MAX) {
|
||||
fLength = (fParent->fLength) - offset; // decrement length as base address is incremented
|
||||
}
|
||||
if(fLength != LE_UINTPTR_MAX) { // if we have bounds:
|
||||
if(offset+fLength > fParent->fLength) {
|
||||
LE_DEBUG_TR3("offset+fLength out of range: (%p) +%d", NULL, offset+fLength);
|
||||
err = LE_INDEX_OUT_OF_BOUNDS_ERROR; // exceeded
|
||||
clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
clear();
|
||||
}
|
||||
LE_TRACE_TR("INFO: new subset")
|
||||
}
|
||||
|
||||
const void* getAlias() const { return (const void*)fStart; }
|
||||
const void* getAliasRAW() const { LE_DEBUG_TR("getAliasRAW()"); return (const void*)fStart; }
|
||||
le_bool isEmpty() const { return fStart==NULL || fLength==0; }
|
||||
le_bool isValid() const { return !isEmpty(); }
|
||||
le_bool hasBounds() const { return fLength!=LE_UINTPTR_MAX; }
|
||||
void clear() { fLength=0; fStart=NULL; }
|
||||
size_t getLength() const { return fLength; }
|
||||
const LEFontInstance* getFont() const { return fFont; }
|
||||
LETag getTag() const { return fTag; }
|
||||
const LETableReference* getParent() const { return fParent; }
|
||||
|
||||
void addOffset(size_t offset, LEErrorCode &success) {
|
||||
if(hasBounds()) {
|
||||
if(offset > fLength) {
|
||||
LE_DEBUG_TR("addOffset off end");
|
||||
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
return;
|
||||
} else {
|
||||
fLength -= offset;
|
||||
}
|
||||
}
|
||||
fStart += offset;
|
||||
}
|
||||
|
||||
size_t ptrToOffset(const void *atPtr, LEErrorCode &success) const {
|
||||
if(atPtr==NULL) return 0;
|
||||
if(LE_FAILURE(success)) return LE_UINTPTR_MAX;
|
||||
if((atPtr < fStart) ||
|
||||
(hasBounds() && (atPtr > fStart+fLength))) {
|
||||
LE_DEBUG_TR3("ptrToOffset args out of range: %p", atPtr, 0);
|
||||
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
return LE_UINTPTR_MAX;
|
||||
}
|
||||
return ((const le_uint8*)atPtr)-fStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp down the length, for range checking.
|
||||
*/
|
||||
size_t contractLength(size_t newLength) {
|
||||
if(fLength!=LE_UINTPTR_MAX&&newLength>0&&newLength<=fLength) {
|
||||
fLength = newLength;
|
||||
}
|
||||
return fLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an error if offset+length off end
|
||||
*/
|
||||
public:
|
||||
size_t verifyLength(size_t offset, size_t length, LEErrorCode &success) {
|
||||
if(isValid()&&
|
||||
LE_SUCCESS(success) &&
|
||||
fLength!=LE_UINTPTR_MAX && length!=LE_UINTPTR_MAX && offset!=LE_UINTPTR_MAX &&
|
||||
(offset+length)>fLength) {
|
||||
LE_DEBUG_TR3("verifyLength failed (%p) %d",NULL, offset+length);
|
||||
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
#if LE_ASSERT_BAD_FONT
|
||||
fprintf(stderr, "offset=%lu, len=%lu, would be at %p, (%lu) off end. End at %p\n", offset,length, fStart+offset+length, (offset+length-fLength), (offset+length-fLength)+fStart);
|
||||
#endif
|
||||
}
|
||||
return fLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change parent link to another
|
||||
*/
|
||||
LETableReference &reparent(const LETableReference &base) {
|
||||
fParent = &base;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove parent link. Factory functions should do this.
|
||||
*/
|
||||
void orphan(void) {
|
||||
fParent=NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
const LEFontInstance* fFont;
|
||||
LETag fTag;
|
||||
const LETableReference *fParent;
|
||||
const le_uint8 *fStart; // keep as 8 bit internally, for pointer math
|
||||
size_t fLength;
|
||||
|
||||
void loadTable(LEErrorCode &success) {
|
||||
if(LE_SUCCESS(success)) {
|
||||
fStart = (const le_uint8*)(fFont->getFontTable(fTag, fLength)); // note - a null table is not an error.
|
||||
}
|
||||
}
|
||||
|
||||
void setRaw(const void *data, size_t length = LE_UINTPTR_MAX) {
|
||||
fFont = NULL;
|
||||
fTag = kQuestionmarkTableTag;
|
||||
fParent = NULL;
|
||||
fStart = (const le_uint8*)data;
|
||||
fLength = length;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
class LETableVarSizer {
|
||||
public:
|
||||
inline static size_t getSize();
|
||||
};
|
||||
|
||||
// base definition- could override for adjustments
|
||||
template<class T> inline
|
||||
size_t LETableVarSizer<T>::getSize() {
|
||||
return sizeof(T);
|
||||
}
|
||||
|
||||
/**
|
||||
* \def LE_VAR_ARRAY
|
||||
* @param x Type (T)
|
||||
* @param y some member that is of length ANY_NUMBER
|
||||
* Call this after defining a class, for example:
|
||||
* LE_VAR_ARRAY(FeatureListTable,featureRecordArray)
|
||||
* this is roughly equivalent to:
|
||||
* template<> inline size_t LETableVarSizer<FeatureListTable>::getSize() { return sizeof(FeatureListTable) - (sizeof(le_uint16)*ANY_NUMBER); }
|
||||
* it's a specialization that informs the LETableReference subclasses to NOT include the variable array in the size.
|
||||
* dereferencing NULL is valid here because we never actually dereference it, just inside sizeof.
|
||||
*/
|
||||
#define LE_VAR_ARRAY(x,y) template<> inline size_t LETableVarSizer<x>::getSize() { return sizeof(x) - (sizeof(((const x*)0)->y)); }
|
||||
/**
|
||||
* \def LE_CORRECT_SIZE
|
||||
* @param x type (T)
|
||||
* @param y fixed size for T
|
||||
*/
|
||||
#define LE_CORRECT_SIZE(x,y) template<> inline size_t LETableVarSizer<x>::getSize() { return y; }
|
||||
|
||||
/**
|
||||
* Open a new entry based on an existing table
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def LE_UNBOUNDED_ARRAY
|
||||
* define an array with no *known* bound. Will trim to available size.
|
||||
* @internal
|
||||
*/
|
||||
#define LE_UNBOUNDED_ARRAY LE_UINT32_MAX
|
||||
|
||||
template<class T>
|
||||
class LEReferenceToArrayOf : public LETableReference {
|
||||
public:
|
||||
LEReferenceToArrayOf(const LETableReference &parent, LEErrorCode &success, size_t offset, le_uint32 count)
|
||||
: LETableReference(parent, offset, LE_UINTPTR_MAX, success), fCount(count) {
|
||||
LE_TRACE_TR("INFO: new RTAO by offset")
|
||||
if(LE_SUCCESS(success)) {
|
||||
if(count == LE_UNBOUNDED_ARRAY) { // not a known length
|
||||
count = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
|
||||
}
|
||||
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*count, success);
|
||||
}
|
||||
if(LE_FAILURE(success)) {
|
||||
fCount=0;
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
LEReferenceToArrayOf(const LETableReference &parent, LEErrorCode &success, const T* array, le_uint32 count)
|
||||
: LETableReference(parent, parent.ptrToOffset(array, success), LE_UINTPTR_MAX, success), fCount(count) {
|
||||
LE_TRACE_TR("INFO: new RTAO")
|
||||
if(LE_SUCCESS(success)) {
|
||||
if(count == LE_UNBOUNDED_ARRAY) { // not a known length
|
||||
count = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
|
||||
}
|
||||
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*count, success);
|
||||
}
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
LEReferenceToArrayOf(const LETableReference &parent, LEErrorCode &success, const T* array, size_t offset, le_uint32 count)
|
||||
: LETableReference(parent, parent.ptrToOffset(array, success)+offset, LE_UINTPTR_MAX, success), fCount(count) {
|
||||
LE_TRACE_TR("INFO: new RTAO")
|
||||
if(LE_SUCCESS(success)) {
|
||||
if(count == LE_UNBOUNDED_ARRAY) { // not a known length
|
||||
count = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
|
||||
}
|
||||
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*count, success);
|
||||
}
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
|
||||
LEReferenceToArrayOf() :LETableReference(), fCount(0) {}
|
||||
|
||||
le_uint32 getCount() const { return fCount; }
|
||||
|
||||
using LETableReference::getAlias;
|
||||
|
||||
const T *getAlias(le_uint32 i, LEErrorCode &success) const {
|
||||
return ((const T*)(((const char*)getAlias())+getOffsetFor(i, success)));
|
||||
}
|
||||
|
||||
const T *getAliasRAW() const { LE_DEBUG_TR("getAliasRAW<>"); return (const T*)fStart; }
|
||||
|
||||
const T& getObject(le_uint32 i, LEErrorCode &success) const {
|
||||
return *getAlias(i,success);
|
||||
}
|
||||
|
||||
const T& operator()(le_uint32 i, LEErrorCode &success) const {
|
||||
return *getAlias(i,success);
|
||||
}
|
||||
|
||||
size_t getOffsetFor(le_uint32 i, LEErrorCode &success) const {
|
||||
if(LE_SUCCESS(success)&&i<getCount()) {
|
||||
return LETableVarSizer<T>::getSize()*i;
|
||||
} else {
|
||||
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LEReferenceToArrayOf<T> &reparent(const LETableReference &base) {
|
||||
fParent = &base;
|
||||
return *this;
|
||||
}
|
||||
|
||||
LEReferenceToArrayOf(const LETableReference& parent, LEErrorCode & success) : LETableReference(parent,0, LE_UINTPTR_MAX, success), fCount(0) {
|
||||
LE_TRACE_TR("INFO: null RTAO")
|
||||
}
|
||||
|
||||
private:
|
||||
le_uint32 fCount;
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
class LEReferenceTo : public LETableReference {
|
||||
public:
|
||||
/**
|
||||
* open a sub reference.
|
||||
* @param parent parent reference
|
||||
* @param success error status
|
||||
* @param atPtr location of reference - if NULL, will be at offset zero (i.e. downcast of parent). Otherwise must be a pointer within parent's bounds.
|
||||
*/
|
||||
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr)
|
||||
: LETableReference(parent, parent.ptrToOffset(atPtr, success), LE_UINTPTR_MAX, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
/**
|
||||
* ptr plus offset
|
||||
*/
|
||||
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr, size_t offset)
|
||||
: LETableReference(parent, parent.ptrToOffset(atPtr, success)+offset, LE_UINTPTR_MAX, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, size_t offset)
|
||||
: LETableReference(parent, offset, LE_UINTPTR_MAX, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success)
|
||||
: LETableReference(parent, 0, LE_UINTPTR_MAX, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
inline LEReferenceTo(const LEFontInstance *font, LETag tableTag, LEErrorCode &success)
|
||||
: LETableReference(font, tableTag, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
inline LEReferenceTo(const le_uint8 *data, size_t length = LE_UINTPTR_MAX) : LETableReference(data, length) {}
|
||||
inline LEReferenceTo(const T *data, size_t length = LE_UINTPTR_MAX) : LETableReference((const le_uint8*)data, length) {}
|
||||
inline LEReferenceTo() : LETableReference(NULL) {}
|
||||
|
||||
inline LEReferenceTo<T>& operator=(const T* other) {
|
||||
setRaw(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
LEReferenceTo<T> &reparent(const LETableReference &base) {
|
||||
fParent = &base;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* roll forward by one <T> size.
|
||||
* same as addOffset(LETableVarSizer<T>::getSize(),success)
|
||||
*/
|
||||
void addObject(LEErrorCode &success) {
|
||||
addOffset(LETableVarSizer<T>::getSize(), success);
|
||||
}
|
||||
void addObject(size_t count, LEErrorCode &success) {
|
||||
addOffset(LETableVarSizer<T>::getSize()*count, success);
|
||||
}
|
||||
|
||||
const T *operator->() const { return getAlias(); }
|
||||
const T *getAlias() const { return (const T*)fStart; }
|
||||
const T *getAliasRAW() const { LE_DEBUG_TR("getAliasRAW<>"); return (const T*)fStart; }
|
||||
};
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
728
project/jni/icuuc/include/layout/LETypes.h
Normal file
728
project/jni/icuuc/include/layout/LETypes.h
Normal file
@@ -0,0 +1,728 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LETYPES_H
|
||||
#define __LETYPES_H
|
||||
|
||||
#if !defined(LE_USE_CMEMORY) && (defined(U_LAYOUT_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION) || defined(U_STATIC_IMPLEMENTATION) || defined(U_COMBINED_IMPLEMENTATION))
|
||||
#define LE_USE_CMEMORY
|
||||
#endif
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "unicode/uobject.h"
|
||||
#endif
|
||||
|
||||
#ifdef LE_USE_CMEMORY
|
||||
#include "cmemory.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \brief C API: Basic definitions for the ICU LayoutEngine
|
||||
*/
|
||||
|
||||
/**
|
||||
* A type used for signed, 32-bit integers.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef int32_t le_int32;
|
||||
|
||||
/**
|
||||
* A type used for unsigned, 32-bit integers.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef uint32_t le_uint32;
|
||||
|
||||
/**
|
||||
* A type used for signed, 16-bit integers.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef int16_t le_int16;
|
||||
|
||||
/**
|
||||
* A type used for unsigned, 16-bit integers.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef uint16_t le_uint16;
|
||||
|
||||
/**
|
||||
* A type used for signed, 8-bit integers.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef int8_t le_int8;
|
||||
|
||||
/**
|
||||
* A type used for unsigned, 8-bit integers.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef uint8_t le_uint8;
|
||||
|
||||
|
||||
/**
|
||||
* A type used for boolean values.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef UBool le_bool;
|
||||
|
||||
#ifndef NULL
|
||||
/**
|
||||
* Used to represent empty pointers.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Used for four character tags.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef le_uint32 LETag;
|
||||
|
||||
/**
|
||||
* Used for 16-bit glyph indices as they're represented
|
||||
* in TrueType font tables.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
typedef le_uint16 TTGlyphID;
|
||||
|
||||
/**
|
||||
* Used for glyph indices. The low-order 16 bits are
|
||||
* the glyph ID within the font. The next 8 bits are
|
||||
* the sub-font ID within a compound font. The high-
|
||||
* order 8 bits are client defined. The LayoutEngine
|
||||
* will never change or look at the client defined bits.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
typedef le_uint32 LEGlyphID;
|
||||
|
||||
/**
|
||||
* Used to mask off the glyph ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_GLYPH_MASK 0x0000FFFF
|
||||
|
||||
/**
|
||||
* Used to shift the glyph ID part of an LEGlyphID
|
||||
* into the low-order bits.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_GLYPH_SHIFT 0
|
||||
|
||||
|
||||
/**
|
||||
* Used to mask off the sub-font ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_SUB_FONT_MASK 0x00FF0000
|
||||
|
||||
/**
|
||||
* Used to shift the sub-font ID part of an LEGlyphID
|
||||
* into the low-order bits.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_SUB_FONT_SHIFT 16
|
||||
|
||||
|
||||
/**
|
||||
* Used to mask off the client-defined part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_CLIENT_MASK 0xFF000000
|
||||
|
||||
/**
|
||||
* Used to shift the sub-font ID part of an LEGlyphID
|
||||
* into the low-order bits.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_CLIENT_SHIFT 24
|
||||
|
||||
|
||||
/**
|
||||
* A convenience macro to get the Glyph ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_GET_GLYPH(gid) ((gid & LE_GLYPH_MASK) >> LE_GLYPH_SHIFT)
|
||||
|
||||
/**
|
||||
* A convenience macro to get the sub-font ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_GET_SUB_FONT(gid) ((gid & LE_SUB_FONT_MASK) >> LE_SUB_FONT_SHIFT)
|
||||
|
||||
/**
|
||||
* A convenience macro to get the client-defined part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_GET_CLIENT(gid) ((gid & LE_CLIENT_MASK) >> LE_CLIENT_SHIFT)
|
||||
|
||||
|
||||
/**
|
||||
* A convenience macro to set the Glyph ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_SET_GLYPH(gid, glyph) ((gid & ~LE_GLYPH_MASK) | ((glyph << LE_GLYPH_SHIFT) & LE_GLYPH_MASK))
|
||||
|
||||
/**
|
||||
* A convenience macro to set the sub-font ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_SET_SUB_FONT(gid, font) ((gid & ~LE_SUB_FONT_MASK) | ((font << LE_SUB_FONT_SHIFT) & LE_SUB_FONT_MASK))
|
||||
|
||||
/**
|
||||
* A convenience macro to set the client-defined part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_SET_CLIENT(gid, client) ((gid & ~LE_CLIENT_MASK) | ((client << LE_CLIENT_SHIFT) & LE_CLIENT_MASK))
|
||||
|
||||
|
||||
/**
|
||||
* Used to represent 16-bit Unicode code points.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef UChar LEUnicode16;
|
||||
|
||||
/**
|
||||
* Used to represent 32-bit Unicode code points.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef UChar32 LEUnicode32;
|
||||
|
||||
#ifndef U_HIDE_DEPRECATED_API
|
||||
/**
|
||||
* Used to represent 16-bit Unicode code points.
|
||||
*
|
||||
* @deprecated since ICU 2.4. Use LEUnicode16 instead
|
||||
*/
|
||||
typedef UChar LEUnicode;
|
||||
#endif /* U_HIDE_DEPRECATED_API */
|
||||
|
||||
/**
|
||||
* Used to hold a pair of (x, y) values which represent a point.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
struct LEPoint
|
||||
{
|
||||
/**
|
||||
* The x coordinate of the point.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
float fX;
|
||||
|
||||
/**
|
||||
* The y coordinate of the point.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
float fY;
|
||||
};
|
||||
|
||||
#ifndef __cplusplus
|
||||
/**
|
||||
* Used to hold a pair of (x, y) values which represent a point.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef struct LEPoint LEPoint;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
|
||||
/**
|
||||
* \def
|
||||
* @internal
|
||||
*/
|
||||
#ifndef LE_ASSERT_BAD_FONT
|
||||
#define LE_ASSERT_BAD_FONT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def LE_DEBUG_BAD_FONT
|
||||
* @internal
|
||||
*/
|
||||
#if LE_ASSERT_BAD_FONT
|
||||
#include <stdio.h>
|
||||
#define LE_DEBUG_BAD_FONT(x) fprintf(stderr,"%s:%d: BAD FONT: %s\n", __FILE__, __LINE__, (x));
|
||||
#else
|
||||
#define LE_DEBUG_BAD_FONT(x)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def LE_UINTPTR_MAX
|
||||
* Max value representable by a uintptr
|
||||
*/
|
||||
|
||||
#ifndef UINT32_MAX
|
||||
#define LE_UINT32_MAX 0xFFFFFFFFU
|
||||
#else
|
||||
#define LE_UINT32_MAX UINT32_MAX
|
||||
#endif
|
||||
|
||||
#ifndef UINTPTR_MAX
|
||||
#define LE_UINTPTR_MAX LE_UINT32_MAX
|
||||
#else
|
||||
#define LE_UINTPTR_MAX UINTPTR_MAX
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Range check for overflow
|
||||
*/
|
||||
#define LE_RANGE_CHECK(type, count, ptrfn) (( (LE_UINTPTR_MAX / sizeof(type)) < (size_t)count ) ? NULL : (ptrfn))
|
||||
/**
|
||||
* A convenience macro to get the length of an array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_ARRAY_SIZE(array) (sizeof array / sizeof array[0])
|
||||
|
||||
#ifdef LE_USE_CMEMORY
|
||||
/**
|
||||
* A convenience macro for copying an array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_ARRAY_COPY(dst, src, count) uprv_memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
|
||||
|
||||
/**
|
||||
* Allocate an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_NEW_ARRAY(type, count) (type *) LE_RANGE_CHECK(type,count,uprv_malloc((count) * sizeof(type)))
|
||||
|
||||
/**
|
||||
* Re-allocate an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_GROW_ARRAY(array, newSize) uprv_realloc((void *) (array), (newSize) * sizeof (array)[0])
|
||||
|
||||
/**
|
||||
* Free an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_DELETE_ARRAY(array) uprv_free((void *) (array))
|
||||
#else
|
||||
|
||||
/* Not using ICU memory - use C std lib versions */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* A convenience macro to get the length of an array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_ARRAY_SIZE(array) (sizeof array / sizeof array[0])
|
||||
|
||||
/**
|
||||
* A convenience macro for copying an array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_ARRAY_COPY(dst, src, count) memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
|
||||
|
||||
/**
|
||||
* Allocate an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_NEW_ARRAY(type, count) LE_RANGE_CHECK(type,count,(type *) malloc((count) * sizeof(type)))
|
||||
|
||||
/**
|
||||
* Re-allocate an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_GROW_ARRAY(array, newSize) realloc((void *) (array), (newSize) * sizeof (array)[0])
|
||||
|
||||
/**
|
||||
* Free an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_DELETE_ARRAY(array) free((void *) (array))
|
||||
|
||||
#endif
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* A macro to construct the four-letter tags used to
|
||||
* label TrueType tables, and for script, language and
|
||||
* feature tags in OpenType tables.
|
||||
*
|
||||
* WARNING: THIS MACRO WILL ONLY WORK CORRECTLY IF
|
||||
* THE ARGUMENT CHARACTERS ARE ASCII.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define LE_MAKE_TAG(a, b, c, d) \
|
||||
(((le_uint32)(a) << 24) | \
|
||||
((le_uint32)(b) << 16) | \
|
||||
((le_uint32)(c) << 8) | \
|
||||
(le_uint32)(d))
|
||||
|
||||
/**
|
||||
* This enumeration defines constants for the standard
|
||||
* TrueType, OpenType and AAT table tags.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
enum LETableTags {
|
||||
LE_ACNT_TABLE_TAG = 0x61636E74UL, /**< 'acnt' */
|
||||
LE_AVAR_TABLE_TAG = 0x61766172UL, /**< 'avar' */
|
||||
LE_BASE_TABLE_TAG = 0x42415345UL, /**< 'BASE' */
|
||||
LE_BDAT_TABLE_TAG = 0x62646174UL, /**< 'bdat' */
|
||||
LE_BHED_TABLE_TAG = 0x62686564UL, /**< 'bhed' */
|
||||
LE_BLOC_TABLE_TAG = 0x626C6F63UL, /**< 'bloc' */
|
||||
LE_BSLN_TABLE_TAG = 0x62736C6EUL, /**< 'bsln' */
|
||||
LE_CFF__TABLE_TAG = 0x43464620UL, /**< 'CFF ' */
|
||||
LE_CMAP_TABLE_TAG = 0x636D6170UL, /**< 'cmap' */
|
||||
LE_CVAR_TABLE_TAG = 0x63766172UL, /**< 'cvar' */
|
||||
LE_CVT__TABLE_TAG = 0x63767420UL, /**< 'cvt ' */
|
||||
LE_DSIG_TABLE_TAG = 0x44534947UL, /**< 'DSIG' */
|
||||
LE_EBDT_TABLE_TAG = 0x45424454UL, /**< 'EBDT' */
|
||||
LE_EBLC_TABLE_TAG = 0x45424C43UL, /**< 'EBLC' */
|
||||
LE_EBSC_TABLE_TAG = 0x45425343UL, /**< 'EBSC' */
|
||||
LE_FDSC_TABLE_TAG = 0x66647363UL, /**< 'fdsc' */
|
||||
LE_FEAT_TABLE_TAG = 0x66656174UL, /**< 'feat' */
|
||||
LE_FMTX_TABLE_TAG = 0x666D7478UL, /**< 'fmtx' */
|
||||
LE_FPGM_TABLE_TAG = 0x6670676DUL, /**< 'fpgm' */
|
||||
LE_FVAR_TABLE_TAG = 0x66766172UL, /**< 'fvar' */
|
||||
LE_GASP_TABLE_TAG = 0x67617370UL, /**< 'gasp' */
|
||||
LE_GDEF_TABLE_TAG = 0x47444546UL, /**< 'GDEF' */
|
||||
LE_GLYF_TABLE_TAG = 0x676C7966UL, /**< 'glyf' */
|
||||
LE_GPOS_TABLE_TAG = 0x47504F53UL, /**< 'GPOS' */
|
||||
LE_GSUB_TABLE_TAG = 0x47535542UL, /**< 'GSUB' */
|
||||
LE_GVAR_TABLE_TAG = 0x67766172UL, /**< 'gvar' */
|
||||
LE_HDMX_TABLE_TAG = 0x68646D78UL, /**< 'hdmx' */
|
||||
LE_HEAD_TABLE_TAG = 0x68656164UL, /**< 'head' */
|
||||
LE_HHEA_TABLE_TAG = 0x68686561UL, /**< 'hhea' */
|
||||
LE_HMTX_TABLE_TAG = 0x686D7478UL, /**< 'hmtx' */
|
||||
LE_HSTY_TABLE_TAG = 0x68737479UL, /**< 'hsty' */
|
||||
LE_JUST_TABLE_TAG = 0x6A757374UL, /**< 'just' */
|
||||
LE_JSTF_TABLE_TAG = 0x4A535446UL, /**< 'JSTF' */
|
||||
LE_KERN_TABLE_TAG = 0x6B65726EUL, /**< 'kern' */
|
||||
LE_LCAR_TABLE_TAG = 0x6C636172UL, /**< 'lcar' */
|
||||
LE_LOCA_TABLE_TAG = 0x6C6F6361UL, /**< 'loca' */
|
||||
LE_LTSH_TABLE_TAG = 0x4C545348UL, /**< 'LTSH' */
|
||||
LE_MAXP_TABLE_TAG = 0x6D617870UL, /**< 'maxp' */
|
||||
LE_MORT_TABLE_TAG = 0x6D6F7274UL, /**< 'mort' */
|
||||
LE_MORX_TABLE_TAG = 0x6D6F7278UL, /**< 'morx' */
|
||||
LE_NAME_TABLE_TAG = 0x6E616D65UL, /**< 'name' */
|
||||
LE_OPBD_TABLE_TAG = 0x6F706264UL, /**< 'opbd' */
|
||||
LE_OS_2_TABLE_TAG = 0x4F532F32UL, /**< 'OS/2' */
|
||||
LE_PCLT_TABLE_TAG = 0x50434C54UL, /**< 'PCLT' */
|
||||
LE_POST_TABLE_TAG = 0x706F7374UL, /**< 'post' */
|
||||
LE_PREP_TABLE_TAG = 0x70726570UL, /**< 'prep' */
|
||||
LE_PROP_TABLE_TAG = 0x70726F70UL, /**< 'prop' */
|
||||
LE_TRAK_TABLE_TAG = 0x7472616BUL, /**< 'trak' */
|
||||
LE_VDMX_TABLE_TAG = 0x56444D58UL, /**< 'VDMX' */
|
||||
LE_VHEA_TABLE_TAG = 0x76686561UL, /**< 'vhea' */
|
||||
LE_VMTX_TABLE_TAG = 0x766D7478UL, /**< 'vmtx' */
|
||||
LE_VORG_TABLE_TAG = 0x564F5247UL, /**< 'VORG' */
|
||||
LE_ZAPF_TABLE_TAG = 0x5A617066UL /**< 'Zapf' */
|
||||
};
|
||||
|
||||
/**
|
||||
* This enumeration defines constants for all
|
||||
* the common OpenType feature tags.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
enum LEFeatureTags {
|
||||
LE_AALT_FEATURE_TAG = 0x61616C74UL, /**< 'aalt' */
|
||||
LE_ABVF_FEATURE_TAG = 0x61627666UL, /**< 'abvf' */
|
||||
LE_ABVM_FEATURE_TAG = 0x6162766DUL, /**< 'abvm' */
|
||||
LE_ABVS_FEATURE_TAG = 0x61627673UL, /**< 'abvs' */
|
||||
LE_AFRC_FEATURE_TAG = 0x61667263UL, /**< 'afrc' */
|
||||
LE_AKHN_FEATURE_TAG = 0x616B686EUL, /**< 'akhn' */
|
||||
LE_BLWF_FEATURE_TAG = 0x626C7766UL, /**< 'blwf' */
|
||||
LE_BLWM_FEATURE_TAG = 0x626C776DUL, /**< 'blwm' */
|
||||
LE_BLWS_FEATURE_TAG = 0x626C7773UL, /**< 'blws' */
|
||||
LE_CALT_FEATURE_TAG = 0x63616C74UL, /**< 'calt' */
|
||||
LE_CASE_FEATURE_TAG = 0x63617365UL, /**< 'case' */
|
||||
LE_CCMP_FEATURE_TAG = 0x63636D70UL, /**< 'ccmp' */
|
||||
LE_CJCT_FEATURE_TAG = 0x636A6374UL, /**< 'cjct' */
|
||||
LE_CLIG_FEATURE_TAG = 0x636C6967UL, /**< 'clig' */
|
||||
LE_CPSP_FEATURE_TAG = 0x63707370UL, /**< 'cpsp' */
|
||||
LE_CSWH_FEATURE_TAG = 0x63737768UL, /**< 'cswh' */
|
||||
LE_CURS_FEATURE_TAG = 0x63757273UL, /**< 'curs' */
|
||||
LE_C2SC_FEATURE_TAG = 0x63327363UL, /**< 'c2sc' */
|
||||
LE_C2PC_FEATURE_TAG = 0x63327063UL, /**< 'c2pc' */
|
||||
LE_DIST_FEATURE_TAG = 0x64697374UL, /**< 'dist' */
|
||||
LE_DLIG_FEATURE_TAG = 0x646C6967UL, /**< 'dlig' */
|
||||
LE_DNOM_FEATURE_TAG = 0x646E6F6DUL, /**< 'dnom' */
|
||||
LE_EXPT_FEATURE_TAG = 0x65787074UL, /**< 'expt' */
|
||||
LE_FALT_FEATURE_TAG = 0x66616C74UL, /**< 'falt' */
|
||||
LE_FIN2_FEATURE_TAG = 0x66696E32UL, /**< 'fin2' */
|
||||
LE_FIN3_FEATURE_TAG = 0x66696E33UL, /**< 'fin3' */
|
||||
LE_FINA_FEATURE_TAG = 0x66696E61UL, /**< 'fina' */
|
||||
LE_FRAC_FEATURE_TAG = 0x66726163UL, /**< 'frac' */
|
||||
LE_FWID_FEATURE_TAG = 0x66776964UL, /**< 'fwid' */
|
||||
LE_HALF_FEATURE_TAG = 0x68616C66UL, /**< 'half' */
|
||||
LE_HALN_FEATURE_TAG = 0x68616C6EUL, /**< 'haln' */
|
||||
LE_HALT_FEATURE_TAG = 0x68616C74UL, /**< 'halt' */
|
||||
LE_HIST_FEATURE_TAG = 0x68697374UL, /**< 'hist' */
|
||||
LE_HKNA_FEATURE_TAG = 0x686B6E61UL, /**< 'hkna' */
|
||||
LE_HLIG_FEATURE_TAG = 0x686C6967UL, /**< 'hlig' */
|
||||
LE_HNGL_FEATURE_TAG = 0x686E676CUL, /**< 'hngl' */
|
||||
LE_HWID_FEATURE_TAG = 0x68776964UL, /**< 'hwid' */
|
||||
LE_INIT_FEATURE_TAG = 0x696E6974UL, /**< 'init' */
|
||||
LE_ISOL_FEATURE_TAG = 0x69736F6CUL, /**< 'isol' */
|
||||
LE_ITAL_FEATURE_TAG = 0x6974616CUL, /**< 'ital' */
|
||||
LE_JALT_FEATURE_TAG = 0x6A616C74UL, /**< 'jalt' */
|
||||
LE_JP78_FEATURE_TAG = 0x6A703738UL, /**< 'jp78' */
|
||||
LE_JP83_FEATURE_TAG = 0x6A703833UL, /**< 'jp83' */
|
||||
LE_JP90_FEATURE_TAG = 0x6A703930UL, /**< 'jp90' */
|
||||
LE_KERN_FEATURE_TAG = 0x6B65726EUL, /**< 'kern' */
|
||||
LE_LFBD_FEATURE_TAG = 0x6C666264UL, /**< 'lfbd' */
|
||||
LE_LIGA_FEATURE_TAG = 0x6C696761UL, /**< 'liga' */
|
||||
LE_LJMO_FEATURE_TAG = 0x6C6A6D6FUL, /**< 'ljmo' */
|
||||
LE_LNUM_FEATURE_TAG = 0x6C6E756DUL, /**< 'lnum' */
|
||||
LE_LOCL_FEATURE_TAG = 0x6C6F636CUL, /**< 'locl' */
|
||||
LE_MARK_FEATURE_TAG = 0x6D61726BUL, /**< 'mark' */
|
||||
LE_MED2_FEATURE_TAG = 0x6D656432UL, /**< 'med2' */
|
||||
LE_MEDI_FEATURE_TAG = 0x6D656469UL, /**< 'medi' */
|
||||
LE_MGRK_FEATURE_TAG = 0x6D67726BUL, /**< 'mgrk' */
|
||||
LE_MKMK_FEATURE_TAG = 0x6D6B6D6BUL, /**< 'mkmk' */
|
||||
LE_MSET_FEATURE_TAG = 0x6D736574UL, /**< 'mset' */
|
||||
LE_NALT_FEATURE_TAG = 0x6E616C74UL, /**< 'nalt' */
|
||||
LE_NLCK_FEATURE_TAG = 0x6E6C636BUL, /**< 'nlck' */
|
||||
LE_NUKT_FEATURE_TAG = 0x6E756B74UL, /**< 'nukt' */
|
||||
LE_NUMR_FEATURE_TAG = 0x6E756D72UL, /**< 'numr' */
|
||||
LE_ONUM_FEATURE_TAG = 0x6F6E756DUL, /**< 'onum' */
|
||||
LE_OPBD_FEATURE_TAG = 0x6F706264UL, /**< 'opbd' */
|
||||
LE_ORDN_FEATURE_TAG = 0x6F72646EUL, /**< 'ordn' */
|
||||
LE_ORNM_FEATURE_TAG = 0x6F726E6DUL, /**< 'ornm' */
|
||||
LE_PALT_FEATURE_TAG = 0x70616C74UL, /**< 'palt' */
|
||||
LE_PCAP_FEATURE_TAG = 0x70636170UL, /**< 'pcap' */
|
||||
LE_PNUM_FEATURE_TAG = 0x706E756DUL, /**< 'pnum' */
|
||||
LE_PREF_FEATURE_TAG = 0x70726566UL, /**< 'pref' */
|
||||
LE_PRES_FEATURE_TAG = 0x70726573UL, /**< 'pres' */
|
||||
LE_PSTF_FEATURE_TAG = 0x70737466UL, /**< 'pstf' */
|
||||
LE_PSTS_FEATURE_TAG = 0x70737473UL, /**< 'psts' */
|
||||
LE_PWID_FEATURE_TAG = 0x70776964UL, /**< 'pwid' */
|
||||
LE_QWID_FEATURE_TAG = 0x71776964UL, /**< 'qwid' */
|
||||
LE_RAND_FEATURE_TAG = 0x72616E64UL, /**< 'rand' */
|
||||
LE_RLIG_FEATURE_TAG = 0x726C6967UL, /**< 'rlig' */
|
||||
LE_RPHF_FEATURE_TAG = 0x72706866UL, /**< 'rphf' */
|
||||
LE_RKRF_FEATURE_TAG = 0x726B7266UL, /**< 'rkrf' */
|
||||
LE_RTBD_FEATURE_TAG = 0x72746264UL, /**< 'rtbd' */
|
||||
LE_RTLA_FEATURE_TAG = 0x72746C61UL, /**< 'rtla' */
|
||||
LE_RUBY_FEATURE_TAG = 0x72756279UL, /**< 'ruby' */
|
||||
LE_SALT_FEATURE_TAG = 0x73616C74UL, /**< 'salt' */
|
||||
LE_SINF_FEATURE_TAG = 0x73696E66UL, /**< 'sinf' */
|
||||
LE_SIZE_FEATURE_TAG = 0x73697A65UL, /**< 'size' */
|
||||
LE_SMCP_FEATURE_TAG = 0x736D6370UL, /**< 'smcp' */
|
||||
LE_SMPL_FEATURE_TAG = 0x736D706CUL, /**< 'smpl' */
|
||||
LE_SS01_FEATURE_TAG = 0x73733031UL, /**< 'ss01' */
|
||||
LE_SS02_FEATURE_TAG = 0x73733032UL, /**< 'ss02' */
|
||||
LE_SS03_FEATURE_TAG = 0x73733033UL, /**< 'ss03' */
|
||||
LE_SS04_FEATURE_TAG = 0x73733034UL, /**< 'ss04' */
|
||||
LE_SS05_FEATURE_TAG = 0x73733035UL, /**< 'ss05' */
|
||||
LE_SS06_FEATURE_TAG = 0x73733036UL, /**< 'ss06' */
|
||||
LE_SS07_FEATURE_TAG = 0x73733037UL, /**< 'ss07' */
|
||||
LE_SS08_FEATURE_TAG = 0x73733038UL, /**< 'ss08' */
|
||||
LE_SS09_FEATURE_TAG = 0x73733039UL, /**< 'ss09' */
|
||||
LE_SS10_FEATURE_TAG = 0x73733130UL, /**< 'ss10' */
|
||||
LE_SS11_FEATURE_TAG = 0x73733131UL, /**< 'ss11' */
|
||||
LE_SS12_FEATURE_TAG = 0x73733132UL, /**< 'ss12' */
|
||||
LE_SS13_FEATURE_TAG = 0x73733133UL, /**< 'ss13' */
|
||||
LE_SS14_FEATURE_TAG = 0x73733134UL, /**< 'ss14' */
|
||||
LE_SS15_FEATURE_TAG = 0x73733135UL, /**< 'ss15' */
|
||||
LE_SS16_FEATURE_TAG = 0x73733136UL, /**< 'ss16' */
|
||||
LE_SS17_FEATURE_TAG = 0x73733137UL, /**< 'ss17' */
|
||||
LE_SS18_FEATURE_TAG = 0x73733138UL, /**< 'ss18' */
|
||||
LE_SS19_FEATURE_TAG = 0x73733139UL, /**< 'ss19' */
|
||||
LE_SS20_FEATURE_TAG = 0x73733230UL, /**< 'ss20' */
|
||||
LE_SUBS_FEATURE_TAG = 0x73756273UL, /**< 'subs' */
|
||||
LE_SUPS_FEATURE_TAG = 0x73757073UL, /**< 'sups' */
|
||||
LE_SWSH_FEATURE_TAG = 0x73777368UL, /**< 'swsh' */
|
||||
LE_TITL_FEATURE_TAG = 0x7469746CUL, /**< 'titl' */
|
||||
LE_TJMO_FEATURE_TAG = 0x746A6D6FUL, /**< 'tjmo' */
|
||||
LE_TNAM_FEATURE_TAG = 0x746E616DUL, /**< 'tnam' */
|
||||
LE_TNUM_FEATURE_TAG = 0x746E756DUL, /**< 'tnum' */
|
||||
LE_TRAD_FEATURE_TAG = 0x74726164UL, /**< 'trad' */
|
||||
LE_TWID_FEATURE_TAG = 0x74776964UL, /**< 'twid' */
|
||||
LE_UNIC_FEATURE_TAG = 0x756E6963UL, /**< 'unic' */
|
||||
LE_VALT_FEATURE_TAG = 0x76616C74UL, /**< 'valt' */
|
||||
LE_VATU_FEATURE_TAG = 0x76617475UL, /**< 'vatu' */
|
||||
LE_VERT_FEATURE_TAG = 0x76657274UL, /**< 'vert' */
|
||||
LE_VHAL_FEATURE_TAG = 0x7668616CUL, /**< 'vhal' */
|
||||
LE_VJMO_FEATURE_TAG = 0x766A6D6FUL, /**< 'vjmo' */
|
||||
LE_VKNA_FEATURE_TAG = 0x766B6E61UL, /**< 'vkna' */
|
||||
LE_VKRN_FEATURE_TAG = 0x766B726EUL, /**< 'vkrn' */
|
||||
LE_VPAL_FEATURE_TAG = 0x7670616CUL, /**< 'vpal' */
|
||||
LE_VRT2_FEATURE_TAG = 0x76727432UL, /**< 'vrt2' */
|
||||
LE_ZERO_FEATURE_TAG = 0x7A65726FUL /**< 'zero' */
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
enum LEFeatureENUMs {
|
||||
LE_Kerning_FEATURE_ENUM = 0, /**< Requests Kerning. Formerly LayoutEngine::kTypoFlagKern */
|
||||
LE_Ligatures_FEATURE_ENUM = 1, /**< Requests Ligatures. Formerly LayoutEngine::kTypoFlagLiga */
|
||||
LE_CLIG_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_DLIG_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_HLIG_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_LIGA_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_RLIG_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SMCP_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_FRAC_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_AFRC_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_ZERO_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SWSH_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_CSWH_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SALT_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_NALT_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_RUBY_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS01_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS02_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS03_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS04_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS05_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS06_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS07_FEATURE_ENUM, /**< Feature specific enum */
|
||||
|
||||
LE_CHAR_FILTER_FEATURE_ENUM = 31, /**< Apply CharSubstitutionFilter */
|
||||
LE_FEATURE_ENUM_MAX = LE_CHAR_FILTER_FEATURE_ENUM
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Flags for typographic features.
|
||||
* @internal
|
||||
* @{
|
||||
*/
|
||||
#define LE_Kerning_FEATURE_FLAG (1 << LE_Kerning_FEATURE_ENUM)
|
||||
#define LE_Ligatures_FEATURE_FLAG (1 << LE_Ligatures_FEATURE_ENUM)
|
||||
#define LE_CLIG_FEATURE_FLAG (1 << LE_CLIG_FEATURE_ENUM)
|
||||
#define LE_DLIG_FEATURE_FLAG (1 << LE_DLIG_FEATURE_ENUM)
|
||||
#define LE_HLIG_FEATURE_FLAG (1 << LE_HLIG_FEATURE_ENUM)
|
||||
#define LE_LIGA_FEATURE_FLAG (1 << LE_LIGA_FEATURE_ENUM)
|
||||
#define LE_RLIG_FEATURE_FLAG (1 << LE_RLIG_FEATURE_ENUM)
|
||||
#define LE_SMCP_FEATURE_FLAG (1 << LE_SMCP_FEATURE_ENUM)
|
||||
#define LE_FRAC_FEATURE_FLAG (1 << LE_FRAC_FEATURE_ENUM)
|
||||
#define LE_AFRC_FEATURE_FLAG (1 << LE_AFRC_FEATURE_ENUM)
|
||||
#define LE_ZERO_FEATURE_FLAG (1 << LE_ZERO_FEATURE_ENUM)
|
||||
#define LE_SWSH_FEATURE_FLAG (1 << LE_SWSH_FEATURE_ENUM)
|
||||
#define LE_CSWH_FEATURE_FLAG (1 << LE_CSWH_FEATURE_ENUM)
|
||||
#define LE_SALT_FEATURE_FLAG (1 << LE_SALT_FEATURE_ENUM)
|
||||
#define LE_NALT_FEATURE_FLAG (1 << LE_NALT_FEATURE_ENUM)
|
||||
#define LE_RUBY_FEATURE_FLAG (1 << LE_RUBY_FEATURE_ENUM)
|
||||
#define LE_SS01_FEATURE_FLAG (1 << LE_SS01_FEATURE_ENUM)
|
||||
#define LE_SS02_FEATURE_FLAG (1 << LE_SS02_FEATURE_ENUM)
|
||||
#define LE_SS03_FEATURE_FLAG (1 << LE_SS03_FEATURE_ENUM)
|
||||
#define LE_SS04_FEATURE_FLAG (1 << LE_SS04_FEATURE_ENUM)
|
||||
#define LE_SS05_FEATURE_FLAG (1 << LE_SS05_FEATURE_ENUM)
|
||||
#define LE_SS06_FEATURE_FLAG (1 << LE_SS06_FEATURE_ENUM)
|
||||
#define LE_SS07_FEATURE_FLAG (1 << LE_SS07_FEATURE_ENUM)
|
||||
|
||||
#define LE_CHAR_FILTER_FEATURE_FLAG (1 << LE_CHAR_FILTER_FEATURE_ENUM)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define LE_DEFAULT_FEATURE_FLAG (LE_Kerning_FEATURE_FLAG | LE_Ligatures_FEATURE_FLAG) /**< default features */
|
||||
|
||||
/**
|
||||
* Error codes returned by the LayoutEngine.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
enum LEErrorCode {
|
||||
/* informational */
|
||||
LE_NO_SUBFONT_WARNING = U_USING_DEFAULT_WARNING, /**< The font does not contain subfonts. */
|
||||
|
||||
/* success */
|
||||
LE_NO_ERROR = U_ZERO_ERROR, /**< No error, no warning. */
|
||||
|
||||
/* failures */
|
||||
LE_ILLEGAL_ARGUMENT_ERROR = U_ILLEGAL_ARGUMENT_ERROR, /**< An illegal argument was detected. */
|
||||
LE_MEMORY_ALLOCATION_ERROR = U_MEMORY_ALLOCATION_ERROR, /**< Memory allocation error. */
|
||||
LE_INDEX_OUT_OF_BOUNDS_ERROR = U_INDEX_OUTOFBOUNDS_ERROR, /**< Trying to access an index that is out of bounds. */
|
||||
LE_NO_LAYOUT_ERROR = U_UNSUPPORTED_ERROR, /**< You must call layoutChars() first. */
|
||||
LE_INTERNAL_ERROR = U_INTERNAL_PROGRAM_ERROR, /**< An internal error was encountered. */
|
||||
LE_FONT_FILE_NOT_FOUND_ERROR = U_FILE_ACCESS_ERROR, /**< The requested font file cannot be opened. */
|
||||
LE_MISSING_FONT_TABLE_ERROR = U_MISSING_RESOURCE_ERROR /**< The requested font table does not exist. */
|
||||
};
|
||||
|
||||
#ifndef __cplusplus
|
||||
/**
|
||||
* Error codes returned by the LayoutEngine.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
typedef enum LEErrorCode LEErrorCode;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A convenience macro to test for the success of a LayoutEngine call.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
#define LE_SUCCESS(code) (U_SUCCESS((UErrorCode)code))
|
||||
|
||||
/**
|
||||
* A convenience macro to test for the failure of a LayoutEngine call.
|
||||
*
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
#define LE_FAILURE(code) (U_FAILURE((UErrorCode)code))
|
||||
|
||||
|
||||
#endif
|
||||
511
project/jni/icuuc/include/layout/LayoutEngine.h
Normal file
511
project/jni/icuuc/include/layout/LayoutEngine.h
Normal file
@@ -0,0 +1,511 @@
|
||||
/*
|
||||
* (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
|
||||
*/
|
||||
|
||||
#ifndef __LAYOUTENGINE_H
|
||||
#define __LAYOUTENGINE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Virtual base class for complex text layout.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class LEFontInstance;
|
||||
class LEGlyphFilter;
|
||||
class LEGlyphStorage;
|
||||
|
||||
/**
|
||||
* This is a virtual base class used to do complex text layout. The text must all
|
||||
* be in a single font, script, and language. An instance of a LayoutEngine can be
|
||||
* created by calling the layoutEngineFactory method. Fonts are identified by
|
||||
* instances of the LEFontInstance class. Script and language codes are identified
|
||||
* by integer codes, which are defined in ScriptAndLanuageTags.h.
|
||||
*
|
||||
* Note that this class is not public API. It is declared public so that it can be
|
||||
* exported from the library that it is a part of.
|
||||
*
|
||||
* The input to the layout process is an array of characters in logical order,
|
||||
* and a starting X, Y position for the text. The output is an array of glyph indices,
|
||||
* an array of character indices for the glyphs, and an array of glyph positions.
|
||||
* These arrays are protected members of LayoutEngine which can be retreived by a
|
||||
* public method. The reset method can be called to free these arrays so that the
|
||||
* LayoutEngine can be reused.
|
||||
*
|
||||
* The layout process is done in three steps. There is a protected virtual method
|
||||
* for each step. These methods have a default implementation which only does
|
||||
* character to glyph mapping and default positioning using the glyph's advance
|
||||
* widths. Subclasses can override these methods for more advanced layout.
|
||||
* There is a public method which invokes the steps in the correct order.
|
||||
*
|
||||
* The steps are:
|
||||
*
|
||||
* 1) Glyph processing - character to glyph mapping and any other glyph processing
|
||||
* such as ligature substitution and contextual forms.
|
||||
*
|
||||
* 2) Glyph positioning - position the glyphs based on their advance widths.
|
||||
*
|
||||
* 3) Glyph position adjustments - adjustment of glyph positions for kerning,
|
||||
* accent placement, etc.
|
||||
*
|
||||
* NOTE: in all methods below, output parameters are references to pointers so
|
||||
* the method can allocate and free the storage as needed. All storage allocated
|
||||
* in this way is owned by the object which created it, and will be freed when it
|
||||
* is no longer needed, or when the object's destructor is invoked.
|
||||
*
|
||||
* @see LEFontInstance
|
||||
* @see ScriptAndLanguageTags.h
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
class U_LAYOUT_API LayoutEngine : public UObject {
|
||||
public:
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/** @internal Flag to request kerning. Use LE_Kerning_FEATURE_FLAG instead. */
|
||||
static const le_int32 kTypoFlagKern;
|
||||
/** @internal Flag to request ligatures. Use LE_Ligatures_FEATURE_FLAG instead. */
|
||||
static const le_int32 kTypoFlagLiga;
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The object which holds the glyph storage
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEGlyphStorage *fGlyphStorage;
|
||||
|
||||
/**
|
||||
* The font instance for the text font.
|
||||
*
|
||||
* @see LEFontInstance
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const LEFontInstance *fFontInstance;
|
||||
|
||||
/**
|
||||
* The script code for the text
|
||||
*
|
||||
* @see ScriptAndLanguageTags.h for script codes.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fScriptCode;
|
||||
|
||||
/**
|
||||
* The langauge code for the text
|
||||
*
|
||||
* @see ScriptAndLanguageTags.h for language codes.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fLanguageCode;
|
||||
|
||||
/**
|
||||
* The typographic control flags
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fTypoFlags;
|
||||
|
||||
/**
|
||||
* <code>TRUE</code> if <code>mapCharsToGlyphs</code> should replace ZWJ / ZWNJ with a glyph
|
||||
* with no contours.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_bool fFilterZeroWidth;
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* This constructs an instance for a given font, script and language. Subclass constructors
|
||||
* must call this constructor.
|
||||
*
|
||||
* @param fontInstance - the font for the text
|
||||
* @param scriptCode - the script for the text
|
||||
* @param languageCode - the language for the text
|
||||
* @param typoFlags - the typographic control flags for the text (a bitfield). Use kTypoFlagKern
|
||||
* if kerning is desired, kTypoFlagLiga if ligature formation is desired. Others are reserved.
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @see LEFontInstance
|
||||
* @see ScriptAndLanguageTags.h
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LayoutEngine(const LEFontInstance *fontInstance,
|
||||
le_int32 scriptCode,
|
||||
le_int32 languageCode,
|
||||
le_int32 typoFlags,
|
||||
LEErrorCode &success);
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
// Do not enclose the protected default constructor with #ifndef U_HIDE_INTERNAL_API
|
||||
// or else the compiler will create a public default constructor.
|
||||
/**
|
||||
* This overrides the default no argument constructor to make it
|
||||
* difficult for clients to call it. Clients are expected to call
|
||||
* layoutEngineFactory.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LayoutEngine();
|
||||
|
||||
/**
|
||||
* This method does any required pre-processing to the input characters. It
|
||||
* may generate output characters that differ from the input charcters due to
|
||||
* insertions, deletions, or reorderings. In such cases, it will also generate an
|
||||
* output character index array reflecting these changes.
|
||||
*
|
||||
* Subclasses must override this method.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param chars - the input character context
|
||||
* @param offset - the index of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param max - the number of characters in the input context
|
||||
* @param rightToLeft - TRUE if the characters are in a right to left directional run
|
||||
* @param outChars - the output character array, if different from the input
|
||||
* @param glyphStorage - the object that holds the per-glyph storage. The character index array may be set.
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @return the output character count (input character count if no change)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
|
||||
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method does the glyph processing. It converts an array of characters
|
||||
* into an array of glyph indices and character indices. The characters to be
|
||||
* processed are passed in a surrounding context. The context is specified as
|
||||
* a starting address and a maximum character count. An offset and a count are
|
||||
* used to specify the characters to be processed.
|
||||
*
|
||||
* The default implementation of this method only does character to glyph mapping.
|
||||
* Subclasses needing more elaborate glyph processing must override this method.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param chars - the character context
|
||||
* @param offset - the offset of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param max - the number of characters in the context.
|
||||
* @param rightToLeft - TRUE if the text is in a right to left directional run
|
||||
* @param glyphStorage - the object which holds the per-glyph storage. The glyph and char indices arrays
|
||||
* will be set.
|
||||
*
|
||||
* Output parameters:
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @return the number of glyphs in the glyph index array
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method does basic glyph positioning. The default implementation positions
|
||||
* the glyphs based on their advance widths. This is sufficient for most uses. It
|
||||
* is not expected that many subclasses will override this method.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param glyphStorage - the object which holds the per-glyph storage. The glyph position array will be set.
|
||||
* @param x - the starting X position
|
||||
* @param y - the starting Y position
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual void positionGlyphs(LEGlyphStorage &glyphStorage, float x, float y, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method does positioning adjustments like accent positioning and
|
||||
* kerning. The default implementation does nothing. Subclasses needing
|
||||
* position adjustments must override this method.
|
||||
*
|
||||
* Note that this method has both characters and glyphs as input so that
|
||||
* it can use the character codes to determine glyph types if that information
|
||||
* isn't directly available. (e.g. Some Arabic OpenType fonts don't have a GDEF
|
||||
* table)
|
||||
*
|
||||
* @param chars - the input character context
|
||||
* @param offset - the offset of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
|
||||
* @param glyphStorage - the object which holds the per-glyph storage. The glyph positions will be
|
||||
* adjusted as needed.
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method gets a table from the font associated with
|
||||
* the text. The default implementation gets the table from
|
||||
* the font instance. Subclasses which need to get the tables
|
||||
* some other way must override this method.
|
||||
*
|
||||
* @param tableTag - the four byte table tag.
|
||||
* @param length - length to use
|
||||
*
|
||||
* @return the address of the table.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual const void *getFontTable(LETag tableTag, size_t &length) const;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
virtual const void *getFontTable(LETag tableTag) const { size_t ignored; return getFontTable(tableTag, ignored); }
|
||||
|
||||
/**
|
||||
* This method does character to glyph mapping. The default implementation
|
||||
* uses the font instance to do the mapping. It will allocate the glyph and
|
||||
* character index arrays if they're not already allocated. If it allocates the
|
||||
* character index array, it will fill it it.
|
||||
*
|
||||
* This method supports right to left
|
||||
* text with the ability to store the glyphs in reverse order, and by supporting
|
||||
* character mirroring, which will replace a character which has a left and right
|
||||
* form, such as parens, with the opposite form before mapping it to a glyph index.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param chars - the input character context
|
||||
* @param offset - the offset of the first character to be mapped
|
||||
* @param count - the number of characters to be mapped
|
||||
* @param reverse - if <code>TRUE</code>, the output will be in reverse order
|
||||
* @param mirror - if <code>TRUE</code>, do character mirroring
|
||||
* @param glyphStorage - the object which holds the per-glyph storage. The glyph and char
|
||||
* indices arrays will be filled in.
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @see LEFontInstance
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* This is a convenience method that forces the advance width of mark
|
||||
* glyphs to be zero, which is required for proper selection and highlighting.
|
||||
*
|
||||
* @param glyphStorage - the object containing the per-glyph storage. The positions array will be modified.
|
||||
* @param markFilter - used to identify mark glyphs
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @see LEGlyphFilter
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static void adjustMarkGlyphs(LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success);
|
||||
|
||||
|
||||
/**
|
||||
* This is a convenience method that forces the advance width of mark
|
||||
* glyphs to be zero, which is required for proper selection and highlighting.
|
||||
* This method uses the input characters to identify marks. This is required in
|
||||
* cases where the font does not contain enough information to identify them based
|
||||
* on the glyph IDs.
|
||||
*
|
||||
* @param chars - the array of input characters
|
||||
* @param charCount - the number of input characers
|
||||
* @param glyphStorage - the object containing the per-glyph storage. The positions array will be modified.
|
||||
* @param reverse - <code>TRUE</code> if the glyph array has been reordered
|
||||
* @param markFilter - used to identify mark glyphs
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @see LEGlyphFilter
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 charCount, le_bool reverse, LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success);
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
public:
|
||||
/**
|
||||
* The destructor. It will free any storage allocated for the
|
||||
* glyph, character index and position arrays by calling the reset
|
||||
* method. It is declared virtual so that it will be invoked by the
|
||||
* subclass destructors.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual ~LayoutEngine();
|
||||
|
||||
/**
|
||||
* This method will invoke the layout steps in their correct order by calling
|
||||
* the computeGlyphs, positionGlyphs and adjustGlyphPosition methods. It will
|
||||
* compute the glyph, character index and position arrays.
|
||||
*
|
||||
* @param chars - the input character context
|
||||
* @param offset - the offset of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param max - the number of characters in the input context
|
||||
* @param rightToLeft - TRUE if the characers are in a right to left directional run
|
||||
* @param x - the initial X position
|
||||
* @param y - the initial Y position
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* Note: The glyph, character index and position array can be accessed
|
||||
* using the getter methods below.
|
||||
*
|
||||
* Note: If you call this method more than once, you must call the reset()
|
||||
* method first to free the glyph, character index and position arrays
|
||||
* allocated by the previous call.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual le_int32 layoutChars(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, float x, float y, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method returns the number of glyphs in the glyph array. Note
|
||||
* that the number of glyphs will be greater than or equal to the number
|
||||
* of characters used to create the LayoutEngine.
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
le_int32 getGlyphCount() const;
|
||||
|
||||
/**
|
||||
* This method copies the glyph array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold all
|
||||
* the glyphs.
|
||||
*
|
||||
* @param glyphs - the destiniation glyph array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the glyph array into a caller supplied array,
|
||||
* ORing in extra bits. (This functionality is needed by the JDK,
|
||||
* which uses 32 bits pre glyph idex, with the high 16 bits encoding
|
||||
* the composite font slot number)
|
||||
*
|
||||
* @param glyphs - the destination (32 bit) glyph array
|
||||
* @param extraBits - this value will be ORed with each glyph index
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param indexBase - an offset which will be added to each index
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the position array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold an
|
||||
* X and Y position for each glyph, plus an extra X and Y for the
|
||||
* advance of the last glyph.
|
||||
*
|
||||
* @param positions - the destiniation position array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
void getGlyphPositions(float positions[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method returns the X and Y position of the glyph at
|
||||
* the given index.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param glyphIndex - the index of the glyph
|
||||
*
|
||||
* Output parameters:
|
||||
* @param x - the glyph's X position
|
||||
* @param y - the glyph's Y position
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method frees the glyph, character index and position arrays
|
||||
* so that the LayoutEngine can be reused to layout a different
|
||||
* characer array. (This method is also called by the destructor)
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual void reset();
|
||||
|
||||
/**
|
||||
* This method returns a LayoutEngine capable of laying out text
|
||||
* in the given font, script and langauge. Note that the LayoutEngine
|
||||
* returned may be a subclass of LayoutEngine.
|
||||
*
|
||||
* @param fontInstance - the font of the text
|
||||
* @param scriptCode - the script of the text
|
||||
* @param languageCode - the language of the text
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @return a LayoutEngine which can layout text in the given font.
|
||||
*
|
||||
* @see LEFontInstance
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Override of existing call that provides flags to control typography.
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typo_flags, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
static UClassID getStaticClassID();
|
||||
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
740
project/jni/icuuc/include/layout/ParagraphLayout.h
Normal file
740
project/jni/icuuc/include/layout/ParagraphLayout.h
Normal file
@@ -0,0 +1,740 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 2002-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __PARAGRAPHLAYOUT_H
|
||||
|
||||
#define __PARAGRAPHLAYOUT_H
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Paragraph Layout
|
||||
*/
|
||||
|
||||
/*
|
||||
* ParagraphLayout doesn't make much sense without
|
||||
* BreakIterator...
|
||||
*/
|
||||
#include "unicode/uscript.h"
|
||||
#if ! UCONFIG_NO_BREAK_ITERATION
|
||||
|
||||
#include "layout/LETypes.h"
|
||||
#include "layout/LEFontInstance.h"
|
||||
#include "layout/LayoutEngine.h"
|
||||
#include "unicode/ubidi.h"
|
||||
#include "unicode/brkiter.h"
|
||||
|
||||
#include "layout/RunArrays.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* ParagraphLayout.
|
||||
*
|
||||
* The <code>ParagraphLayout</code> object will analyze the text into runs of text in the
|
||||
* same font, script and direction, and will create a <code>LayoutEngine</code> object for each run.
|
||||
* The <code>LayoutEngine</code> will transform the characters into glyph codes in visual order.
|
||||
*
|
||||
* Clients can use this to break a paragraph into lines, and to display the glyphs in each line.
|
||||
*
|
||||
*/
|
||||
class U_LAYOUTEX_API ParagraphLayout : public UObject
|
||||
{
|
||||
public:
|
||||
class VisualRun;
|
||||
|
||||
/**
|
||||
* This class represents a single line of text in a <code>ParagraphLayout</code>. They
|
||||
* can only be created by calling <code>ParagraphLayout::nextLine()</code>. Each line
|
||||
* consists of multiple visual runs, represented by <code>ParagraphLayout::VisualRun</code>
|
||||
* objects.
|
||||
*
|
||||
* @see ParagraphLayout
|
||||
* @see ParagraphLayout::VisualRun
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API Line : public UObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The constructor is private since these objects can only be
|
||||
* created by <code>ParagraphLayout</code>. However, it is the
|
||||
* clients responsibility to destroy the objects, so the destructor
|
||||
* is public.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
~Line();
|
||||
|
||||
/**
|
||||
* Count the number of visual runs in the line.
|
||||
*
|
||||
* @return the number of visual runs.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 countRuns() const;
|
||||
|
||||
/**
|
||||
* Get the ascent of the line. This is the maximum ascent
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @return the ascent of the line.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 getAscent() const;
|
||||
|
||||
/**
|
||||
* Get the descent of the line. This is the maximum descent
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @return the descent of the line.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 getDescent() const;
|
||||
|
||||
/**
|
||||
* Get the leading of the line. This is the maximum leading
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @return the leading of the line.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 getLeading() const;
|
||||
|
||||
/**
|
||||
* Get the width of the line. This is a convenience method
|
||||
* which returns the last X position of the last visual run
|
||||
* in the line.
|
||||
*
|
||||
* @return the width of the line.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
le_int32 getWidth() const;
|
||||
|
||||
/**
|
||||
* Get a <code>ParagraphLayout::VisualRun</code> object for a given
|
||||
* visual run in the line.
|
||||
*
|
||||
* @param runIndex is the index of the run, in visual order.
|
||||
*
|
||||
* @return the <code>ParagraphLayout::VisualRun</code> object representing the
|
||||
* visual run. This object is owned by the <code>Line</code> object which
|
||||
* created it, and will remain valid for as long as the <code>Line</code>
|
||||
* object is valid.
|
||||
*
|
||||
* @see ParagraphLayout::VisualRun
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
const VisualRun *getVisualRun(le_int32 runIndex) const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
friend class ParagraphLayout;
|
||||
|
||||
le_int32 fAscent;
|
||||
le_int32 fDescent;
|
||||
le_int32 fLeading;
|
||||
|
||||
le_int32 fRunCount;
|
||||
le_int32 fRunCapacity;
|
||||
|
||||
VisualRun **fRuns;
|
||||
|
||||
inline Line();
|
||||
inline Line(const Line &other);
|
||||
inline Line &operator=(const Line & /*other*/) { return *this; };
|
||||
|
||||
void computeMetrics();
|
||||
|
||||
void append(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
|
||||
const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
|
||||
};
|
||||
|
||||
/**
|
||||
* This object represents a single visual run in a line of text in
|
||||
* a paragraph. A visual run is text which is in the same font,
|
||||
* script, and direction. The text is represented by an array of
|
||||
* <code>LEGlyphIDs</code>, an array of (x, y) glyph positions and
|
||||
* a table which maps indices into the glyph array to indices into
|
||||
* the original character array which was used to create the paragraph.
|
||||
*
|
||||
* These objects are only created by <code>ParagraphLayout::Line</code> objects,
|
||||
* so their constructors and destructors are private.
|
||||
*
|
||||
* @see ParagraphLayout::Line
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API VisualRun : public UObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Get the <code>LEFontInstance</code> object which
|
||||
* represents the font of the visual run. This will always
|
||||
* be a non-composite font.
|
||||
*
|
||||
* @return the <code>LEFontInstance</code> object which represents the
|
||||
* font of the visual run.
|
||||
*
|
||||
* @see LEFontInstance
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline const LEFontInstance *getFont() const;
|
||||
|
||||
/**
|
||||
* Get the direction of the visual run.
|
||||
*
|
||||
* @return the direction of the run. This will be UBIDI_LTR if the
|
||||
* run is left-to-right and UBIDI_RTL if the line is right-to-left.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline UBiDiDirection getDirection() const;
|
||||
|
||||
/**
|
||||
* Get the number of glyphs in the visual run.
|
||||
*
|
||||
* @return the number of glyphs.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getGlyphCount() const;
|
||||
|
||||
/**
|
||||
* Get the glyphs in the visual run. Glyphs with the values <code>0xFFFE</code> and
|
||||
* <code>0xFFFF</code> should be ignored.
|
||||
*
|
||||
* @return the address of the array of glyphs for this visual run. The storage
|
||||
* is owned by the <code>VisualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>VisualRun</code> object is valid.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline const LEGlyphID *getGlyphs() const;
|
||||
|
||||
/**
|
||||
* Get the (x, y) positions of the glyphs in the visual run. To simplify storage
|
||||
* management, the x and y positions are stored in a single array with the x positions
|
||||
* at even offsets in the array and the corresponding y position in the following odd offset.
|
||||
* There is an extra (x, y) pair at the end of the array which represents the advance of
|
||||
* the final glyph in the run.
|
||||
*
|
||||
* @return the address of the array of glyph positions for this visual run. The storage
|
||||
* is owned by the <code>VisualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>VisualRun</code> object is valid.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline const float *getPositions() const;
|
||||
|
||||
/**
|
||||
* Get the glyph-to-character map for this visual run. This maps the indices into
|
||||
* the glyph array to indices into the character array used to create the paragraph.
|
||||
*
|
||||
* @return the address of the character-to-glyph map for this visual run. The storage
|
||||
* is owned by the <code>VisualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>VisualRun</code> object is valid.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline const le_int32 *getGlyphToCharMap() const;
|
||||
|
||||
/**
|
||||
* A convenience method which returns the ascent value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @return the ascent value of this run's font.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getAscent() const;
|
||||
|
||||
/**
|
||||
* A convenience method which returns the descent value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @return the descent value of this run's font.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getDescent() const;
|
||||
|
||||
/**
|
||||
* A convenience method which returns the leading value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @return the leading value of this run's font.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getLeading() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
const LEFontInstance *fFont;
|
||||
const UBiDiDirection fDirection;
|
||||
|
||||
const le_int32 fGlyphCount;
|
||||
|
||||
const LEGlyphID *fGlyphs;
|
||||
const float *fPositions;
|
||||
const le_int32 *fGlyphToCharMap;
|
||||
|
||||
friend class Line;
|
||||
|
||||
inline VisualRun();
|
||||
inline VisualRun(const VisualRun &other);
|
||||
inline VisualRun &operator=(const VisualRun &/*other*/) { return *this; };
|
||||
|
||||
inline VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
|
||||
const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
|
||||
|
||||
~VisualRun();
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct a <code>ParagraphLayout</code> object for a styled paragraph. The paragraph is specified
|
||||
* as runs of text all in the same font. An <code>LEFontInstance</code> object and a limit offset
|
||||
* are specified for each font run. The limit offset is the offset of the character immediately
|
||||
* after the font run.
|
||||
*
|
||||
* Clients can optionally specify directional runs and / or script runs. If these aren't specified
|
||||
* they will be computed.
|
||||
*
|
||||
* If any errors are encountered during construction, <code>status</code> will be set, and the object
|
||||
* will be set to be empty.
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @param fontRuns a pointer to a <code>FontRuns</code> object representing the font runs.
|
||||
*
|
||||
* @param levelRuns is a pointer to a <code>ValueRuns</code> object representing the directional levels.
|
||||
* If this pointer in <code>NULL</code> the levels will be determined by running the Unicde
|
||||
* Bidi algorithm.
|
||||
*
|
||||
* @param scriptRuns is a pointer to a <code>ValueRuns</code> object representing script runs.
|
||||
* If this pointer in <code>NULL</code> the script runs will be determined using the
|
||||
* Unicode code points.
|
||||
*
|
||||
* @param localeRuns is a pointer to a <code>LocaleRuns</code> object representing locale runs.
|
||||
* The <code>Locale</code> objects are used to determind the language of the text. If this
|
||||
* pointer is <code>NULL</code> the default locale will be used for all of the text.
|
||||
*
|
||||
* @param paragraphLevel is the directionality of the paragraph, as in the UBiDi object.
|
||||
*
|
||||
* @param vertical is <code>TRUE</code> if the paragraph should be set vertically.
|
||||
*
|
||||
* @param status will be set to any error code encountered during construction.
|
||||
*
|
||||
* @see ubidi.h
|
||||
* @see LEFontInstance.h
|
||||
* @see LayoutEngine.h
|
||||
* @see RunArrays.h
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
ParagraphLayout(const LEUnicode chars[], le_int32 count,
|
||||
const FontRuns *fontRuns,
|
||||
const ValueRuns *levelRuns,
|
||||
const ValueRuns *scriptRuns,
|
||||
const LocaleRuns *localeRuns,
|
||||
UBiDiLevel paragraphLevel, le_bool vertical,
|
||||
LEErrorCode &status);
|
||||
|
||||
/**
|
||||
* The destructor. Virtual so that it works correctly with
|
||||
* sublcasses.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
~ParagraphLayout();
|
||||
|
||||
// Note: the following is #if 0'd out because there's no good
|
||||
// way to implement it without either calling layoutEngineFactory()
|
||||
// or duplicating the logic there...
|
||||
#if 0
|
||||
/**
|
||||
* Examine the given styled paragraph and determine if it contains any text which
|
||||
* requires complex processing. (i.e. that cannot be correctly rendered by
|
||||
* just mapping the characters to glyphs and rendering them in order)
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @param fontRuns is a pointer to a <code>FontRuns</code> object representing the font runs.
|
||||
*
|
||||
* @return <code>TRUE</code> if the paragraph contains complex text.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static le_bool isComplex(const LEUnicode chars[], le_int32 count, const FontRuns *fontRuns);
|
||||
#else
|
||||
/**
|
||||
* Examine the given text and determine if it contains characters in any
|
||||
* script which requires complex processing to be rendered correctly.
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @return <code>TRUE</code> if any of the text requires complex processing.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static le_bool isComplex(const LEUnicode chars[], le_int32 count);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return the resolved paragraph level. This is useful for those cases
|
||||
* where the bidi analysis has determined the level based on the first
|
||||
* strong character in the paragraph.
|
||||
*
|
||||
* @return the resolved paragraph level.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline UBiDiLevel getParagraphLevel();
|
||||
|
||||
/**
|
||||
* Return the directionality of the text in the paragraph.
|
||||
*
|
||||
* @return <code>UBIDI_LTR</code> if the text is all left to right,
|
||||
* <code>UBIDI_RTL</code> if the text is all right to left,
|
||||
* or <code>UBIDI_MIXED</code> if the text has mixed direction.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline UBiDiDirection getTextDirection();
|
||||
|
||||
/**
|
||||
* Return the max ascent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @return the ascent value.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getAscent() const;
|
||||
|
||||
/**
|
||||
* Return the max descent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @return the decent value.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getDescent() const;
|
||||
|
||||
/**
|
||||
* Return the max leading value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @return the leading value.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getLeading() const;
|
||||
|
||||
/**
|
||||
* Reset line breaking to start from the beginning of the paragraph.
|
||||
*
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline void reflow();
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
*
|
||||
* Convenience method for determining if paragraph layout processing is complete ( i.e. there
|
||||
* are no more lines left to process. )
|
||||
*
|
||||
* @return true if there are no more lines to be processed
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
inline le_bool isDone() const;
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* Return a <code>ParagraphLayout::Line</code> object which represents next line
|
||||
* in the paragraph. The width of the line is specified each time so that it can
|
||||
* be varied to support arbitrary paragraph shapes.
|
||||
*
|
||||
* @param width is the width of the line. If <code>width</code> is less than or equal
|
||||
* to zero, a <code>ParagraphLayout::Line</code> object representing the
|
||||
* rest of the paragraph will be returned.
|
||||
*
|
||||
* @return a <code>ParagraphLayout::Line</code> object which represents the line. The caller
|
||||
* is responsible for deleting the object. Returns <code>NULL</code> if there are no
|
||||
* more lines in the paragraph.
|
||||
*
|
||||
* @see ParagraphLayout::Line
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
Line *nextLine(float width);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
struct StyleRunInfo
|
||||
{
|
||||
LayoutEngine *engine;
|
||||
const LEFontInstance *font;
|
||||
const Locale *locale;
|
||||
LEGlyphID *glyphs;
|
||||
float *positions;
|
||||
UScriptCode script;
|
||||
UBiDiLevel level;
|
||||
le_int32 runBase;
|
||||
le_int32 runLimit;
|
||||
le_int32 glyphBase;
|
||||
le_int32 glyphCount;
|
||||
};
|
||||
|
||||
ParagraphLayout() {};
|
||||
ParagraphLayout(const ParagraphLayout & /*other*/) : UObject( ){};
|
||||
inline ParagraphLayout &operator=(const ParagraphLayout & /*other*/) { return *this; };
|
||||
|
||||
void computeLevels(UBiDiLevel paragraphLevel);
|
||||
|
||||
Line *computeVisualRuns();
|
||||
void appendRun(Line *line, le_int32 run, le_int32 firstChar, le_int32 lastChar);
|
||||
|
||||
void computeScripts();
|
||||
|
||||
void computeLocales();
|
||||
|
||||
void computeSubFonts(const FontRuns *fontRuns, LEErrorCode &status);
|
||||
|
||||
void computeMetrics();
|
||||
|
||||
le_int32 getLanguageCode(const Locale *locale);
|
||||
|
||||
le_int32 getCharRun(le_int32 charIndex);
|
||||
|
||||
static le_bool isComplex(UScriptCode script);
|
||||
|
||||
le_int32 previousBreak(le_int32 charIndex);
|
||||
|
||||
|
||||
const LEUnicode *fChars;
|
||||
le_int32 fCharCount;
|
||||
|
||||
const FontRuns *fFontRuns;
|
||||
const ValueRuns *fLevelRuns;
|
||||
const ValueRuns *fScriptRuns;
|
||||
const LocaleRuns *fLocaleRuns;
|
||||
|
||||
le_bool fVertical;
|
||||
le_bool fClientLevels;
|
||||
le_bool fClientScripts;
|
||||
le_bool fClientLocales;
|
||||
|
||||
UBiDiLevel *fEmbeddingLevels;
|
||||
|
||||
le_int32 fAscent;
|
||||
le_int32 fDescent;
|
||||
le_int32 fLeading;
|
||||
|
||||
le_int32 *fGlyphToCharMap;
|
||||
le_int32 *fCharToMinGlyphMap;
|
||||
le_int32 *fCharToMaxGlyphMap;
|
||||
float *fGlyphWidths;
|
||||
le_int32 fGlyphCount;
|
||||
|
||||
UBiDi *fParaBidi;
|
||||
UBiDi *fLineBidi;
|
||||
|
||||
le_int32 *fStyleRunLimits;
|
||||
le_int32 *fStyleIndices;
|
||||
StyleRunInfo *fStyleRunInfo;
|
||||
le_int32 fStyleRunCount;
|
||||
|
||||
BreakIterator *fBreakIterator;
|
||||
le_int32 fLineStart;
|
||||
le_int32 fLineEnd;
|
||||
|
||||
le_int32 fFirstVisualRun;
|
||||
le_int32 fLastVisualRun;
|
||||
float fVisualRunLastX;
|
||||
float fVisualRunLastY;
|
||||
};
|
||||
|
||||
inline UBiDiLevel ParagraphLayout::getParagraphLevel()
|
||||
{
|
||||
return ubidi_getParaLevel(fParaBidi);
|
||||
}
|
||||
|
||||
inline UBiDiDirection ParagraphLayout::getTextDirection()
|
||||
{
|
||||
return ubidi_getDirection(fParaBidi);
|
||||
}
|
||||
|
||||
inline void ParagraphLayout::reflow()
|
||||
{
|
||||
fLineEnd = 0;
|
||||
}
|
||||
|
||||
inline ParagraphLayout::Line::Line()
|
||||
: UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
|
||||
{
|
||||
// nothing else to do
|
||||
}
|
||||
|
||||
inline ParagraphLayout::Line::Line(const Line & /*other*/)
|
||||
: UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
|
||||
{
|
||||
// nothing else to do
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::Line::countRuns() const
|
||||
{
|
||||
return fRunCount;
|
||||
}
|
||||
|
||||
inline const LEFontInstance *ParagraphLayout::VisualRun::getFont() const
|
||||
{
|
||||
return fFont;
|
||||
}
|
||||
|
||||
inline UBiDiDirection ParagraphLayout::VisualRun::getDirection() const
|
||||
{
|
||||
return fDirection;
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::VisualRun::getGlyphCount() const
|
||||
{
|
||||
return fGlyphCount;
|
||||
}
|
||||
|
||||
inline const LEGlyphID *ParagraphLayout::VisualRun::getGlyphs() const
|
||||
{
|
||||
return fGlyphs;
|
||||
}
|
||||
|
||||
inline const float *ParagraphLayout::VisualRun::getPositions() const
|
||||
{
|
||||
return fPositions;
|
||||
}
|
||||
|
||||
inline const le_int32 *ParagraphLayout::VisualRun::getGlyphToCharMap() const
|
||||
{
|
||||
return fGlyphToCharMap;
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::VisualRun::getAscent() const
|
||||
{
|
||||
return fFont->getAscent();
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::VisualRun::getDescent() const
|
||||
{
|
||||
return fFont->getDescent();
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::VisualRun::getLeading() const
|
||||
{
|
||||
return fFont->getLeading();
|
||||
}
|
||||
|
||||
inline ParagraphLayout::VisualRun::VisualRun()
|
||||
: UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &/*other*/)
|
||||
: UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
inline ParagraphLayout::VisualRun::VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
|
||||
const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[])
|
||||
: fFont(font), fDirection(direction), fGlyphCount(glyphCount),
|
||||
fGlyphs(glyphs), fPositions(positions), fGlyphToCharMap(glyphToCharMap)
|
||||
{
|
||||
// nothing else needs to be done!
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
#endif
|
||||
676
project/jni/icuuc/include/layout/RunArrays.h
Normal file
676
project/jni/icuuc/include/layout/RunArrays.h
Normal file
@@ -0,0 +1,676 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 2003-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __RUNARRAYS_H
|
||||
|
||||
#define __RUNARRAYS_H
|
||||
|
||||
#include "layout/LETypes.h"
|
||||
#include "layout/LEFontInstance.h"
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/locid.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: base class for building classes which represent data that is associated with runs of text.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* The initial size of an array if it is unspecified.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define INITIAL_CAPACITY 16
|
||||
|
||||
/**
|
||||
* When an array needs to grow, it will double in size until
|
||||
* it becomes this large, then it will grow by this amount.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define CAPACITY_GROW_LIMIT 128
|
||||
|
||||
/**
|
||||
* The <code>RunArray</code> class is a base class for building classes
|
||||
* which represent data that is associated with runs of text. This class
|
||||
* maintains an array of limit indices into the text, subclasses
|
||||
* provide one or more arrays of data.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API RunArray : public UObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a <code>RunArray</code> object from a pre-existing
|
||||
* array of limit indices.
|
||||
*
|
||||
* @param limits is an array of limit indices. This array must remain
|
||||
* valid until the <code>RunArray</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the limit array.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline RunArray(const le_int32 *limits, le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>RunArray</code> object. Clients can add limit
|
||||
* indices array using the <code>add</code> method.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the limit indices array. If
|
||||
* this value is zero, no array will be allocated.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
RunArray(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* The destructor; virtual so that subclass destructors are invoked as well.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual ~RunArray();
|
||||
|
||||
/**
|
||||
* Get the number of entries in the limit indices array.
|
||||
*
|
||||
* @return the number of entries in the limit indices array.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getCount() const;
|
||||
|
||||
/**
|
||||
* Reset the limit indices array. This method sets the number of entries in the
|
||||
* limit indices array to zero. It does not delete the array.
|
||||
*
|
||||
* Note: Subclass arrays will also be reset and not deleted.
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
inline void reset();
|
||||
|
||||
/**
|
||||
* Get the last limit index. This is the number of characters in
|
||||
* the text.
|
||||
*
|
||||
* @return the last limit index.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getLimit() const;
|
||||
|
||||
/**
|
||||
* Get the limit index for a particular run of text.
|
||||
*
|
||||
* @param run is the run. This is an index into the limit index array.
|
||||
*
|
||||
* @return the limit index for the run, or -1 if <code>run</code> is out of bounds.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getLimit(le_int32 run) const;
|
||||
|
||||
/**
|
||||
* Add a limit index to the limit indices array and return the run index
|
||||
* where it was stored. If the array does not exist, it will be created by
|
||||
* calling the <code>init</code> method. If it is full, it will be grown by
|
||||
* calling the <code>grow</code> method.
|
||||
*
|
||||
* If the <code>RunArray</code> object was created with a client-supplied
|
||||
* limit indices array, this method will return a run index of -1.
|
||||
*
|
||||
* Subclasses should not override this method. Rather they should provide
|
||||
* a new <code>add</code> method which takes a limit index along with whatever
|
||||
* other data they implement. The new <code>add</code> method should
|
||||
* first call this method to grow the data arrays, and use the return value
|
||||
* to store the data in their own arrays.
|
||||
*
|
||||
* @param limit is the limit index to add to the array.
|
||||
*
|
||||
* @return the run index where the limit index was stored, or -1 if the limit index cannt be stored.
|
||||
*
|
||||
* @see init
|
||||
* @see grow
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 add(le_int32 limit);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Create a data array with the given initial size. This method will be
|
||||
* called by the <code>add</code> method if there is no limit indices
|
||||
* array. Subclasses which override this method must also call it from
|
||||
* the overriding method to create the limit indices array.
|
||||
*
|
||||
* @param capacity is the initial size of the data array.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual void init(le_int32 capacity);
|
||||
|
||||
/**
|
||||
* Grow a data array to the given initial size. This method will be
|
||||
* called by the <code>add</code> method if the limit indices
|
||||
* array is full. Subclasses which override this method must also call it from
|
||||
* the overriding method to grow the limit indices array.
|
||||
*
|
||||
* @param capacity is the initial size of the data array.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual void grow(le_int32 capacity);
|
||||
|
||||
/**
|
||||
* Set by the constructors to indicate whether
|
||||
* or not the client supplied the data arrays.
|
||||
* If they were supplied by the client, the
|
||||
* <code>add</code> method won't change the arrays
|
||||
* and the destructor won't delete them.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_bool fClientArrays;
|
||||
|
||||
private:
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
le_int32 ensureCapacity();
|
||||
|
||||
inline RunArray();
|
||||
inline RunArray(const RunArray & /*other*/);
|
||||
inline RunArray &operator=(const RunArray & /*other*/) { return *this; };
|
||||
|
||||
const le_int32 *fLimits;
|
||||
le_int32 fCount;
|
||||
le_int32 fCapacity;
|
||||
};
|
||||
|
||||
inline RunArray::RunArray()
|
||||
: UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline RunArray::RunArray(const RunArray & /*other*/)
|
||||
: UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline RunArray::RunArray(const le_int32 *limits, le_int32 count)
|
||||
: UObject(), fClientArrays(TRUE), fLimits(limits), fCount(count), fCapacity(count)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline le_int32 RunArray::getCount() const
|
||||
{
|
||||
return fCount;
|
||||
}
|
||||
|
||||
inline void RunArray::reset()
|
||||
{
|
||||
fCount = 0;
|
||||
}
|
||||
|
||||
inline le_int32 RunArray::getLimit(le_int32 run) const
|
||||
{
|
||||
if (run < 0 || run >= fCount) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fLimits[run];
|
||||
}
|
||||
|
||||
inline le_int32 RunArray::getLimit() const
|
||||
{
|
||||
return getLimit(fCount - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>FontRuns</code> class associates pointers to <code>LEFontInstance</code>
|
||||
* objects with runs of text.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API FontRuns : public RunArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a <code>FontRuns</code> object from pre-existing arrays of fonts
|
||||
* and limit indices.
|
||||
*
|
||||
* @param fonts is the address of an array of pointers to <code>LEFontInstance</code> objects. This
|
||||
* array, and the <code>LEFontInstance</code> objects to which it points must remain
|
||||
* valid until the <code>FontRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>FontRuns</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>FontRuns</code> object. Clients can add font and limit
|
||||
* indices arrays using the <code>add</code> method.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the font and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
FontRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* The destructor; virtual so that subclass destructors are invoked as well.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual ~FontRuns();
|
||||
|
||||
/**
|
||||
* Get the <code>LEFontInstance</code> object assoicated with the given run
|
||||
* of text. Use <code>RunArray::getLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the <code>LEFontInstance</code> associated with the given text run.
|
||||
*
|
||||
* @see RunArray::getLimit
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
const LEFontInstance *getFont(le_int32 run) const;
|
||||
|
||||
|
||||
/**
|
||||
* Add an <code>LEFontInstance</code> and limit index pair to the data arrays and return
|
||||
* the run index where the data was stored. This method calls
|
||||
* <code>RunArray::add(limit)</code> which will create or grow the arrays as needed.
|
||||
*
|
||||
* If the <code>FontRuns</code> object was created with a client-supplied
|
||||
* font and limit indices arrays, this method will return a run index of -1.
|
||||
*
|
||||
* Subclasses should not override this method. Rather they should provide a new <code>add</code>
|
||||
* method which takes a font and a limit index along with whatever other data they implement.
|
||||
* The new <code>add</code> method should first call this method to grow the font and limit indices
|
||||
* arrays, and use the returned run index to store data their own arrays.
|
||||
*
|
||||
* @param font is the address of the <code>LEFontInstance</code> to add. This object must
|
||||
* remain valid until the <code>FontRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the font and limit index were stored, or -1 if the data cannot be stored.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 add(const LEFontInstance *font, le_int32 limit);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
protected:
|
||||
virtual void init(le_int32 capacity);
|
||||
virtual void grow(le_int32 capacity);
|
||||
|
||||
private:
|
||||
|
||||
inline FontRuns();
|
||||
inline FontRuns(const FontRuns &other);
|
||||
inline FontRuns &operator=(const FontRuns & /*other*/) { return *this; };
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
const LEFontInstance **fFonts;
|
||||
};
|
||||
|
||||
inline FontRuns::FontRuns()
|
||||
: RunArray(0), fFonts(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline FontRuns::FontRuns(const FontRuns & /*other*/)
|
||||
: RunArray(0), fFonts(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
|
||||
: RunArray(limits, count), fFonts(fonts)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>LocaleRuns</code> class associates pointers to <code>Locale</code>
|
||||
* objects with runs of text.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API LocaleRuns : public RunArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a <code>LocaleRuns</code> object from pre-existing arrays of locales
|
||||
* and limit indices.
|
||||
*
|
||||
* @param locales is the address of an array of pointers to <code>Locale</code> objects. This array,
|
||||
* and the <code>Locale</code> objects to which it points, must remain valid until
|
||||
* the <code>LocaleRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until the
|
||||
* <code>LocaleRuns</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>LocaleRuns</code> object. Clients can add locale and limit
|
||||
* indices arrays using the <code>add</code> method.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the locale and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
LocaleRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* The destructor; virtual so that subclass destructors are invoked as well.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual ~LocaleRuns();
|
||||
|
||||
/**
|
||||
* Get the <code>Locale</code> object assoicated with the given run
|
||||
* of text. Use <code>RunArray::getLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the <code>Locale</code> associated with the given text run.
|
||||
*
|
||||
* @see RunArray::getLimit
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
const Locale *getLocale(le_int32 run) const;
|
||||
|
||||
|
||||
/**
|
||||
* Add a <code>Locale</code> and limit index pair to the data arrays and return
|
||||
* the run index where the data was stored. This method calls
|
||||
* <code>RunArray::add(limit)</code> which will create or grow the arrays as needed.
|
||||
*
|
||||
* If the <code>LocaleRuns</code> object was created with a client-supplied
|
||||
* locale and limit indices arrays, this method will return a run index of -1.
|
||||
*
|
||||
* Subclasses should not override this method. Rather they should provide a new <code>add</code>
|
||||
* method which takes a locale and a limit index along with whatever other data they implement.
|
||||
* The new <code>add</code> method should first call this method to grow the font and limit indices
|
||||
* arrays, and use the returned run index to store data their own arrays.
|
||||
*
|
||||
* @param locale is the address of the <code>Locale</code> to add. This object must remain valid
|
||||
* until the <code>LocaleRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the locale and limit index were stored, or -1 if the data cannot be stored.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 add(const Locale *locale, le_int32 limit);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
protected:
|
||||
virtual void init(le_int32 capacity);
|
||||
virtual void grow(le_int32 capacity);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const Locale **fLocales;
|
||||
|
||||
private:
|
||||
|
||||
inline LocaleRuns();
|
||||
inline LocaleRuns(const LocaleRuns &other);
|
||||
inline LocaleRuns &operator=(const LocaleRuns & /*other*/) { return *this; };
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
};
|
||||
|
||||
inline LocaleRuns::LocaleRuns()
|
||||
: RunArray(0), fLocales(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline LocaleRuns::LocaleRuns(const LocaleRuns & /*other*/)
|
||||
: RunArray(0), fLocales(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
|
||||
: RunArray(limits, count), fLocales(locales)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ValueRuns</code> class associates integer values with runs of text.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API ValueRuns : public RunArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a <code>ValueRuns</code> object from pre-existing arrays of values
|
||||
* and limit indices.
|
||||
*
|
||||
* @param values is the address of an array of integer. This array must remain valid until
|
||||
* the <code>ValueRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>ValueRuns</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>ValueRuns</code> object. Clients can add value and limit
|
||||
* indices arrays using the <code>add</code> method.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the value and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
ValueRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* The destructor; virtual so that subclass destructors are invoked as well.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual ~ValueRuns();
|
||||
|
||||
/**
|
||||
* Get the integer value assoicated with the given run
|
||||
* of text. Use <code>RunArray::getLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the integer value associated with the given text run.
|
||||
*
|
||||
* @see RunArray::getLimit
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 getValue(le_int32 run) const;
|
||||
|
||||
|
||||
/**
|
||||
* Add an integer value and limit index pair to the data arrays and return
|
||||
* the run index where the data was stored. This method calls
|
||||
* <code>RunArray::add(limit)</code> which will create or grow the arrays as needed.
|
||||
*
|
||||
* If the <code>ValueRuns</code> object was created with a client-supplied
|
||||
* font and limit indices arrays, this method will return a run index of -1.
|
||||
*
|
||||
* Subclasses should not override this method. Rather they should provide a new <code>add</code>
|
||||
* method which takes an integer value and a limit index along with whatever other data they implement.
|
||||
* The new <code>add</code> method should first call this method to grow the font and limit indices
|
||||
* arrays, and use the returned run index to store data their own arrays.
|
||||
*
|
||||
* @param value is the integer value to add
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the value and limit index were stored, or -1 if the data cannot be stored.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 add(le_int32 value, le_int32 limit);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
protected:
|
||||
virtual void init(le_int32 capacity);
|
||||
virtual void grow(le_int32 capacity);
|
||||
|
||||
private:
|
||||
|
||||
inline ValueRuns();
|
||||
inline ValueRuns(const ValueRuns &other);
|
||||
inline ValueRuns &operator=(const ValueRuns & /*other*/) { return *this; };
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
const le_int32 *fValues;
|
||||
};
|
||||
|
||||
inline ValueRuns::ValueRuns()
|
||||
: RunArray(0), fValues(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline ValueRuns::ValueRuns(const ValueRuns & /*other*/)
|
||||
: RunArray(0), fValues(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
|
||||
: RunArray(limits, count), fValues(values)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
225
project/jni/icuuc/include/layout/loengine.h
Normal file
225
project/jni/icuuc/include/layout/loengine.h
Normal file
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LOENGINE_H
|
||||
#define __LOENGINE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* \file
|
||||
* \brief C API for complex text layout.
|
||||
* \internal
|
||||
*
|
||||
* This is a technology preview. The API may
|
||||
* change significantly.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The opaque type for a LayoutEngine.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void le_engine;
|
||||
|
||||
/**
|
||||
* The opaque type for a font instance.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void le_font;
|
||||
|
||||
/**
|
||||
* This function returns an le_engine capable of laying out text
|
||||
* in the given font, script and langauge. Note that the LayoutEngine
|
||||
* returned may be a subclass of LayoutEngine.
|
||||
*
|
||||
* @param font - the font of the text
|
||||
* @param scriptCode - the script of the text
|
||||
* @param languageCode - the language of the text
|
||||
* @param typo_flags - flags that control layout features like kerning and ligatures.
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @return an le_engine which can layout text in the given font.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_engine * U_EXPORT2
|
||||
le_create(const le_font *font,
|
||||
le_int32 scriptCode,
|
||||
le_int32 languageCode,
|
||||
le_int32 typo_flags,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function closes the given LayoutEngine. After
|
||||
* it returns, the le_engine is no longer valid.
|
||||
*
|
||||
* @param engine - the LayoutEngine to close.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_close(le_engine *engine);
|
||||
|
||||
/**
|
||||
* This routine will compute the glyph, character index and position arrays.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param chars - the input character context
|
||||
* @param offset - the offset of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param max - the number of characters in the input context
|
||||
* @param rightToLeft - TRUE if the characers are in a right to left directional run
|
||||
* @param x - the initial X position
|
||||
* @param y - the initial Y position
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* Note: The glyph, character index and position array can be accessed
|
||||
* using the getter routines below.
|
||||
*
|
||||
* Note: If you call this function more than once, you must call the reset()
|
||||
* function first to free the glyph, character index and position arrays
|
||||
* allocated by the previous call.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
le_layoutChars(le_engine *engine,
|
||||
const LEUnicode chars[],
|
||||
le_int32 offset,
|
||||
le_int32 count,
|
||||
le_int32 max,
|
||||
le_bool rightToLeft,
|
||||
float x,
|
||||
float y,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function returns the number of glyphs in the glyph array. Note
|
||||
* that the number of glyphs will be greater than or equal to the number
|
||||
* of characters used to create the LayoutEngine.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param success - output parameter set to an error code if the operation fails.
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
le_getGlyphCount(le_engine *engine,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function copies the glyph array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold all
|
||||
* the glyphs.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param glyphs - the destiniation glyph array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getGlyphs(le_engine *engine,
|
||||
LEGlyphID glyphs[],
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getCharIndices(le_engine *engine,
|
||||
le_int32 charIndices[],
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param indexBase - an offset that will be added to each index.
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getCharIndicesWithBase(le_engine *engine,
|
||||
le_int32 charIndices[],
|
||||
le_int32 indexBase,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function copies the position array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold an
|
||||
* X and Y position for each glyph, plus an extra X and Y for the
|
||||
* advance of the last glyph.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param positions - the destiniation position array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getGlyphPositions(le_engine *engine,
|
||||
float positions[],
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function returns the X and Y position of the glyph at
|
||||
* the given index.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param engine - the LayoutEngine
|
||||
* @param glyphIndex - the index of the glyph
|
||||
*
|
||||
* Output parameters:
|
||||
* @param x - the glyph's X position
|
||||
* @param y - the glyph's Y position
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getGlyphPosition(le_engine *engine,
|
||||
le_int32 glyphIndex,
|
||||
float *x,
|
||||
float *y,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function frees the glyph, character index and position arrays
|
||||
* so that the LayoutEngine can be reused to layout a different
|
||||
* characer array. (This function is also called by le_close)
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_reset(le_engine *engine,
|
||||
LEErrorCode *success);
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
#endif
|
||||
466
project/jni/icuuc/include/layout/playout.h
Normal file
466
project/jni/icuuc/include/layout/playout.h
Normal file
@@ -0,0 +1,466 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PLAYOUT_H
|
||||
#define __PLAYOUT_H
|
||||
|
||||
/*
|
||||
* ParagraphLayout doesn't make much sense without
|
||||
* BreakIterator...
|
||||
*/
|
||||
#include "unicode/ubidi.h"
|
||||
#if ! UCONFIG_NO_BREAK_ITERATION
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
|
||||
#include "layout/LETypes.h"
|
||||
#include "plruns.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C API for paragraph layout.
|
||||
*
|
||||
* This is a technology preview. The API may
|
||||
* change significantly.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The opaque type for a paragraph layout.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void pl_paragraph;
|
||||
|
||||
/**
|
||||
* The opaque type for a line in a paragraph layout.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void pl_line;
|
||||
|
||||
/**
|
||||
* The opaque type for a visual run in a line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void pl_visualRun;
|
||||
|
||||
/**
|
||||
* Construct a <code>ParagraphLayout</code> object for a styled paragraph. The paragraph is specified
|
||||
* as runs of text all in the same font. An <code>LEFontInstance</code> object and a limit offset
|
||||
* are specified for each font run. The limit offset is the offset of the character immediately
|
||||
* after the font run.
|
||||
*
|
||||
* Clients can optionally specify directional runs and / or script runs. If these aren't specified
|
||||
* they will be computed.
|
||||
*
|
||||
* If any errors are encountered during construction, <code>status</code> will be set, and the object
|
||||
* will be set to be empty.
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @param fontRuns a pointer to a <code>pl_fontRuns</code> object representing the font runs.
|
||||
*
|
||||
* @param levelRuns is a pointer to a <code>pl_valueRuns</code> object representing the directional levels.
|
||||
* If this pointer in <code>NULL</code> the levels will be determined by running the Unicde
|
||||
* Bidi algorithm.
|
||||
*
|
||||
* @param scriptRuns is a pointer to a <code>pl_valueRuns</code> object representing script runs.
|
||||
* If this pointer in <code>NULL</code> the script runs will be determined using the
|
||||
* Unicode code points.
|
||||
*
|
||||
* @param localeRuns is a pointer to a <code>pl_localeRuns</code> object representing locale runs.
|
||||
* The <code>Locale</code> objects are used to determind the language of the text. If this
|
||||
* pointer is <code>NULL</code> the default locale will be used for all of the text.
|
||||
*
|
||||
* @param paragraphLevel is the directionality of the paragraph, as in the UBiDi object.
|
||||
*
|
||||
* @param vertical is <code>TRUE</code> if the paragraph should be set vertically.
|
||||
*
|
||||
* @param status will be set to any error code encountered during construction.
|
||||
*
|
||||
* @return a pointer to the newly created <code>pl_paragraph</code> object. The object
|
||||
* will remain valid until <code>pl_close</code> is called.
|
||||
*
|
||||
* @see ubidi.h
|
||||
* @see longine.h
|
||||
* @see plruns.h
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_paragraph * U_EXPORT2
|
||||
pl_create(const LEUnicode chars[],
|
||||
le_int32 count,
|
||||
const pl_fontRuns *fontRuns,
|
||||
const pl_valueRuns *levelRuns,
|
||||
const pl_valueRuns *scriptRuns,
|
||||
const pl_localeRuns *localeRuns,
|
||||
UBiDiLevel paragraphLevel,
|
||||
le_bool vertical,
|
||||
LEErrorCode *status);
|
||||
|
||||
/**
|
||||
* Close the given paragraph layout object.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code> object to be
|
||||
* closed. Once this routine returns the object
|
||||
* can no longer be referenced
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_close(pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Examine the given text and determine if it contains characters in any
|
||||
* script which requires complex processing to be rendered correctly.
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @return <code>TRUE</code> if any of the text requires complex processing.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
||||
U_INTERNAL le_bool U_EXPORT2
|
||||
pl_isComplex(const LEUnicode chars[],
|
||||
le_int32 count);
|
||||
|
||||
/**
|
||||
* Return the resolved paragraph level. This is useful for those cases
|
||||
* where the bidi analysis has determined the level based on the first
|
||||
* strong character in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return the resolved paragraph level.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL UBiDiLevel U_EXPORT2
|
||||
pl_getParagraphLevel(pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Return the directionality of the text in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return <code>UBIDI_LTR</code> if the text is all left to right,
|
||||
* <code>UBIDI_RTL</code> if the text is all right to left,
|
||||
* or <code>UBIDI_MIXED</code> if the text has mixed direction.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL UBiDiDirection U_EXPORT2
|
||||
pl_getTextDirection(pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Get the max ascent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* Return the max ascent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return the ascent value.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getAscent(const pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Return the max descent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return the decent value.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getDescent(const pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Return the max leading value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return the leading value.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLeading(const pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Reset line breaking to start from the beginning of the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_reflow(pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Return a <code>pl_line</code> object which represents next line
|
||||
* in the paragraph. The width of the line is specified each time so that it can
|
||||
* be varied to support arbitrary paragraph shapes.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
* @param width is the width of the line. If <code>width</code> is less than or equal
|
||||
* to zero, a <code>ParagraphLayout::Line</code> object representing the
|
||||
* rest of the paragraph will be returned.
|
||||
*
|
||||
* @return a <code>ParagraphLayout::Line</code> object which represents the line. The caller
|
||||
* is responsible for deleting the object. Returns <code>NULL</code> if there are no
|
||||
* more lines in the paragraph.
|
||||
*
|
||||
* @see pl_line
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_line * U_EXPORT2
|
||||
pl_nextLine(pl_paragraph *paragraph, float width);
|
||||
|
||||
/**
|
||||
* Close the given line object. Line objects are created
|
||||
* by <code>pl_nextLine</code> but it is the client's responsibility
|
||||
* to close them by calling this routine.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object to close.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_closeLine(pl_line *line);
|
||||
|
||||
/**
|
||||
* Count the number of visual runs in the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the number of visual runs.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_countLineRuns(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get the ascent of the line. This is the maximum ascent
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the ascent of the line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLineAscent(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get the descent of the line. This is the maximum descent
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the descent of the line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLineDescent(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get the leading of the line. This is the maximum leading
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the leading of the line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLineLeading(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get the width of the line. This is a convenience method
|
||||
* which returns the last X position of the last visual run
|
||||
* in the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the width of the line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLineWidth(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get a <code>ParagraphLayout::VisualRun</code> object for a given
|
||||
* visual run in the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
* @param runIndex is the index of the run, in visual order.
|
||||
*
|
||||
* @return the <code>pl_visualRun</code> object representing the
|
||||
* visual run. This object is owned by the <code>pl_line</code> object which
|
||||
* created it, and will remain valid for as long as the <code>pl_line</code>
|
||||
* object is valid.
|
||||
*
|
||||
* @see pl_visualRun
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const pl_visualRun * U_EXPORT2
|
||||
pl_getLineVisualRun(const pl_line *line, le_int32 runIndex);
|
||||
|
||||
/**
|
||||
* Get the <code>le_font</code> object which
|
||||
* represents the font of the visual run. This will always
|
||||
* be a non-composite font.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the <code>le_font</code> object which represents the
|
||||
* font of the visual run.
|
||||
*
|
||||
* @see le_font
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const le_font * U_EXPORT2
|
||||
pl_getVisualRunFont(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the direction of the visual run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the direction of the run. This will be <code>UBIDI_LTR</code> if the
|
||||
* run is left-to-right and <code>UBIDI_RTL</code> if the line is right-to-left.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL UBiDiDirection U_EXPORT2
|
||||
pl_getVisualRunDirection(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the number of glyphs in the visual run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the number of glyphs.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getVisualRunGlyphCount(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the glyphs in the visual run. Glyphs with the values <code>0xFFFE</code> and
|
||||
* <code>0xFFFF</code> should be ignored.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the address of the array of glyphs for this visual run. The storage
|
||||
* is owned by the <code>pl_visualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>pl_visualRun</code> object is valid.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const LEGlyphID * U_EXPORT2
|
||||
pl_getVisualRunGlyphs(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the (x, y) positions of the glyphs in the visual run. To simplify storage
|
||||
* management, the x and y positions are stored in a single array with the x positions
|
||||
* at even offsets in the array and the corresponding y position in the following odd offset.
|
||||
* There is an extra (x, y) pair at the end of the array which represents the advance of
|
||||
* the final glyph in the run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the address of the array of glyph positions for this visual run. The storage
|
||||
* is owned by the <code>pl_visualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>pl_visualRun</code> object is valid.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const float * U_EXPORT2
|
||||
pl_getVisualRunPositions(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the glyph-to-character map for this visual run. This maps the indices into
|
||||
* the glyph array to indices into the character array used to create the paragraph.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the address of the character-to-glyph map for this visual run. The storage
|
||||
* is owned by the <code>pl_visualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>pl_visualRun</code> object is valid.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const le_int32 * U_EXPORT2
|
||||
pl_getVisualRunGlyphToCharMap(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* A convenience method which returns the ascent value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the ascent value of this run's font.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getVisualRunAscent(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* A convenience method which returns the descent value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the descent value of this run's font.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getVisualRunDescent(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* A convenience method which returns the leading value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the leading value of this run's font.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getVisualRunLeading(const pl_visualRun *run);
|
||||
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
#endif
|
||||
#endif
|
||||
441
project/jni/icuuc/include/layout/plruns.h
Normal file
441
project/jni/icuuc/include/layout/plruns.h
Normal file
@@ -0,0 +1,441 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PLRUNS_H
|
||||
#define __PLRUNS_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
|
||||
#include "unicode/ubidi.h"
|
||||
#include "layout/LETypes.h"
|
||||
|
||||
#include "layout/loengine.h"
|
||||
|
||||
/**
|
||||
* Opaque datatype representing an array of font runs
|
||||
*/
|
||||
typedef void pl_fontRuns;
|
||||
/**
|
||||
* Opaque datatype representing an array of value runs
|
||||
*/
|
||||
typedef void pl_valueRuns;
|
||||
/**
|
||||
* Opaque datatype representing an array of locale runs
|
||||
*/
|
||||
typedef void pl_localeRuns;
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C API for run arrays.
|
||||
*
|
||||
* This is a technology preview. The API may
|
||||
* change significantly.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Construct a <code>pl_fontRuns</code> object from pre-existing arrays of fonts
|
||||
* and limit indices.
|
||||
*
|
||||
* @param fonts is the address of an array of pointers to <code>le_font</code> objects. This
|
||||
* array, and the <code>le_font</code> objects to which it points must remain
|
||||
* valid until the <code>pl_fontRuns</code> object is closed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>pl_fontRuns</code> object is closed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_fontRuns * U_EXPORT2
|
||||
pl_openFontRuns(const le_font **fonts,
|
||||
const le_int32 *limits,
|
||||
le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>pl_fontRuns</code> object. Clients can add font and limit
|
||||
* indices arrays using the <code>pl_addFontRun</code> routine.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the font and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see pl_addFontRun
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_fontRuns * U_EXPORT2
|
||||
pl_openEmptyFontRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* Close the given <code>pl_fontRuns</code> object. Once this
|
||||
* call returns, the object can no longer be referenced.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_closeFontRuns(pl_fontRuns *fontRuns);
|
||||
|
||||
/**
|
||||
* Get the number of font runs.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @return the number of entries in the limit indices array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getFontRunCount(const pl_fontRuns *fontRuns);
|
||||
|
||||
/**
|
||||
* Reset the number of font runs to zero.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_resetFontRuns(pl_fontRuns *fontRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for the last font run. This is the
|
||||
* number of characters in the text.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @return the last limit index.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getFontRunLastLimit(const pl_fontRuns *fontRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for a particular font run.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
* @param run is the run. This is an index into the limit index array.
|
||||
*
|
||||
* @return the limit index for the run, or -1 if <code>run</code> is out of bounds.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getFontRunLimit(const pl_fontRuns *fontRuns,
|
||||
le_int32 run);
|
||||
|
||||
/**
|
||||
* Get the <code>le_font</code> object assoicated with the given run
|
||||
* of text. Use <code>pl_getFontRunLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the <code>le_font</code> associated with the given text run.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const le_font * U_EXPORT2
|
||||
pl_getFontRunFont(const pl_fontRuns *fontRuns,
|
||||
le_int32 run);
|
||||
|
||||
|
||||
/**
|
||||
* Add a new font run to the given <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* If the <code>pl_fontRuns</code> object was not created by calling
|
||||
* <code>pl_openEmptyFontRuns</code>, this method will return a run index of -1.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @param font is the address of the <code>le_font</code> to add. This object must
|
||||
* remain valid until the <code>pl_fontRuns</code> object is closed.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the font and limit index were stored, or -1 if
|
||||
* the run cannot be added.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_addFontRun(pl_fontRuns *fontRuns,
|
||||
const le_font *font,
|
||||
le_int32 limit);
|
||||
|
||||
/**
|
||||
* Construct a <code>pl_valueRuns</code> object from pre-existing arrays of values
|
||||
* and limit indices.
|
||||
*
|
||||
* @param values is the address of an array of values. This array must remain valid until
|
||||
the <code>pl_valueRuns</code> object is closed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>pl_valueRuns</code> object is closed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_valueRuns * U_EXPORT2
|
||||
pl_openValueRuns(const le_int32 *values,
|
||||
const le_int32 *limits,
|
||||
le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>pl_valueRuns</code> object. Clients can add values and limits
|
||||
* using the <code>pl_addValueRun</code> routine.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the value and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see pl_addValueRun
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_valueRuns * U_EXPORT2
|
||||
pl_openEmptyValueRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* Close the given <code>pl_valueRuns</code> object. Once this
|
||||
* call returns, the object can no longer be referenced.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_closeValueRuns(pl_valueRuns *valueRuns);
|
||||
|
||||
/**
|
||||
* Get the number of value runs.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @return the number of value runs.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getValueRunCount(const pl_valueRuns *valueRuns);
|
||||
|
||||
/**
|
||||
* Reset the number of value runs to zero.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_resetValueRuns(pl_valueRuns *valueRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for the last value run. This is the
|
||||
* number of characters in the text.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @return the last limit index.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getValueRunLastLimit(const pl_valueRuns *valueRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for a particular value run.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
* @param run is the run index.
|
||||
*
|
||||
* @return the limit index for the run, or -1 if <code>run</code> is out of bounds.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getValueRunLimit(const pl_valueRuns *valueRuns,
|
||||
le_int32 run);
|
||||
|
||||
/**
|
||||
* Get the value assoicated with the given run * of text. Use
|
||||
* <code>pl_getValueRunLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
* @param run is the run index.
|
||||
*
|
||||
* @return the value associated with the given text run.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getValueRunValue(const pl_valueRuns *valueRuns,
|
||||
le_int32 run);
|
||||
|
||||
|
||||
/**
|
||||
* Add a new font run to the given <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* If the <code>pl_valueRuns</code> object was not created by calling
|
||||
* <code>pl_openEmptyFontRuns</code>, this method will return a run index of -1.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @param value is the value to add.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the font and limit index were stored, or -1 if
|
||||
* the run cannot be added.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_addValueRun(pl_valueRuns *valueRuns,
|
||||
le_int32 value,
|
||||
le_int32 limit);
|
||||
|
||||
/**
|
||||
* Construct a <code>pl_localeRuns</code> object from pre-existing arrays of fonts
|
||||
* and limit indices.
|
||||
*
|
||||
* @param locales is the address of an array of pointers to locale name strings. This
|
||||
* array must remain valid until the <code>pl_localeRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>pl_valueRuns</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_localeRuns * U_EXPORT2
|
||||
pl_openLocaleRuns(const char **locales,
|
||||
const le_int32 *limits,
|
||||
le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>pl_localeRuns</code> object. Clients can add font and limit
|
||||
* indices arrays using the <code>pl_addFontRun</code> routine.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the font and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see pl_addLocaleRun
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_localeRuns * U_EXPORT2
|
||||
pl_openEmptyLocaleRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* Close the given <code>pl_localeRuns</code> object. Once this
|
||||
* call returns, the object can no longer be referenced.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_closeLocaleRuns(pl_localeRuns *localeRuns);
|
||||
|
||||
/**
|
||||
* Get the number of font runs.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @return the number of entries in the limit indices array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLocaleRunCount(const pl_localeRuns *localeRuns);
|
||||
|
||||
/**
|
||||
* Reset the number of locale runs to zero.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_resetLocaleRuns(pl_localeRuns *localeRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for the last font run. This is the
|
||||
* number of characters in the text.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @return the last limit index.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLocaleRunLastLimit(const pl_localeRuns *localeRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for a particular font run.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
* @param run is the run. This is an index into the limit index array.
|
||||
*
|
||||
* @return the limit index for the run, or -1 if <code>run</code> is out of bounds.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLocaleRunLimit(const pl_localeRuns *localeRuns,
|
||||
le_int32 run);
|
||||
|
||||
/**
|
||||
* Get the <code>le_font</code> object assoicated with the given run
|
||||
* of text. Use <code>pl_getLocaleRunLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the <code>le_font</code> associated with the given text run.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const char * U_EXPORT2
|
||||
pl_getLocaleRunLocale(const pl_localeRuns *localeRuns,
|
||||
le_int32 run);
|
||||
|
||||
|
||||
/**
|
||||
* Add a new run to the given <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* If the <code>pl_localeRuns</code> object was not created by calling
|
||||
* <code>pl_openEmptyLocaleRuns</code>, this method will return a run index of -1.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @param locale is the name of the locale to add. This name must
|
||||
* remain valid until the <code>pl_localeRuns</code> object is closed.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the font and limit index were stored, or -1 if
|
||||
* the run cannot be added.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_addLocaleRun(pl_localeRuns *localeRuns,
|
||||
const char *locale,
|
||||
le_int32 limit);
|
||||
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
#endif
|
||||
Reference in New Issue
Block a user