btex: <a> tag underlines

This commit is contained in:
minjaesong
2024-05-18 20:12:22 +09:00
parent 48703a7c38
commit 7d58c9f1ae
3 changed files with 10 additions and 9 deletions

Binary file not shown.

View File

@@ -356,7 +356,7 @@ data class BTeXClickable(
} }
fun drawUnderline(pixmap: Pixmap, doc: BTeXDocument) { fun drawUnderline(pixmap: Pixmap, doc: BTeXDocument) {
if (drawUnderline && width > 1) { if (drawUnderline) {
val x = posX - HBPADH + doc.pageMarginH val x = posX - HBPADH + doc.pageMarginH
val y = posY - HBPADV + doc.pageMarginV + UNDERLINE_Y val y = posY - HBPADV + doc.pageMarginV + UNDERLINE_Y
val width = width + HBPADH val width = width + HBPADH
@@ -391,7 +391,8 @@ class BTeXPage(
if (drawCall.isNotBlank()) drawCalls.add(drawCall) if (drawCall.isNotBlank()) drawCalls.add(drawCall)
} }
fun appendClickable(clickable: BTeXClickable) { fun appendClickable(clickable: BTeXClickable) {
clickableElements.add(clickable) if (clickable.width > 1)
clickableElements.add(clickable)
} }
private var prerender = false private var prerender = false

View File

@@ -1717,8 +1717,8 @@ object BTeXParser {
// get width of "word" // get width of "word"
val searchStrs = slugs.typesettedSlugs.subList(subset.first, subset.first + subset.second) val searchStrs = slugs.typesettedSlugs.subList(subset.first, subset.first + subset.second)
searchStrs.forEach { str -> searchStrs.forEach { str ->
// printdbg("2HREF searchStr: ${str.toReadable()}") printdbg("2HREF searchStr: ${str.toReadable()}")
// printdbg("2HREF object: ${objSeq.toReadable()} (id=${hrefDict[objSeq.toReadable()]})") printdbg("2HREF object: ${objSeq.toReadable()} (id=${hrefDict[objSeq.toReadable()]})")
val indexOfSequence = str.indexOfSequence(objSeq) val indexOfSequence = str.indexOfSequence(objSeq)
@@ -1739,8 +1739,8 @@ object BTeXParser {
// retrieve the actual word // retrieve the actual word
val substr = CodepointSequence(str.subList(wordOffset + 1, wordEnd)) val substr = CodepointSequence(str.subList(wordOffset + 1, wordEnd))
// printdbg("2HREF word: ${substr.toReadable()}") printdbg("2HREF word: ${substr.toReadable()}")
// printdbg("2HREF hrefObj: ${hrefObj}") printdbg("2HREF hrefObj: ${hrefObj}")
val hrefX = if (objectIsSplit) 0 else hrefObj.x val hrefX = if (objectIsSplit) 0 else hrefObj.x
var hrefY = hrefObj.y; if (objectIsSplit) hrefY += doc.lineHeightInPx var hrefY = hrefObj.y; if (objectIsSplit) hrefY += doc.lineHeightInPx
@@ -1754,7 +1754,7 @@ object BTeXParser {
} }
// target word is on the next line (probably) // target word is on the next line (probably)
else { else {
// printdbg("2HREF object was cut off by the linebreak") printdbg("2HREF object was cut off by the linebreak")
objectIsSplit = true objectIsSplit = true
} }
} }