Merge branch 'master' into jgrpp
# Conflicts: # regression/regression/result.txt # src/aircraft_cmd.cpp # src/airport_gui.cpp # src/articulated_vehicles.cpp # src/console_cmds.cpp # src/date_gui.cpp # src/engine.cpp # src/genworld_gui.cpp # src/gfx_layout_fallback.cpp # src/group_gui.cpp # src/hotkeys.cpp # src/network/core/tcp_connect.cpp # src/network/core/tcp_listen.h # src/newgrf.cpp # src/newgrf.h # src/newgrf_engine.cpp # src/newgrf_gui.cpp # src/newgrf_station.cpp # src/openttd.cpp # src/order_gui.cpp # src/os/macosx/osx_main.cpp # src/pathfinder/yapf/yapf_node_rail.hpp # src/rail_gui.cpp # src/saveload/afterload.cpp # src/saveload/cargopacket_sl.cpp # src/saveload/linkgraph_sl.cpp # src/saveload/station_sl.cpp # src/script/api/script_industrytype.cpp # src/settings.cpp # src/settings_gui.cpp # src/settings_table.cpp # src/settingsgen/settingsgen.cpp # src/station.cpp # src/station_cmd.cpp # src/strings.cpp # src/timer/timer_game_calendar.cpp # src/timer/timer_game_calendar.h # src/timer/timer_manager.h # src/timer/timer_window.cpp # src/timetable_cmd.cpp # src/toolbar_gui.cpp # src/town_cmd.cpp # src/town_gui.cpp # src/train_gui.cpp # src/vehicle_cmd.h # src/vehicle_gui.cpp # src/viewport.cpp # src/widgets/dropdown.cpp # src/window_func.h # src/window_gui.h
This commit is contained in:
@@ -39,22 +39,20 @@ class FallbackParagraphLayout : public ParagraphLayouter {
|
||||
public:
|
||||
/** Visual run contains data about the bit of text with the same font. */
|
||||
class FallbackVisualRun : public ParagraphLayouter::VisualRun {
|
||||
std::vector<GlyphID> glyphs; ///< The glyphs we're drawing.
|
||||
std::vector<float> positions; ///< The positions of the glyphs.
|
||||
std::vector<int> glyph_to_char; ///< The char index of the glyphs.
|
||||
|
||||
Font *font; ///< The font used to layout these.
|
||||
GlyphID *glyphs; ///< The glyphs we're drawing.
|
||||
float *positions; ///< The positions of the glyphs.
|
||||
int *glyph_to_char; ///< The char index of the glyphs.
|
||||
int glyph_count; ///< The number of glyphs.
|
||||
|
||||
public:
|
||||
FallbackVisualRun(Font *font, const WChar *chars, int glyph_count, int char_offset, int x);
|
||||
FallbackVisualRun(FallbackVisualRun &&other) noexcept;
|
||||
~FallbackVisualRun() override;
|
||||
const Font *GetFont() const override;
|
||||
int GetGlyphCount() const override;
|
||||
const GlyphID *GetGlyphs() const override;
|
||||
const float *GetPositions() const override;
|
||||
int GetLeading() const override;
|
||||
const int *GetGlyphToCharMap() const override;
|
||||
FallbackVisualRun(Font *font, const char32_t *chars, int glyph_count, int char_offset, int x);
|
||||
const Font *GetFont() const override { return this->font; }
|
||||
int GetGlyphCount() const override { return static_cast<int>(this->glyphs.size()); }
|
||||
const GlyphID *GetGlyphs() const override { return this->glyphs.data(); }
|
||||
const float *GetPositions() const override { return this->positions.data(); }
|
||||
int GetLeading() const override { return this->GetFont()->fc->GetHeight(); }
|
||||
const int *GetGlyphToCharMap() const override { return this->glyph_to_char.data(); }
|
||||
};
|
||||
|
||||
/** A single line worth of VisualRuns. */
|
||||
@@ -111,20 +109,20 @@ public:
|
||||
* @param char_offset This run's offset from the start of the layout input string.
|
||||
* @param x The initial x position for this run.
|
||||
*/
|
||||
FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(Font *font, const WChar *chars, int char_count, int char_offset, int x) :
|
||||
font(font), glyph_count(char_count)
|
||||
FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(Font *font, const char32_t *chars, int char_count, int char_offset, int x) :
|
||||
font(font)
|
||||
{
|
||||
const bool isbuiltin = font->fc->IsBuiltInFont();
|
||||
|
||||
this->glyphs = MallocT<GlyphID>(this->glyph_count);
|
||||
this->glyph_to_char = MallocT<int>(this->glyph_count);
|
||||
this->glyphs.reserve(char_count);
|
||||
this->glyph_to_char.reserve(char_count);
|
||||
|
||||
/* Positions contains the location of the begin of each of the glyphs, and the end of the last one. */
|
||||
this->positions = MallocT<float>(this->glyph_count * 2 + 2);
|
||||
this->positions.resize(char_count * 2 + 2);
|
||||
this->positions[0] = x;
|
||||
|
||||
for (int i = 0; i < this->glyph_count; i++) {
|
||||
this->glyphs[i] = font->fc->MapCharToGlyph(chars[i]);
|
||||
for (int i = 0; i < char_count; i++) {
|
||||
const GlyphID &glyph_id = this->glyphs.emplace_back(font->fc->MapCharToGlyph(chars[i]));
|
||||
if (isbuiltin) {
|
||||
this->positions[2 * i + 1] = font->fc->GetAscender(); // Apply sprite font's ascender.
|
||||
} else if (chars[i] >= SCC_SPRITE_START && chars[i] <= SCC_SPRITE_END) {
|
||||
@@ -132,85 +130,11 @@ FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(Font *font, const
|
||||
} else {
|
||||
this->positions[2 * i + 1] = 0; // No ascender adjustment.
|
||||
}
|
||||
this->positions[2 * i + 2] = this->positions[2 * i] + font->fc->GetGlyphWidth(this->glyphs[i]);
|
||||
this->glyph_to_char[i] = char_offset + i;
|
||||
this->positions[2 * i + 2] = this->positions[2 * i] + font->fc->GetGlyphWidth(glyph_id);
|
||||
this->glyph_to_char.push_back(char_offset + i);
|
||||
}
|
||||
}
|
||||
|
||||
/** Move constructor for visual runs.*/
|
||||
FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(FallbackVisualRun &&other) noexcept : font(other.font), glyph_count(other.glyph_count)
|
||||
{
|
||||
this->positions = other.positions;
|
||||
this->glyph_to_char = other.glyph_to_char;
|
||||
this->glyphs = other.glyphs;
|
||||
|
||||
other.positions = nullptr;
|
||||
other.glyph_to_char = nullptr;
|
||||
other.glyphs = nullptr;
|
||||
}
|
||||
|
||||
/** Free all data. */
|
||||
FallbackParagraphLayout::FallbackVisualRun::~FallbackVisualRun()
|
||||
{
|
||||
free(this->positions);
|
||||
free(this->glyph_to_char);
|
||||
free(this->glyphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the font associated with this run.
|
||||
* @return The font.
|
||||
*/
|
||||
const Font *FallbackParagraphLayout::FallbackVisualRun::GetFont() const
|
||||
{
|
||||
return this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of glyphs in this run.
|
||||
* @return The number of glyphs.
|
||||
*/
|
||||
int FallbackParagraphLayout::FallbackVisualRun::GetGlyphCount() const
|
||||
{
|
||||
return this->glyph_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the glyphs of this run.
|
||||
* @return The glyphs.
|
||||
*/
|
||||
const GlyphID *FallbackParagraphLayout::FallbackVisualRun::GetGlyphs() const
|
||||
{
|
||||
return this->glyphs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the positions of this run.
|
||||
* @return The positions.
|
||||
*/
|
||||
const float *FallbackParagraphLayout::FallbackVisualRun::GetPositions() const
|
||||
{
|
||||
return this->positions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the glyph-to-character map for this visual run.
|
||||
* @return The glyph-to-character map.
|
||||
*/
|
||||
const int *FallbackParagraphLayout::FallbackVisualRun::GetGlyphToCharMap() const
|
||||
{
|
||||
return this->glyph_to_char;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of this font.
|
||||
* @return The height of the font.
|
||||
*/
|
||||
int FallbackParagraphLayout::FallbackVisualRun::GetLeading() const
|
||||
{
|
||||
return this->GetFont()->fc->GetHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of the line.
|
||||
* @return The maximum height of the line.
|
||||
@@ -231,7 +155,7 @@ int FallbackParagraphLayout::FallbackLine::GetLeading() const
|
||||
*/
|
||||
int FallbackParagraphLayout::FallbackLine::GetWidth() const
|
||||
{
|
||||
if (this->size() == 0) return 0;
|
||||
if (this->empty()) return 0;
|
||||
|
||||
/*
|
||||
* The last X position of a run contains is the end of that run.
|
||||
@@ -369,7 +293,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
|
||||
this->buffer++;
|
||||
}
|
||||
|
||||
if (l->size() == 0 || last_char - begin > 0) {
|
||||
if (l->empty() || last_char - begin > 0) {
|
||||
int w = l->GetWidth();
|
||||
l->emplace_back(iter->second, begin, last_char - begin, begin - this->buffer_begin, w);
|
||||
}
|
||||
|
Reference in New Issue
Block a user