Merge branch 'master' into jgrpp
# Conflicts: # src/core/bitmath_func.cpp # src/core/bitmath_func.hpp # src/core/geometry_type.hpp # src/game/game_text.hpp # src/graph_gui.cpp # src/pathfinder/npf/npf.cpp # src/script/api/script_text.cpp # src/spritecache.cpp # src/track_func.h
This commit is contained in:
@@ -73,7 +73,7 @@ public:
|
||||
class CoreTextVisualRun : public ParagraphLayouter::VisualRun {
|
||||
private:
|
||||
std::vector<GlyphID> glyphs;
|
||||
std::vector<float> positions;
|
||||
std::vector<Point> positions;
|
||||
std::vector<int> glyph_to_char;
|
||||
|
||||
int total_advance = 0;
|
||||
@@ -83,9 +83,9 @@ public:
|
||||
CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff);
|
||||
CoreTextVisualRun(CoreTextVisualRun &&other) = default;
|
||||
|
||||
const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
|
||||
const float *GetPositions() const override { return &this->positions[0]; }
|
||||
const int *GetGlyphToCharMap() const override { return &this->glyph_to_char[0]; }
|
||||
const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
|
||||
const std::vector<Point> &GetPositions() const override { return this->positions; }
|
||||
const std::vector<int> &GetGlyphToCharMap() const override { return this->glyph_to_char; }
|
||||
|
||||
const Font *GetFont() const override { return this->font; }
|
||||
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
||||
@@ -242,7 +242,7 @@ CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font
|
||||
|
||||
CGPoint pts[this->glyphs.size()];
|
||||
CTRunGetPositions(run, CFRangeMake(0, 0), pts);
|
||||
this->positions.resize(this->glyphs.size() * 2 + 2);
|
||||
this->positions.reserve(this->glyphs.size() + 1);
|
||||
|
||||
/* Convert glyph array to our data type. At the same time, substitute
|
||||
* the proper glyphs for our private sprite glyphs. */
|
||||
@@ -252,16 +252,15 @@ CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font
|
||||
if (buff[this->glyph_to_char[i]] >= SCC_SPRITE_START && buff[this->glyph_to_char[i]] <= SCC_SPRITE_END && (gl[i] == 0 || gl[i] == 3)) {
|
||||
/* A glyph of 0 indidicates not found, while apparently 3 is what char 0xFFFC maps to. */
|
||||
this->glyphs[i] = font->fc->MapCharToGlyph(buff[this->glyph_to_char[i]]);
|
||||
this->positions[i * 2 + 0] = pts[i].x;
|
||||
this->positions[i * 2 + 1] = (font->fc->GetHeight() - ScaleSpriteTrad(FontCache::GetDefaultFontHeight(font->fc->GetSize()))) / 2; // Align sprite font to centre
|
||||
this->positions.emplace_back(pts[i].x, (font->fc->GetHeight() - ScaleSpriteTrad(FontCache::GetDefaultFontHeight(font->fc->GetSize()))) / 2); // Align sprite font to centre
|
||||
} else {
|
||||
this->glyphs[i] = gl[i];
|
||||
this->positions[i * 2 + 0] = pts[i].x;
|
||||
this->positions[i * 2 + 1] = pts[i].y;
|
||||
this->positions.emplace_back(pts[i].x, pts[i].y);
|
||||
}
|
||||
}
|
||||
this->total_advance = (int)std::ceil(CTRunGetTypographicBounds(run, CFRangeMake(0, 0), nullptr, nullptr, nullptr));
|
||||
this->positions[this->glyphs.size() * 2] = this->positions[0] + this->total_advance;
|
||||
/* End-of-run position. */
|
||||
this->positions.emplace_back(this->positions.front().x + this->total_advance, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,8 @@ static std::tuple<std::string, std::string> SplitFontFamilyAndStyle(std::string_
|
||||
if (separator == std::string_view::npos) return { std::string(font_name), std::string() };
|
||||
|
||||
auto begin = font_name.find_first_not_of("\t ", separator + 1);
|
||||
if (begin == std::string_view::npos) return { std::string(font_name.substr(0, separator)), std::string() };
|
||||
|
||||
return { std::string(font_name.substr(0, separator)), std::string(font_name.substr(begin)) };
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
class UniscribeVisualRun : public ParagraphLayouter::VisualRun {
|
||||
private:
|
||||
std::vector<GlyphID> glyphs;
|
||||
std::vector<float> positions;
|
||||
std::vector<Point> positions;
|
||||
std::vector<WORD> char_to_glyph;
|
||||
|
||||
int start_pos;
|
||||
@@ -83,19 +83,15 @@ public:
|
||||
int num_glyphs;
|
||||
Font *font;
|
||||
|
||||
mutable int *glyph_to_char = nullptr;
|
||||
mutable std::vector<int> glyph_to_char;
|
||||
|
||||
public:
|
||||
UniscribeVisualRun(const UniscribeRun &range, int x);
|
||||
UniscribeVisualRun(UniscribeVisualRun &&other) noexcept;
|
||||
~UniscribeVisualRun() override
|
||||
{
|
||||
free(this->glyph_to_char);
|
||||
}
|
||||
|
||||
const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
|
||||
const float *GetPositions() const override { return &this->positions[0]; }
|
||||
const int *GetGlyphToCharMap() const override;
|
||||
const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
|
||||
const std::vector<Point> &GetPositions() const override { return this->positions; }
|
||||
const std::vector<int> &GetGlyphToCharMap() const override;
|
||||
|
||||
const Font *GetFont() const override { return this->font; }
|
||||
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
||||
@@ -481,30 +477,29 @@ int UniscribeParagraphLayout::UniscribeLine::GetWidth() const
|
||||
UniscribeParagraphLayout::UniscribeVisualRun::UniscribeVisualRun(const UniscribeRun &range, int x) : glyphs(range.ft_glyphs), char_to_glyph(range.char_to_glyph), start_pos(range.pos), total_advance(range.total_advance), font(range.font)
|
||||
{
|
||||
this->num_glyphs = (int)glyphs.size();
|
||||
this->positions.resize(this->num_glyphs * 2 + 2);
|
||||
this->positions.reserve(this->num_glyphs + 1);
|
||||
|
||||
int advance = 0;
|
||||
int advance = x;
|
||||
for (int i = 0; i < this->num_glyphs; i++) {
|
||||
this->positions[i * 2 + 0] = range.offsets[i].du + advance + x;
|
||||
this->positions[i * 2 + 1] = range.offsets[i].dv;
|
||||
this->positions.emplace_back(range.offsets[i].du + advance, range.offsets[i].dv);
|
||||
|
||||
advance += range.advances[i];
|
||||
}
|
||||
this->positions[this->num_glyphs * 2] = advance + x;
|
||||
/* End-of-run position. */
|
||||
this->positions.emplace_back(advance, 0);
|
||||
}
|
||||
|
||||
UniscribeParagraphLayout::UniscribeVisualRun::UniscribeVisualRun(UniscribeVisualRun&& other) noexcept
|
||||
: glyphs(std::move(other.glyphs)), positions(std::move(other.positions)), char_to_glyph(std::move(other.char_to_glyph)),
|
||||
start_pos(other.start_pos), total_advance(other.total_advance), num_glyphs(other.num_glyphs), font(other.font)
|
||||
start_pos(other.start_pos), total_advance(other.total_advance), num_glyphs(other.num_glyphs), font(other.font),
|
||||
glyph_to_char(std::move(other.glyph_to_char))
|
||||
{
|
||||
this->glyph_to_char = other.glyph_to_char;
|
||||
other.glyph_to_char = nullptr;
|
||||
}
|
||||
|
||||
const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() const
|
||||
const std::vector<int> &UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() const
|
||||
{
|
||||
if (this->glyph_to_char == nullptr) {
|
||||
this->glyph_to_char = CallocT<int>(this->GetGlyphCount());
|
||||
if (this->glyph_to_char.empty()) {
|
||||
this->glyph_to_char.resize(this->GetGlyphCount());
|
||||
|
||||
/* The char to glyph array contains the first glyph index of the cluster that is associated
|
||||
* with each character. It is possible for a cluster to be formed of several chars. */
|
||||
|
||||
Reference in New Issue
Block a user