So I have these two texts that I'm trying to align at the same pixel basically, but it seems that one is more offset than the other. Like so, the one on the bottom seems to be further left than the other.
Here is the code:
VStack(alignment: .leading) {
Text("Enter your phone number")
.padding(15)
.frame(alignment: .leading)
.foregroundColor(Color.white)
.font(Font.custom("URWDIN-Thin", size: 30))
//Subtitle
Text("You will be sent a code for verification")
.padding(15)
.frame(alignment: .leading)
.foregroundColor(Color.white)
.font(Font.custom("URWDIN-Thin", size: 16))
Any idea as to why this may be?
You have chosen a font in which capital ‘E’ has a noticeable left side bearing. Left side bearing is the distance from the “pen position” to the left edge of the tight bounding box of the glyph.
That's why your lines of text look misaligned. Here's my test:
PlaygroundPage.current.setLiveView(
VStack(alignment: .leading) {
Text("Enter your phone number")
.border(Color.red, width: 1)
.font(Font.custom("URWDIN-Thin", size: 30))
Text("You will be sent a code for verification")
.border(Color.red, width: 1)
.font(Font.custom("URWDIN-Thin", size: 16))
Text("Enter your phone number")
.border(Color.red, width: 1)
.font(Font.system(size: 30))
Text("You will be sent a code for verification")
.border(Color.red, width: 1)
.font(Font.system(size: 16))
}
)
Output:
Notice how, in both URW DIN Thin and in the system font (SF Pro), the capital ‘Y’ has a left side bearing of essentially zero: both glyphs touch the left edge of the frame.
The left side bearing of SF Pro's capital ‘E’ is not zero but it's small: a fraction of the vertical stroke width.
But the left side bearing of the capital ‘E’ in DRW UDM Thin is significant. It's about twice the vertical stroke width. That makes it quite noticeable compared to the zero bearing of the capital ‘Y’.
Related
I have a view laid out like this:
Text
Spacer
Rectangle
Spacer
I'm trying to make the position of the Rectangle remain constant unless the Text is close enough to push it down. But currently, if the text grows a line taller, the rectangle moves down.
VStack {
Text("Hello")
Spacer()
Rectangle()
.frame(width: 50, height: 50)
Spacer()
}
I tried making the Spacer layoutPriority lower than the Text and Rectangle to no avail.
I'm not sure if I understand the question clearly, but it looks like what you need.
VStack {
Text(
"Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World "
)
.frame(minHeight: 0, maxHeight: .infinity)
Rectangle()
.frame(width: 50, height: 50)
.padding(.vertical, 100)
}
If your view can have a fixed height, you could set a max height for the lower Spacer() and set higher LayoutPriority() for the Text and Rectangle.
Here is an example:
VStack {
Text("Make this text longer and longer")
.layoutPriority(1)
Spacer()
Rectangle()
.frame(width: 50, height: 50)
.layoutPriority(1)
Spacer()
.frame(maxHeight: 120)
}
.frame(width: 100, height: 300)
Now, if you make the text longer it will grow in height and push the rectangle down as soon as the text touches it. I hope it helps.
I'm a beginner and I'm trying to make a macro in Logitech GHub.
I managed to program everything, but I randomly movements .
Is it possible to add random moves to this macro?
I searched in many places and didn't find anything similar to my question.
I want them to move randomly and not the same as in the script.
Thank you!
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 3 then
PressKey("lshift")
MoveMouseTo(34650, 26299)
PressAndReleaseMouseButton(3)
Sleep(math.random(13, 30))
MoveMouseTo(34650,30854)
PressAndReleaseMouseButton(3)
Sleep(math.random(13, 30))
MoveMouseTo(32755,30854)
PressAndReleaseMouseButton(3)
Sleep(math.random(13, 30))
MoveMouseTo(30860,30794)
PressAndReleaseMouseButton(3)
Sleep(math.random(13, 30))
MoveMouseTo(30911,26360)
PressAndReleaseMouseButton(3)
Sleep(math.random(13, 30))
MoveMouseTo(30911,21865)
PressAndReleaseMouseButton(3)
Sleep(math.random(13, 30))
MoveMouseTo(32780,21805)
PressAndReleaseMouseButton(3)
Sleep(math.random(13, 30))
MoveMouseTo(34650,21926)
PressAndReleaseMouseButton(3)
ReleaseKey("lshift")
end
end
I have difficulty to use strokeBorder after trim in SwiftUI, how can do this?
Circle()
.trim(from: 0, to: 0.5)
.strokeBorder(Color.red, style: StrokeStyle(lineWidth: 50.0, lineCap: .round, lineJoin: .round))
Error:
Value of type 'some Shape' has no member 'strokeBorder'
There is at least 2 ways to get the result like strokeBorder gives. But they are not using strokeBorder, I want solve the issue while using strokeBorder.
The llx, lly , urx, ury of co-ordinates are mentioned below
401.74042 747.38 406.18842 753.91815
405.9332 747.38 410.3812 753.91815
410.126 747.38 414.574 753.91815
I am trying to clean up the text in these locations using iText. Only text exists in these locations since I have got these co-ordinates using the renderText method of RenderListener.
The page size is Rectangle: 595.0x842.0 (rot: 0 degrees)
I am getting a "java.lang.IllegalStateException: Coordinate outside allowed range" exception only with this PDF with iText 5.5.11
I found "Exception occur :Reason : Coordinate outside allowed range java.lang.IllegalStateException: Coordinate outside allowed range" and it does not seem to help. Any help would be appreciated
stack trace
java.lang.IllegalStateException: Coordinate outside allowed range
at com.itextpdf.text.pdf.parser.clipper.ClipperBase.rangeTest(ClipperBase.java:119)
at com.itextpdf.text.pdf.parser.clipper.ClipperBase.addPath(ClipperBase.java:192)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRegionFilter.addRect(PdfCleanUpRegionFilter.java:423)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRegionFilter.filterFillPath(PdfCleanUpRegionFilter.java:176)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRegionFilter.filterStrokePath(PdfCleanUpRegionFilter.java:160)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRenderListener.filterCurrentPath(PdfCleanUpRenderListener.java:387)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRenderListener.renderPath(PdfCleanUpRenderListener.java:224)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.paintPath(PdfContentStreamProcessor.java:400)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.access$6300(PdfContentStreamProcessor.java:83)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor$PaintPath.invoke(PdfContentStreamProcessor.java:1218)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpContentOperator.invoke(PdfCleanUpContentOperator.java:139)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.invokeOperator(PdfContentStreamProcessor.java:310)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.processContent(PdfContentStreamProcessor.java:448)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor.cleanUpPage(PdfCleanUpProcessor.java:159)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor.cleanUp(PdfCleanUpProcessor.java:134)
(also here)
graphics state
The graphics state at the time of the exception:
Page Number: 1
Horizontal scaling:1.0
Render Mode: 0
Transformation matrix: 1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
Character spacing: 0.0
Font size: 0.0
Leading: 0.0
Line Cap Style: 0
Line join style: 0
Line wodth: 1.0
Miter limit: 10.0
Rise: 0.0
Word Spacing: 0.0
Color space fill: null
Color space stroke: null
Fill color: null
Font: null
Line dash pattern: null
Stroke color: null
Is knockout: true
(also here)
I'm writing a Framer.js function to simulate the 'splash' effect when you tap a button or a layer, as per Google Material Design.
It looks something like this
tapSplash = (tapX,tapY) ->
tapSplashLayer = new layer
backgroundColor: "#ffffff"
opacity: 0.2
width: 500, height: 1500
borderRadius: 1500
midX: tapX
midY: tapY
After this, I have some code to run the animation.
My question is, how do I get the tapX and tapY coordinates? It is not good enough to use the midpoint of the layer that has been clicked/tapped - I want the animation to originate from the exact point the user tapped on
Check out your own answer to the question.
I've since then forked it and made changes so that taps on a computer or taps on a mobile device are recognized separately.
https://github.com/carignanboy1/Material-Design-Interactions/tree/improved-touch
touchEvent = Events.touchEvent(event)
if Utils.isPhone() || Utils.isTablet()
tX = touchEvent.clientX - layer.x
tY = touchEvent.clientY - layer.y
else
tX = touchEvent.offsetX
tY = touchEvent.offsetY