Skip to content

Commit

Permalink
Fix the FontGlyphFace::makeScale() method when the scale factor < 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
domchen committed Dec 10, 2024
1 parent 413e3d8 commit 09d3c05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/FontGlyphFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool FontGlyphFace::hasOutlines() const {
}

std::shared_ptr<GlyphFace> FontGlyphFace::makeScaled(float scale) {
if (FloatNearlyZero(scale)) {
if (scale <= 0) {
return nullptr;
}
auto size = _font.getSize() * scale;
Expand Down
8 changes: 2 additions & 6 deletions src/core/GlyphRunList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ Rect GlyphRunList::getBounds(float resolutionScale) const {
if (hasScale) {
// Scale the glyphs before measuring to prevent precision loss with small font sizes.
glyphFace = glyphFace->makeScaled(resolutionScale);
if (glyphFace == nullptr) {
return Rect::MakeEmpty();
}
DEBUG_ASSERT(glyphFace != nullptr);
}
size_t index = 0;
auto& positions = run.positions;
Expand Down Expand Up @@ -89,9 +87,7 @@ bool GlyphRunList::getPath(Path* path, float resolutionScale) const {
if (hasScale) {
// Scale the glyphs before measuring to prevent precision loss with small font sizes.
glyphFace = glyphFace->makeScaled(resolutionScale);
if (glyphFace == nullptr) {
return false;
}
DEBUG_ASSERT(glyphFace != nullptr);
}
size_t index = 0;
auto& positions = run.positions;
Expand Down

0 comments on commit 09d3c05

Please sign in to comment.