summaryrefslogtreecommitdiff
path: root/!NetSurf/FixFonts,ffb
blob: c6b73d0b024635f09dcbf2ce4031a23ef4c92d5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
REM Attempt to fix broken font installations which have non-Base0 copies of the
REM ROM fonts in !Fonts on disc.

ON ERROR ON ERROR OFF: PRINT REPORT$ + " (at line " + STR$ERL + ")": END

DIM f$(11)
f$() = "Corpus.Bold","Corpus.Bold.Oblique","Corpus.Medium","Corpus.Medium.Oblique","Homerton.Bold","Homerton.Bold.Oblique","Homerton.Medium","Homerton.Medium.Oblique","Trinity.Bold","Trinity.Bold.Italic","Trinity.Medium","Trinity.Medium.Italic"

PRINT "FONT INSTALLATION FIX"
PRINT

PRINT "Checking ROM fonts"
PRINT
ok% = TRUE
FOR f% = 0 TO 11
    PROCcheck_rom_font(f$(f%))
NEXT
PRINT
IF NOT ok% THEN
    PRINT "One or more of the standard ROM fonts are missing!"
    PRINT "Please contact the developers stating your RISC OS version."
    END
ENDIF


PRINT "Searching for obsolete copies in Boot:Resources.!Fonts"
PRINT
ok% = TRUE
FOR f% = 0 TO 11
    PROCcheck_disc_font(f$(f%))
NEXT
PRINT
IF ok% THEN
    PRINT "No problems were found."
    END
ENDIF

PRINT "One or more obsolete fonts were found in !Fonts."
PRINT
PRINT "Press Y to move these fonts to a new directory"
PRINT "called 'ObsolFonts' and remove them from the"
PRINT "font list ('Messages1'),"
PRINT "or any other key to exit without changes."
key$ = GET$
IF INSTR("Yy", key$) = 0 THEN
    PRINT
    PRINT "Exiting without changes."
    END
ENDIF
PRINT

PRINT "Creating 'ObsolFonts' directory - ";
SYS"OS_File", 8, "<Boot$Dir>.^.ObsolFonts"
PRINT "done"
PRINT
PRINT "Closing open files - ";
SYS"OS_FSControl", 22
PRINT "done"
PRINT
PRINT "Removing fonts from font list - ";
file% = OPENIN "<Boot$Dir>.Resources.!Fonts.Messages1"
IF file% THEN
    new% = OPENOUT "<Boot$Dir>.Resources.!Fonts.Messages_"
    IF new% = 0 THEN
        PRINT "Failed to open new font list"
        END
    ENDIF
    WHILE NOT EOF#file%
        line$ = GET$#file%
        ok% = TRUE
        FOR f% = 0 TO 11
            IF INSTR(line$, "Font_" + f$(f%) + ":") <> 0 THEN ok% = FALSE
        NEXT
        IF ok% THEN
            BPUT#new%, line$
        ENDIF
    ENDWHILE
    CLOSE#file%
    CLOSE#new%
    SYS"OS_File", 18, "<Boot$Dir>.Resources.!Fonts.Messages_", &fff
    SYS"XOS_FSControl", 27, "<Boot$Dir>.^.ObsolFonts.Messages1"
    SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts.Messages1", "<Boot$Dir>.^.ObsolFonts.Messages1"
    SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts.Messages_", "<Boot$Dir>.Resources.!Fonts.Messages1"
ENDIF
PRINT "done"
PRINT
PRINT "Moving away obsolete fonts"
PRINT
FOR f% = 0 TO 11
    PROCfix_font(f$(f%))
NEXT
PRINT
PRINT "Finished"
PRINT "Please restart your machine for the changes to take effect."

END



DEF PROCcheck_rom_font(f$)
PRINT "  "; f$;
SYS"OS_File", 17, "Resources:$.Fonts." + f$ + ".Outlines0" TO t1%
SYS"OS_File", 17, "Resources:$.Fonts." + f$ + ".IntMetric0" TO t2%
IF t1% = 1 AND t2% = 1 THEN
    PRINT " - ok"
ELSE
    PRINT " - MISSING"
    ok% = FALSE
ENDIF
ENDPROC



DEF PROCcheck_disc_font(f$)
SYS"OS_File", 17, "<Boot$Dir>.Resources.!Fonts." + f$ + ".Outlines" TO t%
IF t% <> 0 THEN
    PRINT "  "; f$
    ok% = FALSE
ENDIF
ENDPROC



DEF PROCfix_font(f$)
SYS"OS_File", 17, "<Boot$Dir>.Resources.!Fonts." + f$ + ".Outlines" TO t%
IF t% = 0 THEN ENDPROC

PRINT "  "; f$; " - ";
i% = 0
REPEAT
    i% = INSTR(f$, ".", i% + 1)
    IF i% <> 0 THEN
        SYS"OS_File", 8, "<Boot$Dir>.^.ObsolFonts." + LEFT$(f$, i% - 1)
    ENDIF
UNTIL i% = 0
SYS"OS_File", 8, "<Boot$Dir>.^.ObsolFonts." + f$

SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts." + f$ + ".Outlines", "<Boot$Dir>.^.ObsolFonts." + f$ + ".Outlines"

SYS"OS_File", 17, "<Boot$Dir>.Resources.!Fonts." + f$ + ".IntMetrics" TO t%
IF t% <> 0 THEN
    SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts." + f$ + ".IntMetrics", "<Boot$Dir>.^.ObsolFonts." + f$ + ".IntMetrics"
ENDIF

PRINT "done"
ENDPROC