1
0
Fork 0

Codefix: Use snake_case instead of camelCase in layouters.

pull/13182/head
Peter Nelson 2024-12-20 17:46:13 +00:00 committed by Peter Nelson
parent d623aa0dfb
commit c78e309b16
8 changed files with 26 additions and 26 deletions

View File

@ -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); typename T::CharType *buff_begin = MallocT<typename T::CharType>(str.size() + 1);
const typename T::CharType *buffer_last = buff_begin + str.size() + 1; const typename T::CharType *buffer_last = buff_begin + str.size() + 1;
typename T::CharType *buff = buff_begin; typename T::CharType *buff = buff_begin;
FontMap &fontMapping = line.runs; FontMap &font_mapping = line.runs;
Font *f = Layouter::GetFont(state.fontsize, state.cur_colour); Font *f = Layouter::GetFont(state.fontsize, state.cur_colour);
line.buffer = buff_begin; line.buffer = buff_begin;
fontMapping.clear(); font_mapping.clear();
auto cur = str.begin(); auto cur = str.begin();
@ -105,8 +105,8 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s
continue; continue;
} }
if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) { if (font_mapping.empty() || font_mapping.back().first != buff - buff_begin) {
fontMapping.emplace_back(buff - buff_begin, f); font_mapping.emplace_back(buff - buff_begin, f);
} }
f = Layouter::GetFont(state.fontsize, state.cur_colour); 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. */ /* Better safe than sorry. */
*buff = '\0'; *buff = '\0';
if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) { if (font_mapping.empty() || font_mapping.back().first != buff - buff_begin) {
fontMapping.emplace_back(buff - buff_begin, f); 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; line.state_after = state;
} }

View File

@ -79,12 +79,12 @@ public:
* Get the actual ParagraphLayout for the given buffer. * Get the actual ParagraphLayout for the given buffer.
* @param buff The begin of the buffer. * @param buff The begin of the buffer.
* @param buff_end The location after the last element in 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. * @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);
} }
/** /**

View File

@ -22,7 +22,7 @@ public:
/** Helper for GetLayouter, to get whether the layouter supports RTL. */ /** Helper for GetLayouter, to get whether the layouter supports RTL. */
static const bool SUPPORTS_RTL = false; 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); static size_t AppendToBuffer(char32_t *buff, const char32_t *buffer_last, char32_t c);
}; };

View File

@ -25,7 +25,7 @@ public:
/** Helper for GetLayouter, to get whether the layouter supports RTL. */ /** Helper for GetLayouter, to get whether the layouter supports RTL. */
static const bool SUPPORTS_RTL = true; 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 size_t AppendToBuffer(UChar *buff, const UChar *buffer_last, char32_t c);
static void InitializeLayouter(); static void InitializeLayouter();

View File

@ -94,7 +94,7 @@ public:
/** A single line worth of VisualRuns. */ /** A single line worth of VisualRuns. */
class CoreTextLine : public std::vector<CoreTextVisualRun>, public ParagraphLayouter::Line { class CoreTextLine : public std::vector<CoreTextVisualRun>, public ParagraphLayouter::Line {
public: 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()); CFArrayRef runs = CTLineGetGlyphRuns(line.get());
for (CFIndex i = 0; i < CFArrayGetCount(runs); i++) { for (CFIndex i = 0; i < CFArrayGetCount(runs); i++) {
@ -102,7 +102,7 @@ public:
/* Extract font information for this run. */ /* Extract font information for this run. */
CFRange chars = CTRunGetStringRange(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); 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(); this->Reflow();
} }
@ -148,7 +148,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
&SpriteFontGetWidth &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; if (!MacOSVersionIsAtLeast(10, 5, 0)) return nullptr;
@ -157,7 +157,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
if (length == 0) return nullptr; if (length == 0) return nullptr;
/* Can't layout our in-built sprite fonts. */ /* 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; 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 /* Apply font and colour ranges to our string. This is important to make sure
* that we get proper glyph boundaries on style changes. */ * that we get proper glyph boundaries on style changes. */
int last = 0; int last = 0;
for (const auto &i : fontMapping) { for (const auto &i : font_mapping) {
if (i.first - last == 0) continue; if (i.first - last == 0) continue;
CTFontRef font = (CTFontRef)i.second->fc->GetOSHandle(); CTFontRef font = (CTFontRef)i.second->fc->GetOSHandle();
@ -209,7 +209,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
/* Create and return typesetter for the string. */ /* Create and return typesetter for the string. */
CFAutoRelease<CTTypesetterRef> typesetter(CTTypesetterCreateWithAttributedString(str.get())); 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) /* virtual */ std::unique_ptr<const ParagraphLayouter::Line> CoreTextParagraphLayout::NextLine(int max_width)

View File

@ -49,10 +49,10 @@ public:
* Get the actual ParagraphLayout for the given buffer. * Get the actual ParagraphLayout for the given buffer.
* @param buff The begin of the buffer. * @param buff The begin of the buffer.
* @param buff_end The location after the last element in 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. * @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. * Append a wide character to the internal buffer.

View File

@ -276,14 +276,14 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
return items; 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; int32_t length = buff_end - buff;
/* Can't layout an empty string. */ /* Can't layout an empty string. */
if (length == 0) return nullptr; if (length == 0) return nullptr;
/* Can't layout our in-built sprite fonts. */ /* 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; if (pair.second->fc->IsBuiltInFont()) return nullptr;
} }
@ -297,7 +297,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
int cur_pos = 0; int cur_pos = 0;
std::vector<SCRIPT_ITEM>::iterator cur_item = items.begin(); 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) { while (cur_pos < i.first && cur_item != items.end() - 1) {
/* Add a range that spans the intersection of the remaining item and font run. */ /* 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); int stop_pos = std::min(i.first, (cur_item + 1)->iCharPos);

View File

@ -31,10 +31,10 @@ public:
* Get the actual ParagraphLayout for the given buffer. * Get the actual ParagraphLayout for the given buffer.
* @param buff The begin of the buffer. * @param buff The begin of the buffer.
* @param buff_end The location after the last element in 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. * @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. * Append a wide character to the internal buffer.