mirror of https://github.com/OpenTTD/OpenTTD
Codefix: Use snake_case instead of camelCase in layouters.
parent
d623aa0dfb
commit
c78e309b16
|
@ -68,11 +68,11 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s
|
|||
typename T::CharType *buff_begin = MallocT<typename T::CharType>(str.size() + 1);
|
||||
const typename T::CharType *buffer_last = buff_begin + str.size() + 1;
|
||||
typename T::CharType *buff = buff_begin;
|
||||
FontMap &fontMapping = line.runs;
|
||||
FontMap &font_mapping = line.runs;
|
||||
Font *f = Layouter::GetFont(state.fontsize, state.cur_colour);
|
||||
|
||||
line.buffer = buff_begin;
|
||||
fontMapping.clear();
|
||||
font_mapping.clear();
|
||||
|
||||
auto cur = str.begin();
|
||||
|
||||
|
@ -105,8 +105,8 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s
|
|||
continue;
|
||||
}
|
||||
|
||||
if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) {
|
||||
fontMapping.emplace_back(buff - buff_begin, f);
|
||||
if (font_mapping.empty() || font_mapping.back().first != buff - buff_begin) {
|
||||
font_mapping.emplace_back(buff - buff_begin, f);
|
||||
}
|
||||
f = Layouter::GetFont(state.fontsize, state.cur_colour);
|
||||
}
|
||||
|
@ -114,10 +114,10 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s
|
|||
/* Better safe than sorry. */
|
||||
*buff = '\0';
|
||||
|
||||
if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) {
|
||||
fontMapping.emplace_back(buff - buff_begin, f);
|
||||
if (font_mapping.empty() || font_mapping.back().first != buff - buff_begin) {
|
||||
font_mapping.emplace_back(buff - buff_begin, f);
|
||||
}
|
||||
line.layout = T::GetParagraphLayout(buff_begin, buff, fontMapping);
|
||||
line.layout = T::GetParagraphLayout(buff_begin, buff, font_mapping);
|
||||
line.state_after = state;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,12 +79,12 @@ public:
|
|||
* Get the actual ParagraphLayout for the given buffer.
|
||||
* @param buff The begin of the buffer.
|
||||
* @param buff_end The location after the last element in the buffer.
|
||||
* @param fontMapping THe mapping of the fonts.
|
||||
* @param font_mapping The mapping of the fonts.
|
||||
* @return The ParagraphLayout instance.
|
||||
*/
|
||||
/* static */ std::unique_ptr<ParagraphLayouter> FallbackParagraphLayoutFactory::GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &fontMapping)
|
||||
/* static */ std::unique_ptr<ParagraphLayouter> FallbackParagraphLayoutFactory::GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &font_mapping)
|
||||
{
|
||||
return std::make_unique<FallbackParagraphLayout>(buff, buff_end - buff, fontMapping);
|
||||
return std::make_unique<FallbackParagraphLayout>(buff, buff_end - buff, font_mapping);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
/** Helper for GetLayouter, to get whether the layouter supports RTL. */
|
||||
static const bool SUPPORTS_RTL = false;
|
||||
|
||||
static std::unique_ptr<ParagraphLayouter> GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &fontMapping);
|
||||
static std::unique_ptr<ParagraphLayouter> GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &font_mapping);
|
||||
static size_t AppendToBuffer(char32_t *buff, const char32_t *buffer_last, char32_t c);
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
/** Helper for GetLayouter, to get whether the layouter supports RTL. */
|
||||
static const bool SUPPORTS_RTL = true;
|
||||
|
||||
static std::unique_ptr<ParagraphLayouter> GetParagraphLayout(UChar *buff, UChar *buff_end, FontMap &fontMapping);
|
||||
static std::unique_ptr<ParagraphLayouter> GetParagraphLayout(UChar *buff, UChar *buff_end, FontMap &font_mapping);
|
||||
static size_t AppendToBuffer(UChar *buff, const UChar *buffer_last, char32_t c);
|
||||
|
||||
static void InitializeLayouter();
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
/** A single line worth of VisualRuns. */
|
||||
class CoreTextLine : public std::vector<CoreTextVisualRun>, public ParagraphLayouter::Line {
|
||||
public:
|
||||
CoreTextLine(CFAutoRelease<CTLineRef> line, const FontMap &fontMapping, const CoreTextParagraphLayoutFactory::CharType *buff)
|
||||
CoreTextLine(CFAutoRelease<CTLineRef> line, const FontMap &font_mapping, const CoreTextParagraphLayoutFactory::CharType *buff)
|
||||
{
|
||||
CFArrayRef runs = CTLineGetGlyphRuns(line.get());
|
||||
for (CFIndex i = 0; i < CFArrayGetCount(runs); i++) {
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
|
||||
/* Extract font information for this run. */
|
||||
CFRange chars = CTRunGetStringRange(run);
|
||||
auto map = std::ranges::upper_bound(fontMapping, chars.location, std::less{}, &std::pair<int, Font *>::first);
|
||||
auto map = std::ranges::upper_bound(font_mapping, chars.location, std::less{}, &std::pair<int, Font *>::first);
|
||||
|
||||
this->emplace_back(run, map->second, buff);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
CoreTextParagraphLayout(CFAutoRelease<CTTypesetterRef> typesetter, const CoreTextParagraphLayoutFactory::CharType *buffer, ptrdiff_t len, const FontMap &fontMapping) : text_buffer(buffer), length(len), font_map(fontMapping), typesetter(std::move(typesetter))
|
||||
CoreTextParagraphLayout(CFAutoRelease<CTTypesetterRef> typesetter, const CoreTextParagraphLayoutFactory::CharType *buffer, ptrdiff_t len, const FontMap &font_mapping) : text_buffer(buffer), length(len), font_map(font_mapping), typesetter(std::move(typesetter))
|
||||
{
|
||||
this->Reflow();
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
|||
&SpriteFontGetWidth
|
||||
};
|
||||
|
||||
/* static */ std::unique_ptr<ParagraphLayouter> CoreTextParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping)
|
||||
/* static */ std::unique_ptr<ParagraphLayouter> CoreTextParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &font_mapping)
|
||||
{
|
||||
if (!MacOSVersionIsAtLeast(10, 5, 0)) return nullptr;
|
||||
|
||||
|
@ -157,7 +157,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
|||
if (length == 0) return nullptr;
|
||||
|
||||
/* Can't layout our in-built sprite fonts. */
|
||||
for (const auto &i : fontMapping) {
|
||||
for (const auto &i : font_mapping) {
|
||||
if (i.second->fc->IsBuiltInFont()) return nullptr;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
|||
/* Apply font and colour ranges to our string. This is important to make sure
|
||||
* that we get proper glyph boundaries on style changes. */
|
||||
int last = 0;
|
||||
for (const auto &i : fontMapping) {
|
||||
for (const auto &i : font_mapping) {
|
||||
if (i.first - last == 0) continue;
|
||||
|
||||
CTFontRef font = (CTFontRef)i.second->fc->GetOSHandle();
|
||||
|
@ -209,7 +209,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
|||
/* Create and return typesetter for the string. */
|
||||
CFAutoRelease<CTTypesetterRef> typesetter(CTTypesetterCreateWithAttributedString(str.get()));
|
||||
|
||||
return typesetter ? std::make_unique<CoreTextParagraphLayout>(std::move(typesetter), buff, length, fontMapping) : nullptr;
|
||||
return typesetter ? std::make_unique<CoreTextParagraphLayout>(std::move(typesetter), buff, length, font_mapping) : nullptr;
|
||||
}
|
||||
|
||||
/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> CoreTextParagraphLayout::NextLine(int max_width)
|
||||
|
|
|
@ -49,10 +49,10 @@ public:
|
|||
* Get the actual ParagraphLayout for the given buffer.
|
||||
* @param buff The begin of the buffer.
|
||||
* @param buff_end The location after the last element in the buffer.
|
||||
* @param fontMapping THe mapping of the fonts.
|
||||
* @param font_mapping The mapping of the fonts.
|
||||
* @return The ParagraphLayout instance.
|
||||
*/
|
||||
static std::unique_ptr<ParagraphLayouter> GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping);
|
||||
static std::unique_ptr<ParagraphLayouter> GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &font_mapping);
|
||||
|
||||
/**
|
||||
* Append a wide character to the internal buffer.
|
||||
|
|
|
@ -276,14 +276,14 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
|
|||
return items;
|
||||
}
|
||||
|
||||
/* static */ std::unique_ptr<ParagraphLayouter> UniscribeParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping)
|
||||
/* static */ std::unique_ptr<ParagraphLayouter> UniscribeParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &font_mapping)
|
||||
{
|
||||
int32_t length = buff_end - buff;
|
||||
/* Can't layout an empty string. */
|
||||
if (length == 0) return nullptr;
|
||||
|
||||
/* Can't layout our in-built sprite fonts. */
|
||||
for (auto const &pair : fontMapping) {
|
||||
for (auto const &pair : font_mapping) {
|
||||
if (pair.second->fc->IsBuiltInFont()) return nullptr;
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
|
|||
|
||||
int cur_pos = 0;
|
||||
std::vector<SCRIPT_ITEM>::iterator cur_item = items.begin();
|
||||
for (auto const &i : fontMapping) {
|
||||
for (auto const &i : font_mapping) {
|
||||
while (cur_pos < i.first && cur_item != items.end() - 1) {
|
||||
/* Add a range that spans the intersection of the remaining item and font run. */
|
||||
int stop_pos = std::min(i.first, (cur_item + 1)->iCharPos);
|
||||
|
|
|
@ -31,10 +31,10 @@ public:
|
|||
* Get the actual ParagraphLayout for the given buffer.
|
||||
* @param buff The begin of the buffer.
|
||||
* @param buff_end The location after the last element in the buffer.
|
||||
* @param fontMapping THe mapping of the fonts.
|
||||
* @param font_mapping The mapping of the fonts.
|
||||
* @return The ParagraphLayout instance.
|
||||
*/
|
||||
static std::unique_ptr<ParagraphLayouter> GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping);
|
||||
static std::unique_ptr<ParagraphLayouter> GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &font_mapping);
|
||||
|
||||
/**
|
||||
* Append a wide character to the internal buffer.
|
||||
|
|
Loading…
Reference in New Issue