Comments (6)
I recently added UI resizing and I've noticed that I can get it to reliably happen for all of my text boxes, just at different sizes. I think the textbox size that it happens at changes for different fonts/strings. I took this GIF with just whatever the default Java font is when you do new Font(null, Font.PLAIN, 28)
:
I also recreated this issue with the "Monospaced" font (Using "Monospaced"
instead of null
in the Font
constructor).
from litiengine.
Hi LITIENGINE community,
Can I make my first contribution by working on this issue?
I discovered the same cause that was already mentioned in a bug description: negative x
position is produced by Align.getLocation(width, objectWidth)
when a string line width (objectWidth
) exceeds available space (width
). This affects not just the LEFT
but all values of Align
. Similar issues occur with Valign
enum:
If these lines are removed:
position gets clamped:
However, two tests fail:
AlignTests > getLocation_InPoint(): expected: <-1.5> but was: <0.0>
AlignTests > getLocation_OffPoint(): expected: <0.45> but was: <0.0>
Test code:
Both alignment enums are used not only in GuiComponent.renderText()
(related to this issue) but also in PhysicsEngine
, CollisionEntity
, and direct calls of TextRenderer
methods. Is it necessary to separate text and entity alignments? For example: create a dedicated TextAlign
enum, or just use a common Align
but rename getLocation()
to getTextLocation()
and add getEntityLocation()
.
Either way an expected location behavior should be determined for all alignment values.
from litiengine.
I can reproduce this, but couldn't pinpoint the source of this issue.
What I can say for sure is that it depends on the font used due to the differences in glyph width:
from litiengine.
I remember also having issues with text rendering in java in one of my own projects.
I had to render the text using a GlyphVector to calculate bounds and stuff because it would just be wrong very often, however I've never seen it wrong by that much.
Just from a visual glance, it looks like the text's x-coordinate is being set to -(w*0.5)
where w is the width of the line of text being rendered.
from litiengine.
Hi @hedfol , thank you for your detailed assessment! We welcome your contribution in this regard. I would neither create separate classes nor methods for this, but an overload to the getLocation method with an additional boolean parameter that lets the user decide which behaviour to choose. Since the current logic seems to be assuming the entity case, we should leave the uses of getLocation in entities untouched and only replace the uses in text scenarios with the new overload.
from litiengine.
Thanks @nightm4re94 , that's an easy solution! I've created a PR with suggested changes.
from litiengine.
Related Issues (20)
- Refresh utiLITI resource tab after import
- Sound source dropdown is only updated after project reload
- Tiled versions 1.9.0 or higher make existing maps unusable for MapObject loading HOT 1
- Adjust Creature sprite naming conventions
- Fix name field in Sprite import panel HOT 13
- Enhance sprite dimension determination in sprite import panel HOT 7
- Importing some .WAV files fails HOT 1
- Hello I want to use this library with netbeans any tips on how to? HOT 2
- Cannot open utiliti UI on Mac OS HOT 8
- Impossible to run 0.6.0 litiengine HOT 2
- Unable to run version 0.6.0 of litiengine, problem with JAVA 21 HOT 5
- Link to download 0.6.0 are incorrect on Itch.io HOT 2
- Modifying props at runtime doesn't seem to work properly HOT 2
- Synchronizing maps throws an exception when there is no maps directory in the project root
- Can't run litiengine-ldjam52 HOT 3
- Mouse Moves in Wrong Direction When Turning GrabMouse On HOT 1
- class file has wrong version 65.0, should be 61.0 HOT 7
- Automatically update citation version on release
- Refactor File I/O handling
- Exception occurred applying plugin request "de.gurkenlabs.semverguru" HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from litiengine.