Skip to content

Commit 2a09931

Browse files
committed
Extend tests and fix some issue with pkgIndex.tcl
1 parent 75ad845 commit 2a09931

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/pkgIndex.tcl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package ifneeded extrafont 1.2 [list apply { dir {
22
package require Tk
3-
4-
set thisDir [file normalize ${dir}]
3+
4+
if {![info exists $dir]} {
5+
set dir [pwd]
6+
}
57

68
set os $::tcl_platform(platform)
79
switch -- $os {
@@ -19,16 +21,16 @@ package ifneeded extrafont 1.2 [list apply { dir {
1921
switch -- $arch {
2022
4 { set arch x32 }
2123
8 { set arch x64 }
22-
default { error "extrafont: Unsupported architecture: Unexpected pointer-size $arch!!! "}
24+
default { error "extrafont: Unsupported architecture: Unexpected pointer-size $arch"}
2325
}
2426

2527

2628
set libfile_abspath [file join [file normalize $dir] $libfile]
2729
load $libfile_abspath
2830

2931
namespace eval extrafont {}
30-
source [file join $thisDir extrafont.tcl]
31-
source [file join $thisDir futmp.tcl]
32+
source [file join $dir extrafont.tcl]
33+
source [file join $dir futmp.tcl]
3234

3335
package provide extrafont 1.2
3436

tests/overhaul.ttf

1.2 MB
Binary file not shown.

tests/test_tkextrafont.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,26 @@
66
import tkinter as tk
77
import tkextrafont
88
from unittest import TestCase
9+
import os
910

1011

1112
class TestTkExtraFont(TestCase):
13+
"""Test the compiled extrafont binary with a public-domain font"""
14+
15+
PATH = os.path.abspath(os.path.dirname(__file__))
1216

1317
def setUp(self):
1418
self.window = tk.Tk()
1519
tkextrafont.load_extrafont(self.window)
1620

1721
def test_font_load(self):
18-
# self.window.load_font()\
19-
pass
22+
assert not self.window.is_font_available("Overhaul")
23+
loaded = set(self.window.loaded_fonts())
24+
self.window.load_font(os.path.join(self.PATH, "overhaul.ttf"))
25+
assert len(list(set(self.window.loaded_fonts()) - loaded)) != 0
26+
assert self.window.is_font_available("Overhaul")
27+
assert "Overhaul" in self.window.loaded_fonts()
28+
29+
label = tk.Label(self.window, text="Overhaul font", font=("Overhaul", 12, "bold"))
30+
label.pack()
31+
self.window.update()

0 commit comments

Comments
 (0)