mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
Merge branch master-MC1.7.10 into master-MC1.10
This commit is contained in:
commit
dd3763f0e1
@ -154,6 +154,7 @@ object FontUtils {
|
|||||||
try {
|
try {
|
||||||
var line: String = null
|
var line: String = null
|
||||||
val input = new BufferedReader(new InputStreamReader(font, StandardCharsets.UTF_8))
|
val input = new BufferedReader(new InputStreamReader(font, StandardCharsets.UTF_8))
|
||||||
|
var out_of_range_glyph: Int = 0
|
||||||
while ({line = input.readLine; line != null}) {
|
while ({line = input.readLine; line != null}) {
|
||||||
val info = line.split(":")
|
val info = line.split(":")
|
||||||
val charCode = Integer.parseInt(info(0), 16)
|
val charCode = Integer.parseInt(info(0), 16)
|
||||||
@ -164,8 +165,14 @@ object FontUtils {
|
|||||||
case n => OpenComputers.log.warn(s"Invalid glyph size detected in font.hex. Expected 64 or 32, got: $n")
|
case n => OpenComputers.log.warn(s"Invalid glyph size detected in font.hex. Expected 64 or 32, got: $n")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (out_of_range_glyph == 0) {
|
||||||
OpenComputers.log.warn(f"Invalid glyph char code detected in font.hex. Expected 0<= charCode <$codepoint_limit%X, got: $charCode%X")
|
OpenComputers.log.warn(f"Invalid glyph char code detected in font.hex. Expected 0<= charCode <$codepoint_limit%X, got: $charCode%X")
|
||||||
}
|
}
|
||||||
|
out_of_range_glyph += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out_of_range_glyph > 1) {
|
||||||
|
OpenComputers.log.warn(f"${out_of_range_glyph} total invalid glyph char codes detected in font.hex")
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
@ -166,6 +166,8 @@ class TextBuffer(var width: Int, var height: Int, initialFormat: PackedColor.Col
|
|||||||
case dx if tx > 0 => dx
|
case dx if tx > 0 => dx
|
||||||
case dx => dx.swap
|
case dx => dx.swap
|
||||||
}
|
}
|
||||||
|
val left_edge = math.min(dx0, dx1) - 1
|
||||||
|
if (left_edge >= width - 1) return false // no work
|
||||||
val (dy0, dy1) = (math.max(0, math.min(height - 1, row + ty + h - 1)), math.max(0, math.min(height, row + ty))) match {
|
val (dy0, dy1) = (math.max(0, math.min(height - 1, row + ty + h - 1)), math.max(0, math.min(height, row + ty))) match {
|
||||||
case dy if ty > 0 => dy
|
case dy if ty > 0 => dy
|
||||||
case dy => dy.swap
|
case dy => dy.swap
|
||||||
@ -186,11 +188,17 @@ class TextBuffer(var width: Int, var height: Int, initialFormat: PackedColor.Col
|
|||||||
nl(nx) = ol(ox)
|
nl(nx) = ol(ox)
|
||||||
nc(nx) = oc(ox)
|
nc(nx) = oc(ox)
|
||||||
for (offset <- 1 until FontUtils.wcwidth(nl(nx))) {
|
for (offset <- 1 until FontUtils.wcwidth(nl(nx))) {
|
||||||
nl(nx + offset) = ol(' ')
|
nl(nx + offset) = ' '
|
||||||
nc(nx + offset) = oc(nx)
|
nc(nx + offset) = oc(nx)
|
||||||
}
|
}
|
||||||
case _ => /* Got no source column. */
|
case _ => /* Got no source column. */
|
||||||
}
|
}
|
||||||
|
// any wide chars along the left edge of the target rectangle need to be cleared
|
||||||
|
// don't change their colors
|
||||||
|
if (left_edge >= 0 && FontUtils.wcwidth(nl(left_edge)) > 1) {
|
||||||
|
nl(left_edge) = ' '
|
||||||
|
changed = true
|
||||||
|
}
|
||||||
case _ => /* Got no source row. */
|
case _ => /* Got no source row. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,16 +210,16 @@ class TextBuffer(var width: Int, var height: Int, initialFormat: PackedColor.Col
|
|||||||
// Don't allow setting wide chars in right-most col.
|
// Don't allow setting wide chars in right-most col.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (x > 0 && line(x) == ' ' && FontUtils.wcwidth(line(x - 1)) > 1) {
|
|
||||||
// Don't allow setting the cell following a wide char.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
line(x) = c
|
line(x) = c
|
||||||
lineColor(x) = packed
|
lineColor(x) = packed
|
||||||
for (x1 <- x + 1 until x + FontUtils.wcwidth(c)) {
|
for (x1 <- x + 1 until x + FontUtils.wcwidth(c)) {
|
||||||
line(x1) = ' '
|
line(x1) = ' '
|
||||||
lineColor(x1) = packed
|
lineColor(x1) = packed
|
||||||
}
|
}
|
||||||
|
if (x > 0 && FontUtils.wcwidth(line(x - 1)) > 1) {
|
||||||
|
// remove previous wide char (but don't change its color)
|
||||||
|
line(x - 1) = ' '
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def load(nbt: NBTTagCompound): Unit = {
|
def load(nbt: NBTTagCompound): Unit = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user