1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:27:45 +00:00

Unicode: Try s/codepoint/code_point/g again

This time, without trailing 's'. Ran:

    git grep -l 'codepoint' | xargs sed -ie 's/codepoint/code_point/g
This commit is contained in:
Nico Weber 2020-08-05 16:31:20 -04:00 committed by Andreas Kling
parent 19ac1f6368
commit ce95628b7f
45 changed files with 441 additions and 441 deletions

View file

@ -33,21 +33,21 @@ namespace Gfx {
static HashMap<u32, RefPtr<Gfx::Bitmap>> s_emojis;
const Bitmap* Emoji::emoji_for_codepoint(u32 codepoint)
const Bitmap* Emoji::emoji_for_code_point(u32 code_point)
{
auto it = s_emojis.find(codepoint);
auto it = s_emojis.find(code_point);
if (it != s_emojis.end())
return (*it).value.ptr();
String path = String::format("/res/emoji/U+%X.png", codepoint);
String path = String::format("/res/emoji/U+%X.png", code_point);
auto bitmap = Bitmap::load_from_file(path);
if (!bitmap) {
s_emojis.set(codepoint, nullptr);
s_emojis.set(code_point, nullptr);
return nullptr;
}
s_emojis.set(codepoint, bitmap);
s_emojis.set(code_point, bitmap);
return bitmap.ptr();
}

View file

@ -34,7 +34,7 @@ class Bitmap;
class Emoji {
public:
static const Gfx::Bitmap* emoji_for_codepoint(u32 codepoint);
static const Gfx::Bitmap* emoji_for_code_point(u32 code_point);
};
}

View file

