Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New text tool #4383

Draft
wants to merge 7 commits into
base: beta
Choose a base branch
from
Draft

New text tool #4383

wants to merge 7 commits into from

Conversation

dacap
Copy link
Member

@dacap dacap commented Mar 25, 2024

A work-in-progress to convert the "insert text" command into an interactive "text tool."

This was linked to issues Mar 25, 2024
Copy link
Collaborator

@aseprite-bot aseprite-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

}

std::string faceValue() const {
return m_face;
FontInfo fontInfo() const {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'fontInfo' can be made static [readability-convert-member-functions-to-static]

Suggested change
FontInfo fontInfo() const {
static FontInfo fontInfo() {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a bug in clang-tidy.

src/app/font_info.cpp Outdated Show resolved Hide resolved
src/app/font_info_tests.cpp Outdated Show resolved Hide resolved
src/app/ui/font_entry.cpp Outdated Show resolved Hide resolved
case kFocusEnterMessage:
if (!m_popup) {
try {
FontInfo info = static_cast<FontEntry*>(parent())->info();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'info' of type 'FontInfo' can be declared 'const' [misc-const-correctness]

Suggested change
FontInfo info = static_cast<FontEntry*>(parent())->info();
FontInfo const info = static_cast<FontEntry*>(parent())->info();

font->setSize(fontInfo.size());
}
else {
const int size = (fontInfo.useDefaultSize() ? 18: fontInfo.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'float' to 'int' [bugprone-narrowing-conversions]

    const int size = (fontInfo.useDefaultSize() ? 18: fontInfo.size());
                     ^

if (bounds.w < 1) bounds.w = 1;
if (bounds.h < 1) bounds.h = 1;

image.reset(doc::Image::create(doc::IMAGE_RGB, bounds.w, bounds.h));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'float' to 'int' [bugprone-narrowing-conversions]

  image.reset(doc::Image::create(doc::IMAGE_RGB, bounds.w, bounds.h));
                                                 ^

if (bounds.w < 1) bounds.w = 1;
if (bounds.h < 1) bounds.h = 1;

image.reset(doc::Image::create(doc::IMAGE_RGB, bounds.w, bounds.h));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'float' to 'int' [bugprone-narrowing-conversions]

  image.reset(doc::Image::create(doc::IMAGE_RGB, bounds.w, bounds.h));
                                                           ^

src/ui/manager.cpp Outdated Show resolved Hide resolved
src/ui/manager.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@aseprite-bot aseprite-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions


for (int i=0; i<info.glyphCount; ++i) {
auto rc = info.getGlyphBounds(i);
m_bounds |= gfx::Rect(rc.x, 0, rc.w, height);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'float' to 'int' [bugprone-narrowing-conversions]

        m_bounds |= gfx::Rect(rc.x, 0, rc.w, height);
                              ^


for (int i=0; i<info.glyphCount; ++i) {
auto rc = info.getGlyphBounds(i);
m_bounds |= gfx::Rect(rc.x, 0, rc.w, height);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'float' to 'int' [bugprone-narrowing-conversions]

        m_bounds |= gfx::Rect(rc.x, 0, rc.w, height);
                                       ^


for (int i=0; i<info.glyphCount; ++i) {
auto rc = info.getGlyphBounds(i);
m_bounds |= gfx::Rect(rc.x, 0, rc.w, height);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'float' to 'int' [bugprone-narrowing-conversions]

        m_bounds |= gfx::Rect(rc.x, 0, rc.w, height);
                                             ^

dacap added 7 commits May 7, 2024 20:20
This new font selector list installed fonts with its proper name. It
needs some extra work yet to select font set styles (regular, bold,
italic, etc.)
If we clicked bold/italic, and then choose another font family, we were
using the cached typeface inside the FontInfo instead of an update
typeface with the selected styles applied (bold/italic).

Now we don't cache the typeface inside FontInfo to avoid this.
…t run

This fixes the required output image size to render text in different
languages when the text does't support the full range of the specified
chars/code points.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New font selector Textbox tool
2 participants