android:pdfdocument:measuringparagraph
measuringparagraph
차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| android:pdfdocument:measuringparagraph [2024/12/07 22:02] – 상자와 선을 만들기 이거니맨 | android:pdfdocument:measuringparagraph [2024/12/09 23:31] (현재) – 이거니맨 | ||
|---|---|---|---|
| 줄 234: | 줄 234: | ||
| - | 아래 그림은 각각 김정철명조체와 고령딸기체로 그린 글자에 대하여 경계썬을 나타낸 것이다. | + | 아래 그림은 각각 |
| - | {{: | ||
| + | ^ 고령딸기체 | ||
| + | | {{: | ||
| + | LineHeight()로 줄의 높이를 정하는게 가장 시인성 있는 것을 알 수 있다. 따라서 앞으로는 이를 기준으로 글자의 높이를 정하겠다. | ||
| + | |||
| + | |||
| + | ===== 결론 ===== | ||
| + | |||
| + | ==== 1. Rich Text ==== | ||
| + | |||
| + | 다음과 같이 Rich Text를 구현할 수 있다. | ||
| + | |||
| + | <code kotlin> | ||
| + | // Text with underline, rectangle, outline, shadow | ||
| + | fun richText(text : String, canvas: Canvas, switch : String) { | ||
| + | title.setTypeface(fontKJCMyungjo) | ||
| + | title.color = ContextCompat.getColor(context, | ||
| + | title.textSize = 16f | ||
| + | title.textAlign = Paint.Align.LEFT | ||
| + | |||
| + | // Font Effect | ||
| + | when (switch) { | ||
| + | " | ||
| + | // Draw Text | ||
| + | canvas.drawText(text, | ||
| + | |||
| + | val bounds = Rect() | ||
| + | title.getTextBounds(text, | ||
| + | val offset = 2 | ||
| + | val rc = Rect(currentPOS.X - offset, currentPOS.Y - bounds.height() + offset, currentPOS.X + bounds.right + offset, currentPOS.Y + bounds.bottom + offset) | ||
| + | |||
| + | canvas.drawRect(rc, | ||
| + | } | ||
| + | " | ||
| + | // Draw Text | ||
| + | canvas.drawText(text, | ||
| + | val bounds = Rect() | ||
| + | title.getTextBounds(text, | ||
| + | val offset = 2f | ||
| + | canvas.drawLine(currentPOS.X.toFloat() - offset, currentPOS.Y.toFloat() + bounds.bottom + offset, currentPOS.X + bounds.right.toFloat() + offset, currentPOS.Y + bounds.bottom + offset, linePaint) | ||
| + | |||
| + | canvas.drawText(" | ||
| + | } | ||
| + | " | ||
| + | // Draw Text | ||
| + | canvas.drawText(text, | ||
| + | |||
| + | val bounds = Rect() | ||
| + | title.getTextBounds(text, | ||
| + | val offset = 2f | ||
| + | canvas.drawLine(currentPOS.X.toFloat() - offset, currentPOS.Y.toFloat() - (bounds.height() / 2).toFloat() + bounds.bottom, | ||
| + | |||
| + | canvas.drawText(" | ||
| + | } | ||
| + | " | ||
| + | // draw outline of text | ||
| + | title.style = Paint.Style.FILL_AND_STROKE | ||
| + | title.strokeWidth = 1f | ||
| + | title.color = ContextCompat.getColor(context, | ||
| + | |||
| + | canvas.drawText( text, currentPOS.X.toFloat(), | ||
| + | } | ||
| + | " | ||
| + | // draw outline of text | ||
| + | title.style = Paint.Style.STROKE | ||
| + | title.strokeWidth = 0.5f | ||
| + | title.color = ContextCompat.getColor(context, | ||
| + | |||
| + | canvas.drawText( text, currentPOS.X.toFloat(), | ||
| + | } | ||
| + | " | ||
| + | title.style = Paint.Style.FILL | ||
| + | title.strokeWidth = 1f | ||
| + | title.setShadowLayer(1f, | ||
| + | canvas.drawText( text, currentPOS.X.toFloat(), | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | ==== 2. 예시 ==== | ||
| + | |||
| + | 위의 글자꾸미기는 다음과 같이 PDF로 인쇄된다. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | <code kotlin> | ||
| + | pdfUtil.space() | ||
| + | // 선을 그리기 | ||
| + | pdfUtil.linefeed() | ||
| + | pdfUtil.richText(" | ||
| + | |||
| + | pdfUtil.linefeed() | ||
| + | pdfUtil.richText(" | ||
| + | |||
| + | pdfUtil.linefeed() | ||
| + | pdfUtil.richText(" | ||
| + | |||
| + | pdfUtil.linefeed() | ||
| + | pdfUtil.richText(" | ||
| + | |||
| + | pdfUtil.linefeed() | ||
| + | pdfUtil.richText(" | ||
| + | |||
| + | pdfUtil.linefeed() | ||
| + | pdfUtil.richText(" | ||
| + | |||
| + | </ | ||
android/pdfdocument/measuringparagraph.1733576547.txt.gz · 마지막으로 수정됨: 저자 이거니맨