@ -255,20 +255,20 @@ bool Font::write_to_file(const StringView& path)
return true;
}
GlyphBitmap Font::glyph_bitmap(u32 codepoint) const
GlyphBitmap Font::glyph_bitmap(u32 code_point) const
{
return GlyphBitmap(&m_rows[codepoint * m_glyph_height], { glyph_width(codepoint), m_glyph_height });
return GlyphBitmap(&m_rows[code_point * m_glyph_height], { glyph_width(code_point), m_glyph_height });
}
int Font::glyph_or_emoji_width(u32 codepoint) const
int Font::glyph_or_emoji_width(u32 code_point) const
{
if (codepoint < m_glyph_count)
return glyph_width(codepoint);
if (code_point < m_glyph_count)
return glyph_width(code_point);
if (m_fixed_width)
return m_glyph_width;
auto* emoji = Emoji::emoji_for_codepoint(codepoint);
auto* emoji = Emoji::emoji_for_code_point(code_point);
if (emoji == nullptr)
return glyph_width('?');
return emoji->size().width();
@ -285,11 +285,11 @@ int Font::width(const Utf8View& utf8) const
bool first = true;
int width = 0;
for (u32 codepoint : utf8) {
for (u32 code_point : utf8) {
if (!first)
width += glyph_spacing();
first = false;
width += glyph_or_emoji_width(codepoint);
width += glyph_or_emoji_width(code_point);
}
return width;
@ -301,7 +301,7 @@ int Font::width(const Utf32View& view) const
return 0;
int width = (view.length() - 1) * glyph_spacing();
for (size_t i = 0; i < view.length(); ++i)
width += glyph_or_emoji_width(view.codepoints()[i]);
width += glyph_or_emoji_width(view.code_points()[i]);
return width;
}

View file

@ -89,10 +89,10 @@ public:
~Font();
GlyphBitmap glyph_bitmap(u32 codepoint) const;
GlyphBitmap glyph_bitmap(u32 code_point) const;
u8 glyph_width(size_t ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[ch]; }
int glyph_or_emoji_width(u32 codepoint) const;
int glyph_or_emoji_width(u32 code_point) const;
u8 glyph_height() const { return m_glyph_height; }
u8 min_glyph_width() const { return m_min_glyph_width; }
u8 max_glyph_width() const { return m_max_glyph_width; }

View file

@ -803,14 +803,14 @@ void Painter::draw_scaled_bitmap(const IntRect& a_dst_rect, const Gfx::Bitmap& s
}
}
FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 codepoint, Color color)
FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 code_point, Color color)
{
draw_glyph(point, codepoint, font(), color);
draw_glyph(point, code_point, font(), color);
}
FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 codepoint, const Font& font, Color color)
FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 code_point, const Font& font, Color color)
{
draw_bitmap(point, font.glyph_bitmap(codepoint), color);
draw_bitmap(point, font.glyph_bitmap(code_point), color);
}
void Painter::draw_emoji(const IntPoint& point, const Gfx::Bitmap& emoji, const Font& font)
@ -828,19 +828,19 @@ void Painter::draw_emoji(const IntPoint& point, const Gfx::Bitmap& emoji, const
}
}
void Painter::draw_glyph_or_emoji(const IntPoint& point, u32 codepoint, const Font& font, Color color)
void Painter::draw_glyph_or_emoji(const IntPoint& point, u32 code_point, const Font& font, Color color)
{
if (codepoint < (u32)font.glyph_count()) {
if (code_point < (u32)font.glyph_count()) {
// This looks like a regular character.
draw_glyph(point, (size_t)codepoint, font, color);
draw_glyph(point, (size_t)code_point, font, color);
return;
}
// Perhaps it's an emoji?
auto* emoji = Emoji::emoji_for_codepoint(codepoint);
auto* emoji = Emoji::emoji_for_code_point(code_point);
if (emoji == nullptr) {
#ifdef EMOJI_DEBUG
dbg() << "Failed to find an emoji for codepoint " << codepoint;
dbg() << "Failed to find an emoji for code_point " << code_point;
#endif
draw_glyph(point, '?', font, color);
return;
@ -862,8 +862,8 @@ void Painter::draw_text_line(const IntRect& a_rect, const Utf8View& text, const
int new_width = font.width("...");
if (new_width < text_width) {
for (auto it = final_text.begin(); it != final_text.end(); ++it) {
u32 codepoint = *it;
int glyph_width = font.glyph_or_emoji_width(codepoint);
u32 code_point = *it;
int glyph_width = font.glyph_or_emoji_width(code_point);
// NOTE: Glyph spacing should not be added after the last glyph on the line,
// but since we are here because the last glyph does not actually fit on the line,
// we don't have to worry about spacing.
@ -904,13 +904,13 @@ void Painter::draw_text_line(const IntRect& a_rect, const Utf8View& text, const
auto point = rect.location();
int space_width = font.glyph_width(' ') + font.glyph_spacing();
for (u32 codepoint : final_text) {
if (codepoint == ' ') {
for (u32 code_point : final_text) {
if (code_point == ' ') {
point.move_by(space_width, 0);
continue;
}
draw_glyph_or_emoji(point, codepoint, font, color);
point.move_by(font.glyph_or_emoji_width(codepoint) + font.glyph_spacing(), 0);
draw_glyph_or_emoji(point, code_point, font, color);
point.move_by(font.glyph_or_emoji_width(code_point) + font.glyph_spacing(), 0);
}
}
@ -927,8 +927,8 @@ void Painter::draw_text_line(const IntRect& a_rect, const Utf32View& text, const
if (new_width < text_width) {
size_t i = 0;
for (; i < text.length(); ++i) {
u32 codepoint = text.codepoints()[i];
int glyph_width = font.glyph_or_emoji_width(codepoint);
u32 code_point = text.code_points()[i];
int glyph_width = font.glyph_or_emoji_width(code_point);
// NOTE: Glyph spacing should not be added after the last glyph on the line,
// but since we are here because the last glyph does not actually fit on the line,
// we don't have to worry about spacing.
@ -938,7 +938,7 @@ void Painter::draw_text_line(const IntRect& a_rect, const Utf32View& text, const
new_width += glyph_width + glyph_spacing;
}
elided_text.clear();
elided_text.append(final_text.codepoints(), i);
elided_text.append(final_text.code_points(), i);
elided_text.append('.');
elided_text.append('.');
elided_text.append('.');
@ -970,13 +970,13 @@ void Painter::draw_text_line(const IntRect& a_rect, const Utf32View& text, const
int space_width = font.glyph_width(' ') + font.glyph_spacing();
for (size_t i = 0; i < final_text.length(); ++i) {
auto codepoint = final_text.codepoints()[i];
if (codepoint == ' ') {
auto code_point = final_text.code_points()[i];
if (code_point == ' ') {
point.move_by(space_width, 0);
continue;
}
draw_glyph_or_emoji(point, codepoint, font, color);
point.move_by(font.glyph_or_emoji_width(codepoint) + font.glyph_spacing(), 0);
draw_glyph_or_emoji(point, code_point, font, color);
point.move_by(font.glyph_or_emoji_width(code_point) + font.glyph_spacing(), 0);
}
}
@ -997,8 +997,8 @@ void Painter::draw_text(const IntRect& rect, const StringView& raw_text, const F
int start_of_current_line = 0;
for (auto it = text.begin(); it != text.end(); ++it) {
u32 codepoint = *it;
if (codepoint == '\n') {
u32 code_point = *it;
if (code_point == '\n') {
int byte_offset = text.byte_offset_of(it);
Utf8View line = text.substring_view(start_of_current_line, byte_offset - start_of_current_line);
lines.append(line);
@ -1055,8 +1055,8 @@ void Painter::draw_text(const IntRect& rect, const Utf32View& text, const Font&
size_t start_of_current_line = 0;
for (size_t i = 0; i < text.length(); ++i) {
u32 codepoint = text.codepoints()[i];
if (codepoint == '\n') {
u32 code_point = text.code_points()[i];
if (code_point == '\n') {
Utf32View line = text.substring_view(start_of_current_line, i - start_of_current_line);
lines.append(line);
start_of_current_line = i + 1;

View file

@ -81,7 +81,7 @@ public:
void draw_glyph(const IntPoint&, u32, Color);
void draw_glyph(const IntPoint&, u32, const Font&, Color);
void draw_emoji(const IntPoint&, const Gfx::Bitmap&, const Font&);
void draw_glyph_or_emoji(const IntPoint&, u32 codepoint, const Font&, Color);
void draw_glyph_or_emoji(const IntPoint&, u32 code_point, const Font&, Color);
static void for_each_line_segment_on_bezier_curve(const FloatPoint& control_point, const FloatPoint& p1, const FloatPoint& p2, Function<void(const FloatPoint&, const FloatPoint&)>&);
static void for_each_line_segment_on_bezier_curve(const FloatPoint& control_point, const FloatPoint& p1, const FloatPoint& p2, Function<void(const FloatPoint&, const FloatPoint&)>&&);