mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r26018) -Codechange: since there's a wrapper for ICU functions now, we can use proper coding style for names again
This commit is contained in:
parent
ddc0026712
commit
4c5ccc8b94
26
src/gfx.cpp
26
src/gfx.cpp
@ -341,10 +341,10 @@ static void SetColourRemap(TextColour colour)
|
|||||||
*/
|
*/
|
||||||
static int DrawLayoutLine(const ParagraphLayouter::Line *line, int y, int left, int right, StringAlignment align, bool underline, bool truncation)
|
static int DrawLayoutLine(const ParagraphLayouter::Line *line, int y, int left, int right, StringAlignment align, bool underline, bool truncation)
|
||||||
{
|
{
|
||||||
if (line->countRuns() == 0) return 0;
|
if (line->CountRuns() == 0) return 0;
|
||||||
|
|
||||||
int w = line->getWidth();
|
int w = line->GetWidth();
|
||||||
int h = line->getLeading();
|
int h = line->GetLeading();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following is needed for truncation.
|
* The following is needed for truncation.
|
||||||
@ -375,7 +375,7 @@ static int DrawLayoutLine(const ParagraphLayouter::Line *line, int y, int left,
|
|||||||
* another size would be chosen it won't have truncated too little for
|
* another size would be chosen it won't have truncated too little for
|
||||||
* the truncation dots.
|
* the truncation dots.
|
||||||
*/
|
*/
|
||||||
FontCache *fc = ((const Font*)line->getVisualRun(0)->getFont())->fc;
|
FontCache *fc = ((const Font*)line->GetVisualRun(0)->GetFont())->fc;
|
||||||
GlyphID dot_glyph = fc->MapCharToGlyph('.');
|
GlyphID dot_glyph = fc->MapCharToGlyph('.');
|
||||||
dot_width = fc->GetGlyphWidth(dot_glyph);
|
dot_width = fc->GetGlyphWidth(dot_glyph);
|
||||||
dot_sprite = fc->GetGlyph(dot_glyph);
|
dot_sprite = fc->GetGlyph(dot_glyph);
|
||||||
@ -418,9 +418,9 @@ static int DrawLayoutLine(const ParagraphLayouter::Line *line, int y, int left,
|
|||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int run_index = 0; run_index < line->countRuns(); run_index++) {
|
for (int run_index = 0; run_index < line->CountRuns(); run_index++) {
|
||||||
const ParagraphLayouter::VisualRun *run = line->getVisualRun(run_index);
|
const ParagraphLayouter::VisualRun *run = line->GetVisualRun(run_index);
|
||||||
const Font *f = (const Font*)run->getFont();
|
const Font *f = (const Font*)run->GetFont();
|
||||||
|
|
||||||
FontCache *fc = f->fc;
|
FontCache *fc = f->fc;
|
||||||
TextColour colour = f->colour;
|
TextColour colour = f->colour;
|
||||||
@ -432,15 +432,15 @@ static int DrawLayoutLine(const ParagraphLayouter::Line *line, int y, int left,
|
|||||||
|
|
||||||
bool draw_shadow = fc->GetDrawGlyphShadow() && colour != TC_BLACK;
|
bool draw_shadow = fc->GetDrawGlyphShadow() && colour != TC_BLACK;
|
||||||
|
|
||||||
for (int i = 0; i < run->getGlyphCount(); i++) {
|
for (int i = 0; i < run->GetGlyphCount(); i++) {
|
||||||
GlyphID glyph = run->getGlyphs()[i];
|
GlyphID glyph = run->GetGlyphs()[i];
|
||||||
|
|
||||||
/* Not a valid glyph (empty) */
|
/* Not a valid glyph (empty) */
|
||||||
if (glyph == 0xFFFF) continue;
|
if (glyph == 0xFFFF) continue;
|
||||||
|
|
||||||
int begin_x = (int)run->getPositions()[i * 2] + left - offset_x;
|
int begin_x = (int)run->GetPositions()[i * 2] + left - offset_x;
|
||||||
int end_x = (int)run->getPositions()[i * 2 + 2] + left - offset_x - 1;
|
int end_x = (int)run->GetPositions()[i * 2 + 2] + left - offset_x - 1;
|
||||||
int top = (int)run->getPositions()[i * 2 + 1] + y;
|
int top = (int)run->GetPositions()[i * 2 + 1] + y;
|
||||||
|
|
||||||
/* Truncated away. */
|
/* Truncated away. */
|
||||||
if (truncation && (begin_x < min_x || end_x > max_x)) continue;
|
if (truncation && (begin_x < min_x || end_x > max_x)) continue;
|
||||||
@ -643,7 +643,7 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, const char *st
|
|||||||
for (const ParagraphLayouter::Line **iter = layout.Begin(); iter != layout.End(); iter++) {
|
for (const ParagraphLayouter::Line **iter = layout.Begin(); iter != layout.End(); iter++) {
|
||||||
const ParagraphLayouter::Line *line = *iter;
|
const ParagraphLayouter::Line *line = *iter;
|
||||||
|
|
||||||
int line_height = line->getLeading();
|
int line_height = line->GetLeading();
|
||||||
if (y >= top && y < bottom) {
|
if (y >= top && y < bottom) {
|
||||||
last_line = y + line_height;
|
last_line = y + line_height;
|
||||||
if (first_line > y) first_line = y;
|
if (first_line > y) first_line = y;
|
||||||
|
@ -138,12 +138,12 @@ public:
|
|||||||
public:
|
public:
|
||||||
ICUVisualRun(const ParagraphLayout::VisualRun *vr) : vr(vr) { }
|
ICUVisualRun(const ParagraphLayout::VisualRun *vr) : vr(vr) { }
|
||||||
|
|
||||||
const Font *getFont() const { return (const Font*)vr->getFont(); }
|
const Font *GetFont() const { return (const Font*)vr->getFont(); }
|
||||||
int getGlyphCount() const { return vr->getGlyphCount(); }
|
int GetGlyphCount() const { return vr->getGlyphCount(); }
|
||||||
const GlyphID *getGlyphs() const { return vr->getGlyphs(); }
|
const GlyphID *GetGlyphs() const { return vr->getGlyphs(); }
|
||||||
const float *getPositions() const { return vr->getPositions(); }
|
const float *GetPositions() const { return vr->getPositions(); }
|
||||||
int getLeading() const { return vr->getLeading(); }
|
int GetLeading() const { return vr->getLeading(); }
|
||||||
const int *getGlyphToCharMap() const { return vr->getGlyphToCharMap(); }
|
const int *GetGlyphToCharMap() const { return vr->getGlyphToCharMap(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A single line worth of VisualRuns. */
|
/** A single line worth of VisualRuns. */
|
||||||
@ -159,17 +159,17 @@ public:
|
|||||||
}
|
}
|
||||||
~ICULine() { delete l; }
|
~ICULine() { delete l; }
|
||||||
|
|
||||||
int getLeading() const { return l->getLeading(); }
|
int GetLeading() const { return l->getLeading(); }
|
||||||
int getWidth() const { return l->getWidth(); }
|
int GetWidth() const { return l->getWidth(); }
|
||||||
int countRuns() const { return l->countRuns(); }
|
int CountRuns() const { return l->countRuns(); }
|
||||||
const ParagraphLayouter::VisualRun *getVisualRun(int run) const { return *this->Get(run); }
|
const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return *this->Get(run); }
|
||||||
};
|
};
|
||||||
|
|
||||||
ICUParagraphLayout(ParagraphLayout *p) : p(p) { }
|
ICUParagraphLayout(ParagraphLayout *p) : p(p) { }
|
||||||
~ICUParagraphLayout() { delete p; }
|
~ICUParagraphLayout() { delete p; }
|
||||||
void reflow() { p->reflow(); }
|
void Reflow() { p->reflow(); }
|
||||||
|
|
||||||
ParagraphLayouter::Line *nextLine(int max_width)
|
ParagraphLayouter::Line *NextLine(int max_width)
|
||||||
{
|
{
|
||||||
ParagraphLayout::Line *l = p->nextLine(max_width);
|
ParagraphLayout::Line *l = p->nextLine(max_width);
|
||||||
return l == NULL ? NULL : new ICULine(l);
|
return l == NULL ? NULL : new ICULine(l);
|
||||||
@ -244,21 +244,21 @@ public:
|
|||||||
public:
|
public:
|
||||||
FallbackVisualRun(Font *font, const WChar *chars, int glyph_count, int x);
|
FallbackVisualRun(Font *font, const WChar *chars, int glyph_count, int x);
|
||||||
~FallbackVisualRun();
|
~FallbackVisualRun();
|
||||||
const Font *getFont() const;
|
const Font *GetFont() const;
|
||||||
int getGlyphCount() const;
|
int GetGlyphCount() const;
|
||||||
const GlyphID *getGlyphs() const;
|
const GlyphID *GetGlyphs() const;
|
||||||
const float *getPositions() const;
|
const float *GetPositions() const;
|
||||||
int getLeading() const;
|
int GetLeading() const;
|
||||||
const int *getGlyphToCharMap() const;
|
const int *GetGlyphToCharMap() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A single line worth of VisualRuns. */
|
/** A single line worth of VisualRuns. */
|
||||||
class FallbackLine : public AutoDeleteSmallVector<FallbackVisualRun *, 4>, public ParagraphLayouter::Line {
|
class FallbackLine : public AutoDeleteSmallVector<FallbackVisualRun *, 4>, public ParagraphLayouter::Line {
|
||||||
public:
|
public:
|
||||||
int getLeading() const;
|
int GetLeading() const;
|
||||||
int getWidth() const;
|
int GetWidth() const;
|
||||||
int countRuns() const;
|
int CountRuns() const;
|
||||||
const ParagraphLayouter::VisualRun *getVisualRun(int run) const;
|
const ParagraphLayouter::VisualRun *GetVisualRun(int run) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
const WChar *buffer_begin; ///< Begin of the buffer.
|
const WChar *buffer_begin; ///< Begin of the buffer.
|
||||||
@ -266,8 +266,8 @@ public:
|
|||||||
FontMap &runs; ///< The fonts we have to use for this paragraph.
|
FontMap &runs; ///< The fonts we have to use for this paragraph.
|
||||||
|
|
||||||
FallbackParagraphLayout(WChar *buffer, int length, FontMap &runs);
|
FallbackParagraphLayout(WChar *buffer, int length, FontMap &runs);
|
||||||
void reflow();
|
void Reflow();
|
||||||
const ParagraphLayouter::Line *nextLine(int max_width);
|
const ParagraphLayouter::Line *NextLine(int max_width);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -308,7 +308,7 @@ FallbackParagraphLayout::FallbackVisualRun::~FallbackVisualRun()
|
|||||||
* Get the font associated with this run.
|
* Get the font associated with this run.
|
||||||
* @return The font.
|
* @return The font.
|
||||||
*/
|
*/
|
||||||
const Font *FallbackParagraphLayout::FallbackVisualRun::getFont() const
|
const Font *FallbackParagraphLayout::FallbackVisualRun::GetFont() const
|
||||||
{
|
{
|
||||||
return this->font;
|
return this->font;
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ const Font *FallbackParagraphLayout::FallbackVisualRun::getFont() const
|
|||||||
* Get the number of glyphs in this run.
|
* Get the number of glyphs in this run.
|
||||||
* @return The number of glyphs.
|
* @return The number of glyphs.
|
||||||
*/
|
*/
|
||||||
int FallbackParagraphLayout::FallbackVisualRun::getGlyphCount() const
|
int FallbackParagraphLayout::FallbackVisualRun::GetGlyphCount() const
|
||||||
{
|
{
|
||||||
return this->glyph_count;
|
return this->glyph_count;
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ int FallbackParagraphLayout::FallbackVisualRun::getGlyphCount() const
|
|||||||
* Get the glyphs of this run.
|
* Get the glyphs of this run.
|
||||||
* @return The glyphs.
|
* @return The glyphs.
|
||||||
*/
|
*/
|
||||||
const GlyphID *FallbackParagraphLayout::FallbackVisualRun::getGlyphs() const
|
const GlyphID *FallbackParagraphLayout::FallbackVisualRun::GetGlyphs() const
|
||||||
{
|
{
|
||||||
return this->glyphs;
|
return this->glyphs;
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ const GlyphID *FallbackParagraphLayout::FallbackVisualRun::getGlyphs() const
|
|||||||
* Get the positions of this run.
|
* Get the positions of this run.
|
||||||
* @return The positions.
|
* @return The positions.
|
||||||
*/
|
*/
|
||||||
const float *FallbackParagraphLayout::FallbackVisualRun::getPositions() const
|
const float *FallbackParagraphLayout::FallbackVisualRun::GetPositions() const
|
||||||
{
|
{
|
||||||
return this->positions;
|
return this->positions;
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ const float *FallbackParagraphLayout::FallbackVisualRun::getPositions() const
|
|||||||
* Get the glyph-to-character map for this visual run.
|
* Get the glyph-to-character map for this visual run.
|
||||||
* @return The glyph-to-character map.
|
* @return The glyph-to-character map.
|
||||||
*/
|
*/
|
||||||
const int *FallbackParagraphLayout::FallbackVisualRun::getGlyphToCharMap() const
|
const int *FallbackParagraphLayout::FallbackVisualRun::GetGlyphToCharMap() const
|
||||||
{
|
{
|
||||||
return this->glyph_to_char;
|
return this->glyph_to_char;
|
||||||
}
|
}
|
||||||
@ -353,20 +353,20 @@ const int *FallbackParagraphLayout::FallbackVisualRun::getGlyphToCharMap() const
|
|||||||
* Get the height of this font.
|
* Get the height of this font.
|
||||||
* @return The height of the font.
|
* @return The height of the font.
|
||||||
*/
|
*/
|
||||||
int FallbackParagraphLayout::FallbackVisualRun::getLeading() const
|
int FallbackParagraphLayout::FallbackVisualRun::GetLeading() const
|
||||||
{
|
{
|
||||||
return this->getFont()->fc->GetHeight();
|
return this->GetFont()->fc->GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the height of the line.
|
* Get the height of the line.
|
||||||
* @return The maximum height of the line.
|
* @return The maximum height of the line.
|
||||||
*/
|
*/
|
||||||
int FallbackParagraphLayout::FallbackLine::getLeading() const
|
int FallbackParagraphLayout::FallbackLine::GetLeading() const
|
||||||
{
|
{
|
||||||
int leading = 0;
|
int leading = 0;
|
||||||
for (const FallbackVisualRun * const *run = this->Begin(); run != this->End(); run++) {
|
for (const FallbackVisualRun * const *run = this->Begin(); run != this->End(); run++) {
|
||||||
leading = max(leading, (*run)->getLeading());
|
leading = max(leading, (*run)->GetLeading());
|
||||||
}
|
}
|
||||||
|
|
||||||
return leading;
|
return leading;
|
||||||
@ -376,7 +376,7 @@ int FallbackParagraphLayout::FallbackLine::getLeading() const
|
|||||||
* Get the width of this line.
|
* Get the width of this line.
|
||||||
* @return The width of the line.
|
* @return The width of the line.
|
||||||
*/
|
*/
|
||||||
int FallbackParagraphLayout::FallbackLine::getWidth() const
|
int FallbackParagraphLayout::FallbackLine::GetWidth() const
|
||||||
{
|
{
|
||||||
if (this->Length() == 0) return 0;
|
if (this->Length() == 0) return 0;
|
||||||
|
|
||||||
@ -385,15 +385,15 @@ int FallbackParagraphLayout::FallbackLine::getWidth() const
|
|||||||
* Since there is no left-to-right support, taking this value of
|
* Since there is no left-to-right support, taking this value of
|
||||||
* the last run gives us the end of the line and thus the width.
|
* the last run gives us the end of the line and thus the width.
|
||||||
*/
|
*/
|
||||||
const ParagraphLayouter::VisualRun *run = this->getVisualRun(this->countRuns() - 1);
|
const ParagraphLayouter::VisualRun *run = this->GetVisualRun(this->CountRuns() - 1);
|
||||||
return (int)run->getPositions()[run->getGlyphCount() * 2];
|
return (int)run->GetPositions()[run->GetGlyphCount() * 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of runs in this line.
|
* Get the number of runs in this line.
|
||||||
* @return The number of runs.
|
* @return The number of runs.
|
||||||
*/
|
*/
|
||||||
int FallbackParagraphLayout::FallbackLine::countRuns() const
|
int FallbackParagraphLayout::FallbackLine::CountRuns() const
|
||||||
{
|
{
|
||||||
return this->Length();
|
return this->Length();
|
||||||
}
|
}
|
||||||
@ -402,7 +402,7 @@ int FallbackParagraphLayout::FallbackLine::countRuns() const
|
|||||||
* Get a specific visual run.
|
* Get a specific visual run.
|
||||||
* @return The visual run.
|
* @return The visual run.
|
||||||
*/
|
*/
|
||||||
const ParagraphLayouter::VisualRun *FallbackParagraphLayout::FallbackLine::getVisualRun(int run) const
|
const ParagraphLayouter::VisualRun *FallbackParagraphLayout::FallbackLine::GetVisualRun(int run) const
|
||||||
{
|
{
|
||||||
return *this->Get(run);
|
return *this->Get(run);
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ FallbackParagraphLayout::FallbackParagraphLayout(WChar *buffer, int length, Font
|
|||||||
/**
|
/**
|
||||||
* Reset the position to the start of the paragraph.
|
* Reset the position to the start of the paragraph.
|
||||||
*/
|
*/
|
||||||
void FallbackParagraphLayout::reflow()
|
void FallbackParagraphLayout::Reflow()
|
||||||
{
|
{
|
||||||
this->buffer = this->buffer_begin;
|
this->buffer = this->buffer_begin;
|
||||||
}
|
}
|
||||||
@ -431,7 +431,7 @@ void FallbackParagraphLayout::reflow()
|
|||||||
* @param max_width The maximum width of the string.
|
* @param max_width The maximum width of the string.
|
||||||
* @return A Line, or NULL when at the end of the paragraph.
|
* @return A Line, or NULL when at the end of the paragraph.
|
||||||
*/
|
*/
|
||||||
const ParagraphLayouter::Line *FallbackParagraphLayout::nextLine(int max_width)
|
const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width)
|
||||||
{
|
{
|
||||||
/* Simple idea:
|
/* Simple idea:
|
||||||
* - split a line at a newline character, or at a space where we can break a line.
|
* - split a line at a newline character, or at a space where we can break a line.
|
||||||
@ -473,7 +473,7 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::nextLine(int max_width)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->buffer == next_run) {
|
if (this->buffer == next_run) {
|
||||||
int w = l->getWidth();
|
int w = l->GetWidth();
|
||||||
*l->Append() = new FallbackVisualRun(iter->second, begin, this->buffer - begin, w);
|
*l->Append() = new FallbackVisualRun(iter->second, begin, this->buffer - begin, w);
|
||||||
iter++;
|
iter++;
|
||||||
assert(iter != this->runs.End());
|
assert(iter != this->runs.End());
|
||||||
@ -520,7 +520,7 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::nextLine(int max_width)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (l->Length() == 0 || last_char - begin != 0) {
|
if (l->Length() == 0 || last_char - begin != 0) {
|
||||||
int w = l->getWidth();
|
int w = l->GetWidth();
|
||||||
*l->Append() = new FallbackVisualRun(iter->second, begin, last_char - begin, w);
|
*l->Append() = new FallbackVisualRun(iter->second, begin, last_char - begin, w);
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
@ -641,7 +641,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
|
|||||||
/* Line is in cache */
|
/* Line is in cache */
|
||||||
str = lineend + 1;
|
str = lineend + 1;
|
||||||
state = line.state_after;
|
state = line.state_after;
|
||||||
line.layout->reflow();
|
line.layout->Reflow();
|
||||||
} else {
|
} else {
|
||||||
/* Line is new, layout it */
|
/* Line is new, layout it */
|
||||||
#ifdef WITH_ICU
|
#ifdef WITH_ICU
|
||||||
@ -661,7 +661,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
|
|||||||
|
|
||||||
/* Copy all lines into a local cache so we can reuse them later on more easily. */
|
/* Copy all lines into a local cache so we can reuse them later on more easily. */
|
||||||
const ParagraphLayouter::Line *l;
|
const ParagraphLayouter::Line *l;
|
||||||
while ((l = line.layout->nextLine(maxw)) != NULL) {
|
while ((l = line.layout->NextLine(maxw)) != NULL) {
|
||||||
*this->Append() = l;
|
*this->Append() = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,8 +676,8 @@ Dimension Layouter::GetBounds()
|
|||||||
{
|
{
|
||||||
Dimension d = { 0, 0 };
|
Dimension d = { 0, 0 };
|
||||||
for (const ParagraphLayouter::Line **l = this->Begin(); l != this->End(); l++) {
|
for (const ParagraphLayouter::Line **l = this->Begin(); l != this->End(); l++) {
|
||||||
d.width = max<uint>(d.width, (*l)->getWidth());
|
d.width = max<uint>(d.width, (*l)->GetWidth());
|
||||||
d.height += (*l)->getLeading();
|
d.height += (*l)->GetLeading();
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@ -713,18 +713,18 @@ Point Layouter::GetCharPosition(const char *ch) const
|
|||||||
|
|
||||||
/* Pointer to the end-of-string/line marker? Return total line width. */
|
/* Pointer to the end-of-string/line marker? Return total line width. */
|
||||||
if (*ch == '\0' || *ch == '\n') {
|
if (*ch == '\0' || *ch == '\n') {
|
||||||
Point p = { line->getWidth(), 0 };
|
Point p = { line->GetWidth(), 0 };
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scan all runs until we've found our code point index. */
|
/* Scan all runs until we've found our code point index. */
|
||||||
for (int run_index = 0; run_index < line->countRuns(); run_index++) {
|
for (int run_index = 0; run_index < line->CountRuns(); run_index++) {
|
||||||
const ParagraphLayouter::VisualRun *run = line->getVisualRun(run_index);
|
const ParagraphLayouter::VisualRun *run = line->GetVisualRun(run_index);
|
||||||
|
|
||||||
for (int i = 0; i < run->getGlyphCount(); i++) {
|
for (int i = 0; i < run->GetGlyphCount(); i++) {
|
||||||
/* Matching glyph? Return position. */
|
/* Matching glyph? Return position. */
|
||||||
if ((size_t)run->getGlyphToCharMap()[i] == index) {
|
if ((size_t)run->GetGlyphToCharMap()[i] == index) {
|
||||||
Point p = { (int)run->getPositions()[i * 2], (int)run->getPositions()[i * 2 + 1] };
|
Point p = { (int)run->GetPositions()[i * 2], (int)run->GetPositions()[i * 2 + 1] };
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -742,21 +742,21 @@ Point Layouter::GetCharPosition(const char *ch) const
|
|||||||
*/
|
*/
|
||||||
const char *Layouter::GetCharAtPosition(int x) const
|
const char *Layouter::GetCharAtPosition(int x) const
|
||||||
{
|
{
|
||||||
const ParagraphLayouter::Line *line = *this->Begin();;
|
const ParagraphLayouter::Line *line = *this->Begin();
|
||||||
|
|
||||||
for (int run_index = 0; run_index < line->countRuns(); run_index++) {
|
for (int run_index = 0; run_index < line->CountRuns(); run_index++) {
|
||||||
const ParagraphLayouter::VisualRun *run = line->getVisualRun(run_index);
|
const ParagraphLayouter::VisualRun *run = line->GetVisualRun(run_index);
|
||||||
|
|
||||||
for (int i = 0; i < run->getGlyphCount(); i++) {
|
for (int i = 0; i < run->GetGlyphCount(); i++) {
|
||||||
/* Not a valid glyph (empty). */
|
/* Not a valid glyph (empty). */
|
||||||
if (run->getGlyphs()[i] == 0xFFFF) continue;
|
if (run->GetGlyphs()[i] == 0xFFFF) continue;
|
||||||
|
|
||||||
int begin_x = (int)run->getPositions()[i * 2];
|
int begin_x = (int)run->GetPositions()[i * 2];
|
||||||
int end_x = (int)run->getPositions()[i * 2 + 2];
|
int end_x = (int)run->GetPositions()[i * 2 + 2];
|
||||||
|
|
||||||
if (IsInsideMM(x, begin_x, end_x)) {
|
if (IsInsideMM(x, begin_x, end_x)) {
|
||||||
/* Found our glyph, now convert to UTF-8 string index. */
|
/* Found our glyph, now convert to UTF-8 string index. */
|
||||||
size_t index = run->getGlyphToCharMap()[i];
|
size_t index = run->GetGlyphToCharMap()[i];
|
||||||
|
|
||||||
size_t cur_idx = 0;
|
size_t cur_idx = 0;
|
||||||
for (const char *str = this->string; *str != '\0'; ) {
|
for (const char *str = this->string; *str != '\0'; ) {
|
||||||
|
@ -108,26 +108,26 @@ public:
|
|||||||
class VisualRun {
|
class VisualRun {
|
||||||
public:
|
public:
|
||||||
virtual ~VisualRun() {}
|
virtual ~VisualRun() {}
|
||||||
virtual const Font *getFont() const = 0;
|
virtual const Font *GetFont() const = 0;
|
||||||
virtual int getGlyphCount() const = 0;
|
virtual int GetGlyphCount() const = 0;
|
||||||
virtual const GlyphID *getGlyphs() const = 0;
|
virtual const GlyphID *GetGlyphs() const = 0;
|
||||||
virtual const float *getPositions() const = 0;
|
virtual const float *GetPositions() const = 0;
|
||||||
virtual int getLeading() const = 0;
|
virtual int GetLeading() const = 0;
|
||||||
virtual const int *getGlyphToCharMap() const = 0;
|
virtual const int *GetGlyphToCharMap() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A single line worth of VisualRuns. */
|
/** A single line worth of VisualRuns. */
|
||||||
class Line {
|
class Line {
|
||||||
public:
|
public:
|
||||||
virtual ~Line() {}
|
virtual ~Line() {}
|
||||||
virtual int getLeading() const = 0;
|
virtual int GetLeading() const = 0;
|
||||||
virtual int getWidth() const = 0;
|
virtual int GetWidth() const = 0;
|
||||||
virtual int countRuns() const = 0;
|
virtual int CountRuns() const = 0;
|
||||||
virtual const VisualRun *getVisualRun(int run) const = 0;
|
virtual const VisualRun *GetVisualRun(int run) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void reflow() = 0;
|
virtual void Reflow() = 0;
|
||||||
virtual const Line *nextLine(int max_width) = 0;
|
virtual const Line *NextLine(int max_width) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user