Skip to content

Commit

Permalink
Fix [52df668390]: Measurement of control characters are wrong after m…
Browse files Browse the repository at this point in the history
…easurement of characters that cannot be displayed by the given font.

AllocFont() -> InitFont() in comments
  • Loading branch information
jan.nijtmans committed Jan 3, 2024
2 parents 56aed32 + dd16e78 commit 1298883
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
22 changes: 11 additions & 11 deletions tests/unixFont.test
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,18 @@ test unixfont-7.3 {DrawChars procedure: overstrike} x11 {
.b.l config -font $f
} {}

test unixfont-8.1 {AllocFont procedure: use old font} x11 {
test unixfont-8.1 {InitFont procedure: use old font} x11 {
font create xyz
button .c -font xyz
font configure xyz -family times
update
destroy .c
font delete xyz
} {}
test unixfont-8.2 {AllocFont procedure: parse information from XLFD} x11 {
test unixfont-8.2 {InitFont procedure: parse information from XLFD} x11 {
expr {[lindex [font actual {-family times -size 0}] 3] == 0}
} 0
test unixfont-8.3 {AllocFont procedure: can't parse info from name} x11 {
test unixfont-8.3 {InitFont procedure: can't parse info from name} x11 {
catch {unset fontArray}
# check that font actual returns the correct attributes.
# the values of those attributes are system dependent.
Expand All @@ -256,41 +256,41 @@ test unixfont-8.3 {AllocFont procedure: can't parse info from name} x11 {
catch {unset fontArray}
set result
} {-family -overstrike -size -slant -underline -weight}
test unixfont-8.4 {AllocFont procedure: classify characters} {x11 failsOnUbuntu failsOnXQuarz} {
test unixfont-8.4 {InitFont procedure: classify characters} {x11 failsOnUbuntu failsOnXQuarz} {
set x 0
incr x [font measure $courier "䀀"] ;# 6
incr x [font measure $courier "\002"] ;# 4
incr x [font measure $courier "\012"] ;# 2
incr x [font measure $courier "\101"] ;# 1
set x
} [expr $cx*13]
test unixfont-8.5 {AllocFont procedure: setup widths of normal chars} x11 {
test unixfont-8.5 {InitFont procedure: setup widths of normal chars} x11 {
font metrics $courier -fixed
} 1
test unixfont-8.6 {AllocFont procedure: setup widths of special chars} {x11 failsOnUbuntu failsOnXQuarz} {
test unixfont-8.6 {InitFont procedure: setup widths of special chars} {x11 failsOnUbuntu failsOnXQuarz} {
set x 0
incr x [font measure $courier "\001"] ;# 4
incr x [font measure $courier "\002"] ;# 4
incr x [font measure $courier "\012"] ;# 2
set x
} [expr $cx*10]
test unixfont-8.7 {AllocFont procedure: XA_UNDERLINE_POSITION} x11 {
test unixfont-8.7 {InitFont procedure: XA_UNDERLINE_POSITION} x11 {
catch {font actual -adobe-courier-bold-i-normal--0-0-0-0-m-0-iso8859-1}
set x {}
} {}
test unixfont-8.8 {AllocFont procedure: no XA_UNDERLINE_POSITION} x11 {
test unixfont-8.8 {InitFont procedure: no XA_UNDERLINE_POSITION} x11 {
catch {font actual --symbol-medium-r-normal--0-0-0-0-p-0-sun-fontspecific}
set x {}
} {}
test unixfont-8.9 {AllocFont procedure: XA_UNDERLINE_THICKNESS} x11 {
test unixfont-8.9 {InitFont procedure: XA_UNDERLINE_THICKNESS} x11 {
catch {font actual -adobe-courier-bold-i-normal--0-0-0-0-m-0-iso8859-1}
set x {}
} {}
test unixfont-8.10 {AllocFont procedure: no XA_UNDERLINE_THICKNESS} x11 {
test unixfont-8.10 {InitFont procedure: no XA_UNDERLINE_THICKNESS} x11 {
catch {font actual --symbol-medium-r-normal--0-0-0-0-p-0-sun-fontspecific}
set x {}
} {}
test unixfont-8.11 {AllocFont procedure: XA_UNDERLINE_POSITION was 0} x11 {
test unixfont-8.11 {InitFont procedure: XA_UNDERLINE_POSITION was 0} x11 {
catch {font actual -adobe-courier-bold-i-normal--0-0-0-0-m-0-iso8859-1}
set x {}
} {}
Expand Down
8 changes: 4 additions & 4 deletions tests/winFont.test
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ test winfont-6.1 {Tk_DrawChars procedure: loop test} -constraints win -setup {
} -result {}


test winfont-7.1 {AllocFont procedure: use old font} -constraints win -setup {
test winfont-7.1 {InitFont procedure: use old font} -constraints win -setup {
destroy .c
} -setup {
catch {font delete xyz}
Expand All @@ -366,17 +366,17 @@ test winfont-7.1 {AllocFont procedure: use old font} -constraints win -setup {
destroy .c
font delete xyz
} -result {}
test winfont-7.2 {AllocFont procedure: extract info from logfont} -constraints {
test winfont-7.2 {InitFont procedure: extract info from logfont} -constraints {
win
} -body {
font actual {arial 10 bold italic underline overstrike}
} -result {-family Arial -size 10 -weight bold -slant italic -underline 1 -overstrike 1}
test winfont-7.3 {AllocFont procedure: extract info from textmetric} -constraints {
test winfont-7.3 {InitFont procedure: extract info from textmetric} -constraints {
win
} -body {
font metric {arial 10 bold italic underline overstrike} -fixed
} -result 0
test winfont-7.4 {AllocFont procedure: extract info from textmetric} -constraints {
test winfont-7.4 {InitFont procedure: extract info from textmetric} -constraints {
win
} -body {
font metric systemfixed -fixed
Expand Down
10 changes: 5 additions & 5 deletions unix/tkUnixFont.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ typedef struct UnixFont {
* order to draw/measure all the characters
* encountered by this font so far. All fonts
* start off with one SubFont initialized by
* AllocFont() from the original set of font
* InitFont() from the original set of font
* attributes. Usually points to
* staticSubFonts, but may point to malloced
* space if there are lots of SubFonts. */
Expand Down Expand Up @@ -1813,16 +1813,16 @@ FindSubFontForChar(
ch = 0xFFFD;
}

if (FontMapLookup(&fontPtr->controlSubFont, ch)) {
return &fontPtr->controlSubFont;
}

for (i = 0; i < fontPtr->numSubFonts; i++) {
if (FontMapLookup(&fontPtr->subFontArray[i], ch)) {
return &fontPtr->subFontArray[i];
}
}

if (FontMapLookup(&fontPtr->controlSubFont, ch)) {
return &fontPtr->controlSubFont;
}

/*
* Keep track of all face names that we check, so we don't check some name
* multiple times if it can be reached by multiple paths.
Expand Down
2 changes: 1 addition & 1 deletion win/tkWinFont.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ typedef struct WinFont {
* order to draw/measure all the characters
* encountered by this font so far. All fonts
* start off with one SubFont initialized by
* AllocFont() from the original set of font
* InitFont() from the original set of font
* attributes. Usually points to
* staticSubFonts, but may point to malloced
* space if there are lots of SubFonts. */
Expand Down

0 comments on commit 1298883

Please sign in to comment.