/usr/include/x86_64-linux-gnu/layout/ParagraphLayout.h is in libicu-dev 55.1-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | /*
**********************************************************************
* Copyright (C) 2002-2014, 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.
*
* 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
{
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
|