fix get-face-list 'mono under Mac OS X and X, and delay showing children of a frame during a container sequence

svn: r6563
This commit is contained in:
Matthew Flatt 2007-06-10 09:47:19 +00:00
parent 96a8c87358
commit 1131abd11f
11 changed files with 176 additions and 49 deletions

View File

@ -62,6 +62,7 @@
(define wx-canvas% (define wx-canvas%
(make-canvas-glue% (make-canvas-glue%
(class100 (make-control% wx:canvas% 0 0 #t #t) (parent x y w h style gl-config) (class100 (make-control% wx:canvas% 0 0 #t #t) (parent x y w h style gl-config)
(inherit get-top-level)
(private-field (private-field
[tabable? #f]) [tabable? #f])
(public (public
@ -74,13 +75,16 @@
(lambda (code alpha? meta?) (lambda (code alpha? meta?)
(or meta? (not tabable?)))]) (or meta? (not tabable?)))])
(sequence (sequence
(super-init style parent x y w h style "canvas" gl-config))))) (super-init style parent x y w h (cons 'deleted style) "canvas" gl-config)
(unless (memq 'deleted style)
(send (get-top-level) show-control this #t))))))
(define (make-editor-canvas% %) (define (make-editor-canvas% %)
(class100 % (parent x y w h name style spp init-buffer) (class100 % (parent x y w h name style spp init-buffer)
(inherit get-editor force-redraw (inherit get-editor force-redraw
call-as-primary-owner min-height get-size call-as-primary-owner min-height get-size
get-hard-minimum-size set-min-height) get-hard-minimum-size set-min-height
get-top-level)
(private-field (private-field
[fixed-height? #f] [fixed-height? #f]
[fixed-height-lines 0] [fixed-height-lines 0]
@ -195,7 +199,9 @@
(when fixed-height? (update-size)))]) (when fixed-height? (update-size)))])
(sequence (sequence
(super-init style parent x y w h (or name "") style spp init-buffer) (super-init style parent x y w h (or name "") (cons 'deleted style) spp init-buffer)
(unless (memq 'deleted style)
(send (get-top-level) show-control this #t))
(when init-buffer (when init-buffer
(let ([mred (wx->mred this)]) (let ([mred (wx->mred this)])
(when mred (when mred

View File

@ -40,7 +40,7 @@
(lambda (item% x-margin-w y-margin-h stretch-x stretch-y) (lambda (item% x-margin-w y-margin-h stretch-x stretch-y)
(class100 (wx-make-window% item% #f) (window-style . args) (class100 (wx-make-window% item% #f) (window-style . args)
(inherit get-width get-height get-x get-y (inherit get-width get-height get-x get-y
get-parent get-client-size) get-parent get-client-size get-top-level)
(private-field [enabled? #t]) (private-field [enabled? #t])
(override (override
[enable [enable
@ -197,6 +197,7 @@
(set-min-height (init-min (get-height))) (set-min-height (init-min (get-height)))
(unless (memq 'deleted window-style) (unless (memq 'deleted window-style)
(send (get-top-level) show-control this #t)
;; For a pane[l], the creator must call the equivalent of the following, ;; For a pane[l], the creator must call the equivalent of the following,
;; delaying to let the panel's wx field get initialized before ;; delaying to let the panel's wx field get initialized before
;; panel-sizing methods are called ;; panel-sizing methods are called
@ -233,7 +234,7 @@
(as-exit (as-exit
(lambda () (lambda ()
(command (make-object wx:control-event% 'button)))))]) (command (make-object wx:control-event% 'button)))))])
(sequence (super-init style parent cb label x y w h style font) (sequence (super-init style parent cb label x y w h (cons 'deleted style) font)
(when border? (when border?
(send (get-top-level) add-border-button this)))))) (send (get-top-level) add-border-button this))))))
(define wx-check-box% (class100 (make-window-glue% (make-simple-control% wx:check-box%)) (mred proxy parent cb label x y w h style font) (define wx-check-box% (class100 (make-window-glue% (make-simple-control% wx:check-box%)) (mred proxy parent cb label x y w h style font)
@ -244,17 +245,17 @@
(lambda () (lambda ()
(set-value (not (get-value))) (set-value (not (get-value)))
(command (make-object wx:control-event% 'check-box)))))]) (command (make-object wx:control-event% 'check-box)))))])
(sequence (super-init mred proxy style parent cb label x y w h style font)))) (sequence (super-init mred proxy style parent cb label x y w h (cons 'deleted style) font))))
(define wx-choice% (class100 (make-window-glue% (make-simple-control% wx:choice%)) (mred proxy parent cb label x y w h choices style font) (define wx-choice% (class100 (make-window-glue% (make-simple-control% wx:choice%)) (mred proxy parent cb label x y w h choices style font)
(override (override
[handles-key-code [handles-key-code
(lambda (x alpha? meta?) (lambda (x alpha? meta?)
(or (memq x '(up down)) (or (memq x '(up down))
(and alpha? (not meta?))))]) (and alpha? (not meta?))))])
(sequence (super-init mred proxy style parent cb label x y w h choices style font)))) (sequence (super-init mred proxy style parent cb label x y w h choices (cons 'deleted style) font))))
(define wx-message% (class100 (make-window-glue% (make-simple-control% wx:message%)) (mred proxy parent label x y style font) (define wx-message% (class100 (make-window-glue% (make-simple-control% wx:message%)) (mred proxy parent label x y style font)
(override [gets-focus? (lambda () #f)]) (override [gets-focus? (lambda () #f)])
(sequence (super-init mred proxy style parent label x y style font)))) (sequence (super-init mred proxy style parent label x y (cons 'deleted style) font))))
(define wx-gauge% (define wx-gauge%
(make-window-glue% (make-window-glue%
@ -270,7 +271,7 @@
;; # pixels per unit of value. ;; # pixels per unit of value.
[pixels-per-value 1]) [pixels-per-value 1])
(sequence (sequence
(super-init style parent label range -1 -1 -1 -1 style font) (super-init style parent label range -1 -1 -1 -1 (cons 'deleted style) font)
(let-values ([(client-width client-height) (get-two-int-values (let-values ([(client-width client-height) (get-two-int-values
(lambda (a b) (get-client-size a b)))]) (lambda (a b) (get-client-size a b)))])
@ -337,7 +338,7 @@
[(wheel-up) (scroll -1) #t] [(wheel-up) (scroll -1) #t]
[(wheel-down) (scroll 1) #t] [(wheel-down) (scroll 1) #t]
[else #f])))]) [else #f])))])
(sequence (super-init style parent cb label kind x y w h choices style font label-font))))) (sequence (super-init style parent cb label kind x y w h choices (cons 'deleted style) font label-font)))))
(define wx-radio-box% (define wx-radio-box%
(make-window-glue% (make-window-glue%
@ -365,7 +366,7 @@
(set-selection i) (set-selection i)
(command (make-object wx:control-event% 'radio-box)))))]) (command (make-object wx:control-event% 'radio-box)))))])
(sequence (super-init style parent cb label x y w h choices major style font)) (sequence (super-init style parent cb label x y w h choices major (cons 'deleted style) font))
(private-field [enable-vector (make-vector (number) #t)])))) (private-field [enable-vector (make-vector (number) #t)]))))
@ -385,7 +386,7 @@
;; which looks bad. ;; which looks bad.
(sequence (sequence
(super-init style parent func label value min-val max-val -1 -1 -1 style font) (super-init style parent func label value min-val max-val -1 -1 -1 (cons 'deleted style) font)
(let-values ([(client-w client-h) (get-two-int-values (lambda (a b) (let-values ([(client-w client-h) (get-two-int-values (lambda (a b)
(get-client-size a b)))]) (get-client-size a b)))])

View File

@ -34,6 +34,7 @@
[on-size (lambda () (void))] [on-size (lambda () (void))]
[enable (lambda () (void))] [enable (lambda () (void))]
[show (lambda (on?) (void))] [show (lambda (on?) (void))]
[is-shown? (lambda () #f)]
[is-shown-to-root? (lambda () (send parent is-shown-to-root?))] [is-shown-to-root? (lambda () (send parent is-shown-to-root?))]
[is-enabled-to-root? (lambda () (send parent is-enabled-to-root?))] [is-enabled-to-root? (lambda () (send parent is-enabled-to-root?))]
[get-parent (lambda () parent)] [get-parent (lambda () parent)]
@ -454,7 +455,9 @@
child-infos child-infos
placements))]) placements))])
(sequence (sequence
(super-init style parent -1 -1 0 0 style)))) (super-init style parent -1 -1 0 0 (cons 'deleted style))
(unless (memq 'deleted style)
(send (get-top-level) show-control this #t)))))
(define (wx-make-pane% wx:panel% stretch?) (define (wx-make-pane% wx:panel% stretch?)
(class100 (make-container-glue% (make-glue% (wx-make-basic-panel% wx:panel% stretch?))) args (class100 (make-container-glue% (make-glue% (wx-make-basic-panel% wx:panel% stretch?))) args

View File

@ -95,7 +95,8 @@
[parent-for-center parent] [parent-for-center parent]
[show-ht (make-hash-table)]) [show-ht (make-hash-table)]
[fake-show-ht (make-hash-table)])
(override (override
[enable [enable
@ -196,6 +197,13 @@
(when perform-updates? (when perform-updates?
(when pending-redraws? (when pending-redraws?
(force-redraw)) (force-redraw))
(when (positive? (hash-table-count fake-show-ht))
(let ([t fake-show-ht])
(set! fake-show-ht (make-hash-table))
(hash-table-for-each
t
(lambda (win v?)
(send win really-show #t)))))
(when (positive? (hash-table-count show-ht)) (when (positive? (hash-table-count show-ht))
(let ([t show-ht]) (let ([t show-ht])
(set! show-ht (make-hash-table)) (set! show-ht (make-hash-table))
@ -220,6 +228,21 @@
(send child show show?) (send child show show?)
(hash-table-put! show-ht child show?)))] (hash-table-put! show-ht child show?)))]
[show-control
(lambda (child on?)
(if (or perform-updates?
(not on?)
(child . is-a? . wx-frame%)
(child . is-a? . wx-dialog%))
(send child really-show on?)
(begin
(if on?
(hash-table-put! fake-show-ht child #t)
(begin
(hash-table-remove! show-ht child)
(hash-table-remove! fake-show-ht child)))
(send child fake-show on?))))]
;; force-redraw: receives a message from to redraw the ;; force-redraw: receives a message from to redraw the
;; entire frame. ;; entire frame.
;; input: none ;; input: none

View File

@ -52,7 +52,8 @@
(rename [super-enable enable]) (rename [super-enable enable])
(private-field (private-field
[can-accept-drag? #f]) [can-accept-drag? #f]
[fake-shown? #f])
(public (public
[accept-drag? (lambda () can-accept-drag?)] [accept-drag? (lambda () can-accept-drag?)]
@ -77,11 +78,24 @@
(set! top-level window)] (set! top-level window)]
[else (loop (send window get-parent))]))) [else (loop (send window get-parent))])))
top-level)]) top-level)])
(public
[really-show
(lambda (on?)
(set! fake-shown? #f)
(super show on?))]
[fake-show
(lambda (on?)
(set! fake-shown? on?))])
(override (override
[show [show
(lambda (on?) (lambda (on?)
(queue-visible) (queue-visible)
(super show on?))] (send (get-top-level) show-control this on?))]
[is-shown?
(lambda ()
(or fake-shown?
(super is-shown?)))]
[enable [enable
(lambda (on?) (lambda (on?)
(queue-active) (queue-active)

View File

@ -59,7 +59,7 @@ ZLIB_INC = -I$(srcdir)/../wxcommon/zlib
PNG_A = ../wxcommon/libpng/libpng.@LIBSFX@ PNG_A = ../wxcommon/libpng/libpng.@LIBSFX@
EXTRALDFLAGS_wx_xt = EXTRALDFLAGS_wx_xt =
EXTRALDFLAGS_wx_mac = -framework Carbon -framework QuickTime -framework AGL -framework OpenGL -lz EXTRALDFLAGS_wx_mac = -framework Carbon -framework Cocoa -framework QuickTime -framework AGL -framework OpenGL -lz
MREDLDFLAGS = $(LDFLAGS) $(EXTRALDFLAGS_@WXVARIANT@) MREDLDFLAGS = $(LDFLAGS) $(EXTRALDFLAGS_@WXVARIANT@)
WXLIBS_wx_xt = ../wxxt/src/libwx_xt.@LIBSFX@ ../wxxt/contrib/xpm/lib/libXpm.@LIBSFX@ ../wxxt/utils/image/src/libimage_xt.@LIBSFX@ WXLIBS_wx_xt = ../wxxt/src/libwx_xt.@LIBSFX@ ../wxxt/contrib/xpm/lib/libXpm.@LIBSFX@ ../wxxt/utils/image/src/libimage_xt.@LIBSFX@
MREDX_wx_xt = mredx.@LTO@ MREDX_wx_xt = mredx.@LTO@

View File

@ -1337,8 +1337,11 @@ wx_mac_PLAIN_OBJS = \
xform: $(XSRCS) xsrc/xcglue.c xform: $(XSRCS) xsrc/xcglue.c
wx_font.o : $(srcdir)/../../wxmac/src/mac/wx_font.m
$(CXX) -o wx_font.o -c $(srcdir)/../../wxmac/src/mac/wx_font.m
wx_xt_LIBS = ../../wxxt/contrib/xpm/lib/libXpm.@LTA@ @JPEG_A@ @PNG_A@ @ZLIB_A@ wx_xt_LIBS = ../../wxxt/contrib/xpm/lib/libXpm.@LTA@ @JPEG_A@ @PNG_A@ @ZLIB_A@
wx_mac_LIBS = -framework Carbon -framework QuickTime -framework AGL -framework OpenGL @JPEG_A@ @PNG_A@ -lz @LIBS@ wx_mac_LIBS = -framework Carbon -framework Cocoa -framework QuickTime -framework AGL -framework OpenGL @JPEG_A@ @PNG_A@ -lz @LIBS@
MREDLINKER = @MREDLINKER@ MREDLINKER = @MREDLINKER@
@ -1375,8 +1378,8 @@ MRFWRES = PLT_MrEd.framework/Versions/$(FWVERSION)_3m/Resources/PLT_MrEd.rsrc
cp -r "PLT_MrEd.framework/Versions/$(FWVERSION)_3m/Resources" "../PLT_MrEd.framework/Versions/$(FWVERSION)_3m/Resources" cp -r "PLT_MrEd.framework/Versions/$(FWVERSION)_3m/Resources" "../PLT_MrEd.framework/Versions/$(FWVERSION)_3m/Resources"
/usr/bin/install_name_tool -change "PLT_MrEd.framework/Versions/$(FWVERSION)_3m/PLT_MrEd" "@executable_path/../../../PLT_MrEd.framework/Versions/$(FWVERSION)_3m/PLT_MrEd" "../MrEd@MMM@.app/Contents/MacOS/MrEd@MMM@" /usr/bin/install_name_tool -change "PLT_MrEd.framework/Versions/$(FWVERSION)_3m/PLT_MrEd" "@executable_path/../../../PLT_MrEd.framework/Versions/$(FWVERSION)_3m/PLT_MrEd" "../MrEd@MMM@.app/Contents/MacOS/MrEd@MMM@"
$(MRFW) : $(XOBJS) $(@WXVARIANT@_PLAIN_OBJS) ../../mzscheme/libmzscheme3m.@LIBSFX@ $(MRFW) : $(XOBJS) $(@WXVARIANT@_PLAIN_OBJS) ../../mzscheme/libmzscheme3m.@LIBSFX@ wx_font.o
$(MREDLINKER) -dynamiclib -o $(MRFW) -Wl,-headerpad_max_install_names $(XOBJS) $(@WXVARIANT@_PLAIN_OBJS) ../../mzscheme/libmzscheme3m.@LIBSFX@ $(@WXVARIANT@_LIBS) @X_EXTRA_LIBS@ $(MREDLINKER) -dynamiclib -o $(MRFW) -Wl,-headerpad_max_install_names $(XOBJS) $(@WXVARIANT@_PLAIN_OBJS) ../../mzscheme/libmzscheme3m.@LIBSFX@ $(@WXVARIANT@_LIBS) @X_EXTRA_LIBS@ wx_font.o
$(MRFWRES): $(srcdir)/../../mac/osx_appl.ss $(srcdir)/../../mac/cw/MrEd.r $(MRFWRES): $(srcdir)/../../mac/osx_appl.ss $(srcdir)/../../mac/cw/MrEd.r
rm -rf PLT_MrEd.framework/Resources PLT_MrEd.framework/PLT_MrEd rm -rf PLT_MrEd.framework/Resources PLT_MrEd.framework/PLT_MrEd

View File

@ -61,7 +61,7 @@ extern void wx_release_lazy_regions();
#ifdef WX_USE_XFT #ifdef WX_USE_XFT
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
extern char **wxGetCompleteFaceList(int *_len); extern char **wxGetCompleteFaceList(int *_len, int mono_only);
#endif #endif
#ifdef wx_mac #ifdef wx_mac
@ -1021,6 +1021,20 @@ static int indirect_strcmp(const void *a, const void *b)
{ {
return strcmp(*(char **)a, *(char **)b); return strcmp(*(char **)a, *(char **)b);
} }
static int is_x_monospace(char *s)
{
if (s[0] == '-') {
/* Full X font name. Check for "-m-" in name. */
int j;
for (j = 0; s[j+2]; j++) {
if ((s[j] == '-') && (s[j+1] == 'm') && (s[j+2] == '-'))
return 1;
}
}
return 0;
}
#endif #endif
@ -1141,12 +1155,16 @@ char *wx_get_mac_font_name(FMFontFamily fam, unsigned char *fname, int *_l)
typedef int (*Indirect_Cmp_Proc)(const void *, const void *); typedef int (*Indirect_Cmp_Proc)(const void *, const void *);
#ifdef wx_mac
extern "C" int wx_isFamilyFixedWidth(FMFontFamily fam);
#endif
static Scheme_Object *wxSchemeGetFontList(int argc, Scheme_Object **argv) static Scheme_Object *wxSchemeGetFontList(int argc, Scheme_Object **argv)
{ {
Scheme_Object *first = scheme_null, *last = NULL; Scheme_Object *first = scheme_null, *last = NULL;
int mono_only = 0; int mono_only = 0;
#ifdef wx_x #ifdef wx_x
int count, i = 0; int count, i = 0, pos;
char **xnames, **names; char **xnames, **names;
int last_pos = -1, last_len = 0; int last_pos = -1, last_len = 0;
#endif #endif
@ -1180,11 +1198,13 @@ static Scheme_Object *wxSchemeGetFontList(int argc, Scheme_Object **argv)
xnames = XListFonts(wxAPP_DISPLAY, "*", 50000, &count); xnames = XListFonts(wxAPP_DISPLAY, "*", 50000, &count);
names = (char **)scheme_malloc_atomic(sizeof(char*)*count); names = (char **)scheme_malloc_atomic(sizeof(char*)*count);
pos = 0;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
names[i] = xnames[i]; if (!mono_only || is_x_monospace(xnames[i]))
names[pos++] = xnames[i];
} }
qsort(names, count, sizeof(char *), qsort(names, pos, sizeof(char *),
(Indirect_Cmp_Proc)indirect_strcmp); (Indirect_Cmp_Proc)indirect_strcmp);
i = 0; i = 0;
@ -1211,12 +1231,12 @@ static Scheme_Object *wxSchemeGetFontList(int argc, Scheme_Object **argv)
Scheme_Object *pr; Scheme_Object *pr;
#ifdef wx_x #ifdef wx_x
while ((i < count) while ((i < pos)
&& ((last_pos >= 0) && ((last_pos >= 0)
&& !strncmp(names[i], names[last_pos], last_len))) { && !strncmp(names[i], names[last_pos], last_len))) {
i++; i++;
} }
if (i >= count) if (i >= pos)
break; break;
last_pos = i; last_pos = i;
@ -1249,6 +1269,8 @@ static Scheme_Object *wxSchemeGetFontList(int argc, Scheme_Object **argv)
#ifdef wx_mac #ifdef wx_mac
if (FMGetNextFontFamily(&iterator, &fam) != noErr) if (FMGetNextFontFamily(&iterator, &fam) != noErr)
break; break;
if (mono_only && !wx_isFamilyFixedWidth(fam))
continue;
s = wx_get_mac_font_name(fam, fname, &l); s = wx_get_mac_font_name(fam, fname, &l);
#endif #endif
#ifdef wx_msw #ifdef wx_msw
@ -1271,8 +1293,8 @@ static Scheme_Object *wxSchemeGetFontList(int argc, Scheme_Object **argv)
} }
#ifdef wx_x #ifdef wx_x
XFreeFontNames(xnames); XFreeFontNames(xnames);
xnames = NULL; xnames = NULL;
#endif #endif
#ifdef wx_msw #ifdef wx_msw
ReleaseDC(NULL, dc); ReleaseDC(NULL, dc);
@ -1289,7 +1311,7 @@ static Scheme_Object *wxSchemeGetFontList(int argc, Scheme_Object **argv)
char **fl; char **fl;
int len, i; int len, i;
fl = wxGetCompleteFaceList(&len); fl = wxGetCompleteFaceList(&len, mono_only);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
first = scheme_make_pair(scheme_make_utf8_string(fl[i]), first); first = scheme_make_pair(scheme_make_utf8_string(fl[i]), first);

View File

@ -146,6 +146,8 @@ OBJS = \
wx_24to8.o \ wx_24to8.o \
wx_image.o \ wx_image.o \
wx_xbm.o \ wx_xbm.o \
\
wx_font.o \
\ \
$(MIN_OBJS) $(MIN_OBJS)
@ -388,6 +390,13 @@ ALHeirarchical.o : $(ALISTDEPS) $(ALISTDIR)/ALHeirarchical.c
ALSelectors.o : $(ALISTDEPS) $(ALISTDIR)/ALSelectors.c ALSelectors.o : $(ALISTDEPS) $(ALISTDIR)/ALSelectors.c
$(CC) $(ALISTCCFLAGS) -o ALSelectors.o -c $(ALISTDIR)/ALSelectors.c $(CC) $(ALISTCCFLAGS) -o ALSelectors.o -c $(ALISTDIR)/ALSelectors.c
########################################
# Cocoa fonts #
########################################
wx_font.o : $(srcdir)/mac/wx_font.m
$(CXX) -o wx_font.o -c $(srcdir)/mac/wx_font.m
######################################## ########################################
# Make Depends # # Make Depends #
######################################## ########################################

View File

@ -0,0 +1,28 @@
/* The easiest way to find out whether a font is fixed-width is to
jump over the to Coacao world. The ATS and Cocoa worlds are
connected through the PostScript name of a font. */
#import <Cocoa/Cocoa.h>
int wx_isFamilyFixedWidth(FMFontFamily fam)
{
FMFont fnt;
StyleParameter intrinsic;
if (!FMGetFontFromFontFamilyInstance(fam, 0, &fnt, &intrinsic)) {
ATSFontRef ats;
ats = FMGetATSFontRefFromFont(fnt);
if (ats) {
CFStringRef ref;
NSFont *nsfnt;
if (!ATSFontGetPostScriptName(ats, kATSOptionFlagsDefault, &ref)) {
nsfnt = [NSFont fontWithName: (NSString *)ref size: 12];
CFRelease(ref);
return [nsfnt isFixedPitch];
}
}
}
return 0;
}

View File

@ -76,30 +76,38 @@ static int complete_face_list_size;
static char **complete_face_list; static char **complete_face_list;
static wxFontStruct **complete_font_list; static wxFontStruct **complete_font_list;
char **wxGetCompleteFaceList(int *_len) char **wxGetCompleteFaceList(int *_len, int mono_only)
{ {
char buf[256], *s, *copy; char buf[256], *s, *copy;
int ssize, i, j, pos, len, scalable; int ssize, i, j, pos, len, scalable;
XftFontSet *fs; XftFontSet *fs;
int face_list_size;
char **face_list;
wxFontStruct **font_list;
if (complete_face_list) { if (complete_face_list && !mono_only) {
if (_len) if (_len)
*_len = complete_face_list_size; *_len = complete_face_list_size;
return complete_face_list; return complete_face_list;
} }
fs = XftListFonts(wxAPP_DISPLAY, DefaultScreen(wxAPP_DISPLAY), NULL, if (mono_only) {
/* I'm assuming that every family is either fs = XftListFonts(wxAPP_DISPLAY, DefaultScreen(wxAPP_DISPLAY),
scalable or not. We inspect scalability XFT_SPACING, XftTypeInteger, XFT_MONO, NULL,
to bias substitution to scalable fonts */ /* I'm assuming that every family is either
XFT_FAMILY, XFT_SCALABLE, scalable or not. We inspect scalability
NULL); to bias substitution to scalable fonts */
XFT_FAMILY, XFT_SCALABLE,
NULL);
} else {
fs = XftListFonts(wxAPP_DISPLAY, DefaultScreen(wxAPP_DISPLAY), NULL,
XFT_FAMILY, XFT_SCALABLE,
NULL);
}
complete_face_list_size = fs->nfont; face_list_size = fs->nfont;
wxREGGLOB(complete_face_list); face_list = new WXGC_PTRS char*[face_list_size];
wxREGGLOB(complete_font_list); font_list = (wxFontStruct **)(new WXGC_ATOMIC char[sizeof(wxFontStruct*) * face_list_size]);
complete_face_list = new WXGC_PTRS char*[complete_face_list_size];
complete_font_list = (wxFontStruct **)(new WXGC_ATOMIC char[sizeof(wxFontStruct*) * complete_face_list_size]);
pos = 0; pos = 0;
for (i = 0; i < fs->nfont; i++) { for (i = 0; i < fs->nfont; i++) {
@ -130,19 +138,29 @@ char **wxGetCompleteFaceList(int *_len)
copy[len + 1] = 0; copy[len + 1] = 0;
if (scalable) { if (scalable) {
complete_face_list[pos] = copy; face_list[pos] = copy;
complete_font_list[pos] = NULL; font_list[pos] = NULL;
pos++; pos++;
} else { } else {
/* unscalable at end, to discourage use in substitutions */ /* unscalable at end, to discourage use in substitutions */
j = fs->nfont - (i - pos) - 1; j = fs->nfont - (i - pos) - 1;
complete_face_list[j] = copy; face_list[j] = copy;
complete_font_list[j] = NULL; font_list[j] = NULL;
} }
} }
XftFontSetDestroy(fs); XftFontSetDestroy(fs);
return wxGetCompleteFaceList(_len); if (!mono_only) {
wxREGGLOB(complete_face_list);
wxREGGLOB(complete_font_list);
complete_face_list_size = face_list_size;
complete_face_list = face_list;
complete_font_list = font_list;
}
if (_len)
*_len = face_list_size;
return face_list;
} }
static wxFontStruct *prev_subs; static wxFontStruct *prev_subs;
@ -153,7 +171,7 @@ static wxFontStruct *doFindAAFont(Display *dpy, wxFontStruct *xfont, int c, int
wxFontStruct *naya; wxFontStruct *naya;
int i; int i;
wxGetCompleteFaceList(NULL); wxGetCompleteFaceList(NULL, 0);
for (i = 0; i < complete_face_list_size; i++) { for (i = 0; i < complete_face_list_size; i++) {
if (!complete_font_list[i]) { if (!complete_font_list[i]) {
@ -590,7 +608,7 @@ void *wxFont::GetNextAASubstitution(int index, int cval, double scale_x, double
} }
if (!name[i]) { if (!name[i]) {
if (index == c + 1) { if (index == c + 1) {
wxGetCompleteFaceList(NULL); wxGetCompleteFaceList(NULL, 0);
c = -1; c = -1;
doFindAAFont(wxAPP_DISPLAY, NULL, cval, &c); doFindAAFont(wxAPP_DISPLAY, NULL, cval, &c);
if (c >= 0) { if (c >= 0) {