/*
**********************************************************************
- * Copyright (C) 2002-2003, International Business Machines
+ * Copyright (C) 2002-2014, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#define __PARAGRAPHLAYOUT_H
+/**
+ * \file
+ * \brief C++ API: Paragraph Layout
+ */
+
/*
* ParagraphLayout doesn't make much sense without
* BreakIterator...
*
* Clients can use this to break a paragraph into lines, and to display the glyphs in each line.
*
+ * Note that {@link icu::LayoutEngine} is deprecated, but this class is not.
+ * You may use this class with the HarfBuzz icu-le-hb wrapper,
+ * see http://www.freedesktop.org/wiki/Software/HarfBuzz/
+ *
+ * See http://userguide.icu-project.org/layoutengine for special build instructions.
+ *
+ * @see icu::LayoutEngine
*/
class U_LAYOUTEX_API ParagraphLayout : public UObject
{
* @see ParagraphLayout
* @see ParagraphLayout::VisualRun
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
class U_LAYOUTEX_API Line : public UObject
{
* clients responsibility to destroy the objects, so the destructor
* is public.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
~Line();
*
* @return the number of visual runs.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- le_int32 countRuns() const;
+ inline le_int32 countRuns() const;
/**
* Get the ascent of the line. This is the maximum ascent
*
* @return the ascent of the line.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
le_int32 getAscent() const;
*
* @return the descent of the line.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
le_int32 getDescent() const;
*
* @return the leading of the line.
*
- * @draft ICU 2.6
+ * @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
*
* @see ParagraphLayout::VisualRun
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
const VisualRun *getVisualRun(le_int32 runIndex) const;
/**
- * ICU "poor man's RTTI", returns a UClassID for the actual class.
+ * ICU "poor man's RTTI", returns a UClassID for this class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
+ static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
/**
- * ICU "poor man's RTTI", returns a UClassID for this class.
+ * ICU "poor man's RTTI", returns a UClassID for the actual class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
+ virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
private:
VisualRun **fRuns;
- Line();
- Line(const Line &other);
- Line &operator=(const Line & /*other*/) { return *this; };
+ inline Line();
+ inline Line(const Line &other);
+ inline Line &operator=(const Line & /*other*/) { return *this; };
void computeMetrics();
* 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,
+ * These objects are only created by <code>ParagraphLayout::Line</code> objects,
* so their constructors and destructors are private.
*
* @see ParagraphLayout::Line
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
class U_LAYOUTEX_API VisualRun : public UObject
{
*
* @see LEFontInstance
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- const LEFontInstance *getFont() const;
+ 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.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- UBiDiDirection getDirection() const;
+ inline UBiDiDirection getDirection() const;
/**
* Get the number of glyphs in the visual run.
*
* @return the number of glyphs.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- le_int32 getGlyphCount() const;
+ inline le_int32 getGlyphCount() const;
/**
* Get the glyphs in the visual run. Glyphs with the values <code>0xFFFE</code> and
* 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.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- const LEGlyphID *getGlyphs() const;
+ inline const LEGlyphID *getGlyphs() const;
/**
* Get the (x, y) positions of the glyphs in the visual run. To simplify 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.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- const float *getPositions() const;
+ inline const float *getPositions() const;
/**
* Get the glyph-to-character map for this visual run. This maps the indices into
* 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.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- const le_int32 *getGlyphToCharMap() const;
+ inline const le_int32 *getGlyphToCharMap() const;
/**
* A convenience method which returns the ascent value for the font
*
* @return the ascent value of this run's font.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- le_int32 getAscent() const;
+ inline le_int32 getAscent() const;
/**
* A convenience method which returns the descent value for the font
*
* @return the descent value of this run's font.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- le_int32 getDescent() const;
+ inline le_int32 getDescent() const;
/**
* A convenience method which returns the leading value for the font
*
* @return the leading value of this run's font.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- le_int32 getLeading() const;
+ inline le_int32 getLeading() const;
/**
- * ICU "poor man's RTTI", returns a UClassID for the actual class.
+ * ICU "poor man's RTTI", returns a UClassID for this class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
+ static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
/**
- * ICU "poor man's RTTI", returns a UClassID for this class.
+ * ICU "poor man's RTTI", returns a UClassID for the actual class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
+ virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
private:
friend class Line;
- VisualRun();
- VisualRun(const VisualRun &other);
- VisualRun &operator=(const VisualRun &other) { return *this; };
+ inline VisualRun();
+ inline VisualRun(const VisualRun &other);
+ inline VisualRun &operator=(const VisualRun &/*other*/) { return *this; };
- VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
+ inline VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
~VisualRun();
* 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 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 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
*
- * @draft ICU 2.6
+ * @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);
+ UBiDiLevel paragraphLevel, le_bool vertical,
+ LEErrorCode &status);
/**
* The destructor. Virtual so that it works correctly with
* sublcasses.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
~ParagraphLayout();
*
* @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.
+ * @return <code>TRUE</code> if the paragraph contains complex text.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
static le_bool isComplex(const LEUnicode chars[], le_int32 count, const FontRuns *fontRuns);
#else
*
* @param count is the number of characters in the paragraph.
*
- * @return <code>true</code> if any of the text requires complex processing.
+ * @return <code>TRUE</code> if any of the text requires complex processing.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
static le_bool isComplex(const LEUnicode chars[], le_int32 count);
*
* @return the resolved paragraph level.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- UBiDiLevel getParagraphLevel();
+ inline UBiDiLevel getParagraphLevel();
/**
* Return the directionality of the text in the paragraph.
* <code>UBIDI_RTL</code> if the text is all right to left,
* or <code>UBIDI_MIXED</code> if the text has mixed direction.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- UBiDiDirection getTextDirection();
+ inline UBiDiDirection getTextDirection();
/**
* Return the max ascent value for all the fonts
*
* @return the ascent value.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
virtual le_int32 getAscent() const;
*
* @return the decent value.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
virtual le_int32 getDescent() const;
*
* @return the leading value.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
virtual le_int32 getLeading() const;
* Reset line breaking to start from the beginning of the paragraph.
*
*
- * @draft ICU 2.6
+ * @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
*/
- void reflow();
+ inline le_bool isDone() const;
+#endif /* U_HIDE_INTERNAL_API */
/**
* Return a <code>ParagraphLayout::Line</code> object which represents next line
*
* @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.
+ * more lines in the paragraph.
*
* @see ParagraphLayout::Line
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
Line *nextLine(float width);
/**
- * ICU "poor man's RTTI", returns a UClassID for the actual class.
+ * ICU "poor man's RTTI", returns a UClassID for this class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
+ static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
/**
- * ICU "poor man's RTTI", returns a UClassID for this class.
+ * ICU "poor man's RTTI", returns a UClassID for the actual class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
+ virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
private:
ParagraphLayout() {};
ParagraphLayout(const ParagraphLayout & /*other*/) : UObject( ){};
- ParagraphLayout &operator=(const ParagraphLayout & /*other*/) { return *this; };
+ inline ParagraphLayout &operator=(const ParagraphLayout & /*other*/) { return *this; };
void computeLevels(UBiDiLevel paragraphLevel);
void computeLocales();
- void computeSubFonts(const FontRuns *fontRuns);
+ void computeSubFonts(const FontRuns *fontRuns, LEErrorCode &status);
void computeMetrics();
le_int32 fLeading;
le_int32 *fGlyphToCharMap;
- le_int32 *fCharToGlyphMap;
+ le_int32 *fCharToMinGlyphMap;
+ le_int32 *fCharToMaxGlyphMap;
float *fGlyphWidths;
le_int32 fGlyphCount;
// nothing
}
-inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &other)
+inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &/*other*/)
: UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
{
// nothing
// nothing else needs to be done!
}
-inline ParagraphLayout::VisualRun::~VisualRun()
-{
- LE_DELETE_ARRAY(fGlyphToCharMap);
- LE_DELETE_ARRAY(fPositions);
- LE_DELETE_ARRAY(fGlyphs);
-}
-
U_NAMESPACE_END
#endif
#endif