mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:07:34 +00:00
Revert "Unicode: s/codepoint/code_point/g"
This reverts commit ea9ac3155d
.
It replaced "codepoint" with "code_points", not "code_point".
This commit is contained in:
parent
9664bac281
commit
19ac1f6368
45 changed files with 449 additions and 449 deletions
|
@ -33,21 +33,21 @@ namespace Gfx {
|
|||
|
||||
static HashMap<u32, RefPtr<Gfx::Bitmap>> s_emojis;
|
||||
|
||||
const Bitmap* Emoji::emoji_for_code_points(u32 code_points)
|
||||
const Bitmap* Emoji::emoji_for_codepoint(u32 codepoint)
|
||||
{
|
||||
auto it = s_emojis.find(code_points);
|
||||
auto it = s_emojis.find(codepoint);
|
||||
if (it != s_emojis.end())
|
||||
return (*it).value.ptr();
|
||||
|
||||
String path = String::format("/res/emoji/U+%X.png", code_points);
|
||||
String path = String::format("/res/emoji/U+%X.png", codepoint);
|
||||
|
||||
auto bitmap = Bitmap::load_from_file(path);
|
||||
if (!bitmap) {
|
||||
s_emojis.set(code_points, nullptr);
|
||||
s_emojis.set(codepoint, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
s_emojis.set(code_points, bitmap);
|
||||
s_emojis.set(codepoint, bitmap);
|
||||
return bitmap.ptr();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Bitmap;
|
|||
|
||||
class Emoji {
|
||||
public:
|
||||
static const Gfx::Bitmap* emoji_for_code_points(u32 code_points);
|
||||
static const Gfx::Bitmap* emoji_for_codepoint(u32 codepoint);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -255,20 +255,20 @@ bool Font::write_to_file(const StringView& path)
|
|||
return true;
|
||||
}
|
||||
|
||||
GlyphBitmap Font::glyph_bitmap(u32 code_points) const
|
||||
GlyphBitmap Font::glyph_bitmap(u32 codepoint) const
|
||||
{
|
||||
return GlyphBitmap(&m_rows[code_points * m_glyph_height], { glyph_width(code_points), m_glyph_height });
|
||||
return GlyphBitmap(&m_rows[codepoint * m_glyph_height], { glyph_width(codepoint), m_glyph_height });
|
||||
}
|
||||
|
||||
int Font::glyph_or_emoji_width(u32 code_points) const
|
||||
int Font::glyph_or_emoji_width(u32 codepoint) const
|
||||
{
|
||||
if (code_points < m_glyph_count)
|
||||
return glyph_width(code_points);
|
||||
if (codepoint < m_glyph_count)
|
||||
return glyph_width(codepoint);
|
||||
|
||||
if (m_fixed_width)
|
||||
return m_glyph_width;
|
||||
|
||||
auto* emoji = Emoji::emoji_for_code_points(code_points);
|
||||
auto* emoji = Emoji::emoji_for_codepoint(codepoint);
|
||||
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 code_points : utf8) {
|
||||
for (u32 codepoint : utf8) {
|
||||
if (!first)
|
||||
width += glyph_spacing();
|
||||
first = false;
|
||||
width += glyph_or_emoji_width(code_points);
|
||||
width += glyph_or_emoji_width(codepoint);
|
||||
}
|
||||
|
||||
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.code_pointss()[i]);
|
||||
width += glyph_or_emoji_width(view.codepoints()[i]);
|
||||
return width;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,10 +89,10 @@ public:
|
|||
|
||||
~Font();
|
||||
|
||||
GlyphBitmap glyph_bitmap(u32 code_points) const;
|
||||
GlyphBitmap glyph_bitmap(u32 codepoint) 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 code_points) const;
|
||||
int glyph_or_emoji_width(u32 codepoint) 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; }
|
||||
|
|
|
@ -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 code_points, Color color)
|
||||
FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 codepoint, Color color)
|
||||
{
|
||||
draw_glyph(point, code_points, font(), color);
|
||||
draw_glyph(point, codepoint, font(), color);
|
||||
}
|
||||
|
||||
FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 code_points, const Font& font, Color color)
|
||||
FLATTEN void Painter::draw_glyph(const IntPoint& point, u32 codepoint, const Font& font, Color color)
|
||||
{
|
||||
draw_bitmap(point, font.glyph_bitmap(code_points), color);
|
||||
draw_bitmap(point, font.glyph_bitmap(codepoint), 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 code_points, const Font& font, Color color)
|
||||
void Painter::draw_glyph_or_emoji(const IntPoint& point, u32 codepoint, const Font& font, Color color)
|
||||
{
|
||||
if (code_points < (u32)font.glyph_count()) {
|
||||
if (codepoint < (u32)font.glyph_count()) {
|
||||
// This looks like a regular character.
|
||||
draw_glyph(point, (size_t)code_points, font, color);
|
||||
draw_glyph(point, (size_t)codepoint, font, color);
|
||||
return;
|
||||
}
|
||||
|
||||
// Perhaps it's an emoji?
|
||||
auto* emoji = Emoji::emoji_for_code_points(code_points);
|
||||
auto* emoji = Emoji::emoji_for_codepoint(codepoint);
|
||||
if (emoji == nullptr) {
|
||||
#ifdef EMOJI_DEBUG
|
||||
dbg() << "Failed to find an emoji for code_points " << code_points;
|
||||
dbg() << "Failed to find an emoji for codepoint " << codepoint;
|
||||
#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 code_points = *it;
|
||||
int glyph_width = font.glyph_or_emoji_width(code_points);
|
||||
u32 codepoint = *it;
|
||||
int glyph_width = font.glyph_or_emoji_width(codepoint);
|
||||
// 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 code_points : final_text) {
|
||||
if (code_points == ' ') {
|
||||
for (u32 codepoint : final_text) {
|
||||
if (codepoint == ' ') {
|
||||
point.move_by(space_width, 0);
|
||||
continue;
|
||||
}
|
||||
draw_glyph_or_emoji(point, code_points, font, color);
|
||||
point.move_by(font.glyph_or_emoji_width(code_points) + font.glyph_spacing(), 0);
|
||||
draw_glyph_or_emoji(point, codepoint, font, color);
|
||||
point.move_by(font.glyph_or_emoji_width(codepoint) + 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 code_points = text.code_pointss()[i];
|
||||
int glyph_width = font.glyph_or_emoji_width(code_points);
|
||||
u32 codepoint = text.codepoints()[i];
|
||||
int glyph_width = font.glyph_or_emoji_width(codepoint);
|
||||
// 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.code_pointss(), i);
|
||||
elided_text.append(final_text.codepoints(), 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 code_points = final_text.code_pointss()[i];
|
||||
if (code_points == ' ') {
|
||||
auto codepoint = final_text.codepoints()[i];
|
||||
if (codepoint == ' ') {
|
||||
point.move_by(space_width, 0);
|
||||
continue;
|
||||
}
|
||||
draw_glyph_or_emoji(point, code_points, font, color);
|
||||
point.move_by(font.glyph_or_emoji_width(code_points) + font.glyph_spacing(), 0);
|
||||
draw_glyph_or_emoji(point, codepoint, font, color);
|
||||
point.move_by(font.glyph_or_emoji_width(codepoint) + 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 code_points = *it;
|
||||
if (code_points == '\n') {
|
||||
u32 codepoint = *it;
|
||||
if (codepoint == '\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 code_points = text.code_pointss()[i];
|
||||
if (code_points == '\n') {
|
||||
u32 codepoint = text.codepoints()[i];
|
||||
if (codepoint == '\n') {
|
||||
Utf32View line = text.substring_view(start_of_current_line, i - start_of_current_line);
|
||||
lines.append(line);
|
||||
start_of_current_line = i + 1;
|
||||
|
|
|
@ -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 code_points, const Font&, Color);
|
||||
void draw_glyph_or_emoji(const IntPoint&, u32 codepoint, 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&)>&&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue