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

In another screen, the position is wrong #11

Closed
sxzxs opened this issue Aug 15, 2022 · 8 comments
Closed

In another screen, the position is wrong #11

sxzxs opened this issue Aug 15, 2022 · 8 comments

Comments

@sxzxs
Copy link

sxzxs commented Aug 15, 2022

I have double screen, but in another screen, the position may wrong!

@iseahound
Copy link
Owner

iseahound commented Aug 15, 2022

Can you show where it is wrong? This was tested using Mutiple monitors with different DPI.

You may find a test script in: https://github.com/iseahound/TextRender/releases/tag/v1.8
Run: Showcase 03 - Speed Test.ahk

@sxzxs
Copy link
Author

sxzxs commented Aug 15, 2022

Using your test program, as shown below, change x to a negative value, and y will stop when it moves to a position
main screen:1920x1080, another:1920x1200

image

image
image
image
image
image
image

@sxzxs
Copy link
Author

sxzxs commented Aug 17, 2022

this is a bug? i run same test with v2, same result.

@iseahound
Copy link
Owner

Yes, this does appear to be a bug. It seems to only happen with the y-axis on multi monitor systems

@iseahound
Copy link
Owner

And the reason it happens is because of lazy coding :)

image

I should have used a proper struct.

@iseahound
Copy link
Owner

iseahound commented Aug 18, 2022

Fixed by c1c397e.

Thank you for providing detailed instructions on how to reproduce the error, and for being patient.

Please test the v1 and v2 code to ensure it is fixed

@sxzxs
Copy link
Author

sxzxs commented Aug 19, 2022

I have test with v2 and v1 use new version,it work good!
Thans you very much! I often use TextRender!

I have a quick question, can I know the height or width of the text before rendering?

@iseahound
Copy link
Owner

iseahound commented Aug 19, 2022

I suppose you could do something like this:

#include TextRender.ahk
wh := Width_and_Height("hello world!", "s:42")
MsgBox wh[1] ", " wh[2]

Width_and_Height(text, s1:="", s2:="") {
    static tr := TextRender()
    tr.Draw(text, "x:0 y:0 c:None" . s1, s2) ; only supports string syntax, feel free to check for an object!
    try return [tr.w, tr.h]
    finally tr.Flush() ; Use this to clear the graphics 
}

EDIT: I highly recommend using Draw() before Render(). You can check the width and height between the DrawToScreen action.
https://github.com/iseahound/TextRender/wiki/Internal-Documentation#canvas-coordinates

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

No branches or pull requests

2 participants