From 60934b6b7312054ccd5fd63ac1a810407071efb8 Mon Sep 17 00:00:00 2001 From: Chris Ridd Date: Sun, 1 May 2022 19:44:10 +0100 Subject: [PATCH] Change font sizes from short to fix31 font->size (short) has been renamed and is now replaced with font->extra.size (fix31). Many C interfaces are now changed to take fix31 sizes, and to convert back to short when necessary. New assembly macros are added for fix31<->short conversions, and to slightly improve readability. The GNU macros are tested, which also work with PortAsm. The other macro versions are hopefully correct. vst_arbpt32() is now supported correctly. Papyrus uses this a lot. --- fvdi/engine/fonts.c | 10 +++-- fvdi/engine/loader.c | 4 +- fvdi/engine/text_sq.s | 39 +++++++++++++------ fvdi/engine/textlib.c | 21 ++++++----- fvdi/include/function.h | 6 +-- fvdi/include/fvdi.h | 7 +++- fvdi/include/macros.dev | 21 +++++++++++ fvdi/include/macros.gnu | 21 +++++++++++ fvdi/include/macros.tas | 21 +++++++++++ fvdi/include/types.inc | 21 ++++++----- fvdi/modules/ft2/ft2.c | 83 +++++++++++++++++++++-------------------- 11 files changed, 172 insertions(+), 82 deletions(-) diff --git a/fvdi/engine/fonts.c b/fvdi/engine/fonts.c index a4923aa..dfbbf24 100644 --- a/fvdi/engine/fonts.c +++ b/fvdi/engine/fonts.c @@ -88,7 +88,7 @@ long DRIVER_EXPORT fixup_font(Fontheader *header, char *buffer, long flip) if (flip) { - flip_words(&header->id, (&header->size - &header->id) + 1); + flip_words(&header->id, (&header->dummy - &header->id) + 1); flip_words(&header->code.low, (&header->flags - &header->code.low) + 1); flip_longs(&header->table.horizontal, ((long)&header->data - (long)&header->table.horizontal) / sizeof(long) + 1); @@ -112,6 +112,7 @@ long DRIVER_EXPORT fixup_font(Fontheader *header, char *buffer, long flip) header->extra.distance.descent = -top - header->distance.descent; header->extra.distance.top = 0; + header->extra.size = SHORT_TO_FIX31(header->dummy); header->extra.format = 0x01; /* 1 - Bitmap, 2 - Speedo etc */ header->extra.unpacked.data = 0; /* No smart formats yet */ @@ -175,7 +176,8 @@ Fontheader *load_font(const char *name) long DRIVER_EXPORT insert_font(Fontheader **first_font, Fontheader *new_font) { Fontheader *current_font, *last_font, **previous; - int new_id, new_size; + int new_id; + fix31 new_size; /* * Find first font with higher or equal ID @@ -216,9 +218,9 @@ long DRIVER_EXPORT insert_font(Fontheader **first_font, Fontheader *new_font) * Find first font with larger or equal size */ - new_size = new_font->size; + new_size = new_font->extra.size; last_font = 0; - while (current_font && (current_font->size < new_size)) + while (current_font && (current_font->extra.size < new_size)) { last_font = current_font; current_font = current_font->extra.next_size; diff --git a/fvdi/engine/loader.c b/fvdi/engine/loader.c index 23e8202..285b928 100644 --- a/fvdi/engine/loader.c +++ b/fvdi/engine/loader.c @@ -38,7 +38,7 @@ Fontheader *(*external_load_font)(Virtual *vwk, const char *font) = ft2_load_fon long (*external_vqt_extent)(Virtual *vwk, Fontheader *font, short *text, long length) = ft2_text_width; long (*external_vqt_width)(Virtual *vwk, Fontheader *font, long ch) = ft2_char_width; long (*external_vst_effects)(Virtual *vwk, Fontheader *font, long effects) = ft2_set_effects; -Fontheader *(*external_vst_point)(Virtual *vwk, long size, short *sizes) = ft2_vst_point; +Fontheader *(*external_vst_point)(Virtual *vwk, fix31 size, short *sizes) = ft2_vst_point; long (*external_renderer)(Virtual *vwk, unsigned long coords, short *text, long length) = ft2_text_render_default; void *(*external_char_bitmap)(Virtual *vwk, Fontheader *font, long ch, short *bitmap_info) = ft2_char_bitmap; void *(*external_char_advance)(Virtual *vwk, Fontheader *font, long ch, short *advance_info) = ft2_char_advance; @@ -54,7 +54,7 @@ Fontheader *(*external_load_font)(Virtual *vwk, const char *font) = 0; long (*external_vqt_extent)(Virtual *vwk, Fontheader *font, short *text, long length) = 0; long (*external_vqt_width)(Virtual *vwk, Fontheader *font, long ch) = 0; long (*external_vst_effects)(Virtual *vwk, Fontheader *font, long effects) = 0; -Fontheader *(*external_vst_point)(Virtual *vwk, long size, short *sizes) = 0; +Fontheader *(*external_vst_point)(Virtual *vwk, fix31 size, short *sizes) = 0; long (*external_renderer)(Virtual *vwk, unsigned long coords, short *text, long length) = 0; void *(*external_char_bitmap)(Virtual *vwk, Fontheader *font, long ch, short *bitmap_info) = 0; void *(*external_char_advance)(Virtual *vwk, Fontheader *font, long ch, short *advance_info) = 0; diff --git a/fvdi/engine/text_sq.s b/fvdi/engine/text_sq.s index d2852ab..bcfef13 100644 --- a/fvdi/engine/text_sq.s +++ b/fvdi/engine/text_sq.s @@ -854,7 +854,7 @@ vst_height: movem.l d0-d2/a0-a2,-(a7) move.l _vdi_stack_size,-(a7) move.l #0,-(a7) - ext.l d0 + ext.l d0 move.l d0,-(a7) move.l a0,-(a7) ; VDI struct jsr (a3) @@ -925,9 +925,17 @@ vst_arbpt: pea 4(a2) pea 2(a2) pea 0(a2) + move.l control(a1),a2 + cmp.w #2,L_intin(a2) ; 2 = vst_arbpt32(), 1 = vst_arbpt() move.l intin(a1),a2 + bne short_height + move.l (a2),d0 + bra got_height +short_height: move.w (a2),d0 ext.l d0 + swap d0 +got_height: move.l d0,-(a7) move.l a0,-(a7) jsr _lib_vst_arbpt @@ -936,8 +944,16 @@ vst_arbpt: endc add.w #6*4,a7 movem.l (a7)+,d2/a1 + move.l control(a1),a2 + cmp.w #2,L_intin(a2) ; 2 = vst_arbpt32(), 1 = vst_arbpt() move.l intout(a1),a2 + bne short_return + move.l d0,(a2) + bra got_return +short_return: + swap d0 move.w d0,(a2) +got_return: used_d1 done_return @@ -945,7 +961,7 @@ vst_arbpt: uses_d1 move.l a3,-(a7) move.l intin(a1),a2 - move.w (a2),d0 + short_to_fix31 (a2),d0 move.l vwk_text_current_font(a0),a2 * Some other method should be used for this! @@ -963,7 +979,6 @@ vst_arbpt: movem.l d0-d2/a0-a2,-(a7) move.l _vdi_stack_size,-(a7) move.l #0,-(a7) - ext.l d0 move.l d0,-(a7) move.l a0,-(a7) ; VDI struct jsr (a3) @@ -991,7 +1006,8 @@ vst_arbpt: move.w font_height(a3),d1 move.w d1,(a2)+ ; Height in pixels move.l d1,vwk_text_cell(a0) ; Cell w/h in vwk - move.w font_size(a3),(a1) + move.l font_extra_size(a3),d1 + fix31_to_short d1,(a1) .no_external_vst_arbpt: move.l (a7)+,a3 @@ -1014,8 +1030,7 @@ vst_point: pea 2(a2) pea 0(a2) move.l intin(a1),a2 - move.w (a2),d0 - ext.l d0 + short_to_fix31 (a2),d0 move.l d0,-(a7) move.l a0,-(a7) jsr _lib_vst_point @@ -1025,7 +1040,7 @@ vst_point: add.w #6*4,a7 movem.l (a7)+,d2/a1 move.l intout(a1),a2 - move.w d0,(a2) + fix31_to_short d0,(a2) used_d1 ifne 0 move.l vwk_text_current_font(a0),a0 @@ -1044,7 +1059,7 @@ vst_point: uses_d1 move.l a3,-(a7) move.l intin(a1),a2 - move.w (a2),d0 + short_to_fix31 (a2),d0 move.l vwk_text_current_font(a0),a2 * Some other method should be used for this! @@ -1054,7 +1069,7 @@ vst_point: move.l font_extra_first_size(a2),a2 move.l a2,a3 label .search,1 - cmp.w font_size(a2),d0 + cmp.l font_extra_size(a2),d0 lblo .found,2 move.l a2,a3 move.l font_extra_next_size(a2),a2 @@ -1082,7 +1097,8 @@ vst_point: move.w font_height(a3),d1 move.w d1,(a2)+ ; Height in pixels move.l d1,vwk_text_cell(a0) ; Cell w/h in vwk - move.w font_size(a3),(a1) + move.l font_extra_size(a3),d1 + fix31_to_short d1,(a1) move.l (a7)+,a3 used_d1 ifne 0 @@ -1110,8 +1126,7 @@ vst_point: movem.l d0-d2/a0-a2,-(a7) move.l _vdi_stack_size,-(a7) pea _sizes - ext.l d0 - move.l d0,-(a7) + short_to_fix31 d0,-(a7) move.l a0,-(a7) ; VDI struct jsr (a3) add.w #4*4,a7 diff --git a/fvdi/engine/textlib.c b/fvdi/engine/textlib.c index e3f0255..110c42d 100644 --- a/fvdi/engine/textlib.c +++ b/fvdi/engine/textlib.c @@ -170,7 +170,8 @@ static Fontheader *find_font_by_id(Fontheader *font, long id, long *index) int lib_vst_font(Virtual *vwk, long fontID) { Fontheader *font; - short dummy, size; + short dummy; + fix31 size; if (!fontID) fontID = 1; @@ -194,9 +195,9 @@ int lib_vst_font(Virtual *vwk, long fontID) } if (vwk->text.current_font) - size = vwk->text.current_font->size; + size = vwk->text.current_font->extra.size; else - size = 10; + size = SHORT_TO_FIX31(10); vwk->text.font = fontID; set_current_font(vwk, font); @@ -377,7 +378,7 @@ void CDECL lib_vqt_xfntinfo(Virtual *vwk, long flags, long id, long index, XFNT_ font = font->extra.first_size; while (font) { - info->pt_sizes[i] = font->size; + info->pt_sizes[i] = FIX31_TO_SHORT(font->extra.size); i++; font = font->extra.next_size; } @@ -568,7 +569,7 @@ void CDECL lib_vqt_extent(Virtual *vwk, long length, short *string, short *point } -int lib_vst_point(Virtual *vwk, long height, short *charw, short *charh, short *cellw, short *cellh) +fix31 lib_vst_point(Virtual *vwk, fix31 height, short *charw, short *charh, short *cellw, short *cellh) { Fontheader *font; @@ -591,7 +592,7 @@ int lib_vst_point(Virtual *vwk, long height, short *charw, short *charh, short * { font = vwk->text.current_font->extra.first_size; - while (font->extra.next_size && (font->extra.next_size->size <= height)) + while (font->extra.next_size && (font->extra.next_size->extra.size <= height)) { font = font->extra.next_size; } @@ -604,11 +605,11 @@ int lib_vst_point(Virtual *vwk, long height, short *charw, short *charh, short * *cellw = vwk->text.cell.width = font->widest.cell; *cellh = vwk->text.cell.height = font->height; - return font->size; + return font->extra.size; } -int CDECL lib_vst_arbpt(Virtual *vwk, long height, short *charw, short *charh, short *cellw, short *cellh) +fix31 CDECL lib_vst_arbpt(Virtual *vwk, fix31 height, short *charw, short *charh, short *cellw, short *cellh) { Fontheader *font; @@ -631,7 +632,7 @@ int CDECL lib_vst_arbpt(Virtual *vwk, long height, short *charw, short *charh, s { font = vwk->text.current_font->extra.first_size; - while (font->extra.next_size && (font->extra.next_size->size <= height)) + while (font->extra.next_size && (font->extra.next_size->extra.size <= height)) { font = font->extra.next_size; } @@ -644,7 +645,7 @@ int CDECL lib_vst_arbpt(Virtual *vwk, long height, short *charw, short *charh, s *cellw = vwk->text.cell.width = font->widest.cell; *cellh = vwk->text.cell.height = font->height; - return font->size; + return font->extra.size; } diff --git a/fvdi/include/function.h b/fvdi/include/function.h index 3292a27..fe0aba0 100644 --- a/fvdi/include/function.h +++ b/fvdi/include/function.h @@ -75,7 +75,7 @@ void init_interrupts(void); void reset_interrupts(void); int lib_vst_font(Virtual *vwk, long fontID); -int lib_vst_point(Virtual *vwk, long height, short *charw, short *charh, short *cellw, short *cellh); +fix31 lib_vst_point(Virtual *vwk, fix31 height, short *charw, short *charh, short *cellw, short *cellh); void lib_vrt_cpyfm_nocheck(Virtual *vwk, short mode, short *pxy, MFDB *src, MFDB *dst, short colors[]); void lib_vro_cpyfm(Virtual *vwk, short mode, short *pxy, MFDB *src, MFDB *dst); void lib_vs_clip(Virtual *, short, short *); @@ -91,7 +91,7 @@ long CDECL lib_vqt_name(Virtual * vwk, long number, short *name); void CDECL lib_vqt_fontinfo(Virtual *vwk, short *intout, short *ptsout); void CDECL lib_vqt_xfntinfo(Virtual *vwk, long flags, long id, long index, XFNT_INFO *info); void CDECL lib_vqt_fontheader(Virtual *vwk, VQT_FHDR *fhdr); -int CDECL lib_vst_arbpt(Virtual *vwk, long height, short *charw, short *charh, short *cellw, short *cellh); +fix31 CDECL lib_vst_arbpt(Virtual *vwk, fix31 height, short *charw, short *charh, short *cellw, short *cellh); void CDECL lib_vqt_attributes(Virtual * vwk, short *settings); unsigned short CDECL lib_vqt_char_index(Virtual *vwk, short *intin); short CDECL lib_vst_charmap(Virtual *vwk, long mode); @@ -113,7 +113,7 @@ extern void (*external_term) (void); extern Fontheader* (*external_load_font)(Virtual *vwk, const char *font); extern long (*external_vqt_extent)(Virtual *vwk, Fontheader *font, short *text, long length); extern long (*external_vqt_width)(Virtual *vwk, Fontheader *font, long ch); -extern Fontheader* (*external_vst_point)(Virtual *vwk, long size, short *sizes); +extern Fontheader* (*external_vst_point)(Virtual *vwk, fix31 size, short *sizes); extern long (*external_renderer)(Virtual *vwk, unsigned long coords, short *text, long length); extern void* (*external_char_bitmap)(Virtual *vwk, Fontheader *font, long ch, short *bitmap_info); diff --git a/fvdi/include/fvdi.h b/fvdi/include/fvdi.h index b4f24e5..b4c7d24 100644 --- a/fvdi/include/fvdi.h +++ b/fvdi/include/fvdi.h @@ -192,6 +192,10 @@ typedef struct DrvLine_ { long draw_last; } DrvLine; +typedef long fix31; +#define SHORT_TO_FIX31(X) ((long)(X) << 16) +#define FIX31_TO_SHORT(X) (short)((((long)(X) + 0x8000L) >> 16)) + typedef struct Fontcharmap_ { short id; /* charmap header ('00',01,02,10,11,12,TT,T1) */ short map[224]; /* mapping information d = map[s-32] like */ @@ -227,6 +231,7 @@ typedef struct Fontextra_ { short ref_count; /* Reference count (dispose if 0) */ + fix31 size; /* Font size */ short format; /* Returned by vqt_xfntinfo() and vqt_ext_name() */ /* Vector fonts */ @@ -242,7 +247,7 @@ typedef struct Fontextra_ { typedef struct Fontheader_ { short id; /* Face identifier */ - short size; /* Font size in points */ + short dummy; /* See extra.size for the font size */ char name[32]; /* Face name */ struct code_ { short low; /* Lowest ASCII value in face */ diff --git a/fvdi/include/macros.dev b/fvdi/include/macros.dev index b9b6f1c..9debf08 100644 --- a/fvdi/include/macros.dev +++ b/fvdi/include/macros.dev @@ -40,6 +40,27 @@ done_return macro endc endm +* Convert from a 16 bit size to fix31 +short_to_fix31 macro + ifc \1,\2 + swap \2 + clr.w \2 + else + moveq #0,\2 + move.w \1,\2 + swap \2 + endc + endm + +* Convert from fix31 to a 16 bit size, rounding up +fix31_to_short macro + addi.l #$8000,\1 + swap \1 + ifnc \1,\2 + move.w \1,\2 + endc + endm + ijsr macro indirect ifd mc68000 pea \@ diff --git a/fvdi/include/macros.gnu b/fvdi/include/macros.gnu index 631192b..7f1665f 100644 --- a/fvdi/include/macros.gnu +++ b/fvdi/include/macros.gnu @@ -40,6 +40,27 @@ .endif .endm +* Convert from a 16 bit size to fix31 + .macro short_to_fix31 src dst + .ifc \src,\dst + swap \dst + clr.w \dst + .else + moveq #0,\dst + move.w \src,\dst + swap \dst + .endif + .endm + +* Convert from fix31 to a 16 bit size, rounding up + .macro fix31_to_short src dst + addi.l #0x8000,\src + swap \src + .ifnc \src,\dst + move.w \src,\dst + .endif + .endm + .macro ijsr indirect .if mc68000 == 1 pea ret\@ diff --git a/fvdi/include/macros.tas b/fvdi/include/macros.tas index 906d760..397789b 100644 --- a/fvdi/include/macros.tas +++ b/fvdi/include/macros.tas @@ -42,6 +42,27 @@ mcoldfire equ 0 endc endm +; Convert from a 16 bit size to fix31 + macro short_to_fix31 src,dst + ifc \src,\dst + swap \dst + clr.w \dst + else + moveq #0,\dst + move.w \src,\dst + swap \dst + endc + endm + +; Convert from fix31 to a 16 bit size, rounding up + macro fix31_to_short src,dst + addi.l #$8000,\src + swap \src + ifnc \src,\dst + move.w \src,\dst + endc + endm + macro ijsr indirect local return pea .&return diff --git a/fvdi/include/types.inc b/fvdi/include/types.inc index 1f4bb7a..99cc6aa 100644 --- a/fvdi/include/types.inc +++ b/fvdi/include/types.inc @@ -244,7 +244,7 @@ wk_opcode11_count = 2486 wk_opcode11 = 2488 wk_struct_size = 2544 font_id = 0 -font_size = 2 +font_dummy = 2 font_name = 4 font_code = 36 font_code_low = 36 @@ -288,15 +288,16 @@ font_extra_width_table = 106 font_extra_next_size = 110 font_extra_first_size = 114 font_extra_ref_count = 118 -font_extra_format = 120 -font_extra_filename = 122 -font_extra_index = 126 -font_extra_current = 128 -font_extra_cache = 132 -font_extra_scratch = 136 -font_extra_effects = 140 -font_extra_underline_offset = 142 -font_struct_size = 144 +font_extra_size = 120 +font_extra_format = 124 +font_extra_filename = 126 +font_extra_index = 130 +font_extra_current = 132 +font_extra_cache = 136 +font_extra_scratch = 140 +font_extra_effects = 144 +font_extra_underline_offset = 146 +font_struct_size = 148 mfdb_address = 0 mfdb_width = 4 mfdb_height = 6 diff --git a/fvdi/modules/ft2/ft2.c b/fvdi/modules/ft2/ft2.c index d20a27a..18d9b7a 100644 --- a/fvdi/modules/ft2/ft2.c +++ b/fvdi/modules/ft2/ft2.c @@ -76,6 +76,8 @@ typedef struct cached_glyph /* Handy routines for converting from fixed point */ +#define FIX31_TO_FT26P6(X) (((X) + 0x8000) >> 10) +#define FT26P6_TO_FIX31(X) ((X) << 10) #define FT_FLOOR(X) ((X & -64) / 64) #define FT_CEIL(X) (((X + 63) & -64) / 64) @@ -106,7 +108,7 @@ typedef struct { static FT_Error ft2_find_glyph(Virtual *vwk, Fontheader *font, short ch, int want); -static Fontheader *ft2_dup_font(Virtual *vwk, Fontheader *src, short ptsize); +static Fontheader *ft2_dup_font(Virtual *vwk, Fontheader *src, fix31 ptsize); static void ft2_dispose_font(Fontheader *font); #define USE_FREETYPE_ERRORS 1 @@ -203,7 +205,7 @@ static void ft2_close_face(Fontheader *font) if (debug > 1) { PRINTF(("FT2 close_face: %s\n", font->extra.filename)); - PRINTF(("%s, size: %d\n", ((FT_Face) font->extra.unpacked.data)->family_name, font->size)); + PRINTF(("%s, size: %08lx\n", ((FT_Face) font->extra.unpacked.data)->family_name, font->extra.size)); } #endif @@ -212,7 +214,7 @@ static void ft2_close_face(Fontheader *font) } -static Fontheader *ft2_load_metrics(Virtual *vwk, Fontheader *font, FT_Face face, short ptsize) +static Fontheader *ft2_load_metrics(Virtual *vwk, Fontheader *font, FT_Face face, fix31 ptsize) { FT_Error error; @@ -223,11 +225,10 @@ static Fontheader *ft2_load_metrics(Virtual *vwk, Fontheader *font, FT_Face face if (!ptsize) { access->funcs.puts("Attempt to load metrics with bad point size!\n"); - ptsize = 10; + ptsize = SHORT_TO_FIX31(10); } #endif - - error = FT_Set_Char_Size(face, 0, ptsize * 64, + error = FT_Set_Char_Size(face, 0, FIX31_TO_FT26P6(ptsize), 25400 / vwk->real_address->screen.pixel.width, 25400 / vwk->real_address->screen.pixel.height); if (error) @@ -255,6 +256,7 @@ static Fontheader *ft2_load_metrics(Virtual *vwk, Fontheader *font, FT_Face face { int pick = 0; int s; + short ptsize26p6 = FIX31_TO_FT26P6(ptsize); /* Find the required font size in the bitmap face (if present) */ if (debug > 1) @@ -264,23 +266,23 @@ static Fontheader *ft2_load_metrics(Virtual *vwk, Fontheader *font, FT_Face face for (s = 0; s < face->num_fixed_sizes; s++) { - short size = face->available_sizes[s].size / 64; + short size26p6 = face->available_sizes[s].size; if (debug > 1) { - PRINTF((", %d [%ld,%ld] ", size, (long) face->available_sizes[s].width, (long) face->available_sizes[s].height)); + PRINTF((", %08lx [%ld,%ld] ", size26p6, (long) face->available_sizes[s].width, (long) face->available_sizes[s].height)); } /* Find the closest font size available */ - if (ptsize - face->available_sizes[pick].size / 64 > ptsize - size) + if (ptsize26p6 - face->available_sizes[pick].size > ptsize26p6 - size26p6) pick = s; - if (ptsize >= size / 64) + if (ptsize26p6 >= size26p6) break; } if (debug > 1) { - PRINTF((" => %ld\n", (long) face->available_sizes[pick].size / 64)); + PRINTF((" => %08lx\n", (long) face->available_sizes[pick].size)); } #if FREETYPE_VERSION >= 2002000L @@ -318,7 +320,7 @@ static Fontheader *ft2_load_metrics(Virtual *vwk, Fontheader *font, FT_Face face font->skewing = (int) (0.207f * font->height + 1 /* ceiling */ ); } - font->size = ptsize; + font->extra.size = ptsize; font->extra.effects = vwk->text.effects & FT2_EFFECTS_MASK; font->lightening = 0xaaaa; /* Set the mask to apply to the glyphs */ @@ -695,15 +697,15 @@ Fontheader *ft2_load_font(Virtual *vwk, const char *filename) if (!face->num_fixed_sizes) { - font->size = 0; /* Vector fonts have size = 0 */ + font->extra.size = 0; /* Vector fonts have size = 0 */ } else { - font->size = face->available_sizes[0].size / 64; /* Bitmap font size */ + font->extra.size = FT26P6_TO_FIX31(face->available_sizes[0].size); /* Bitmap font size */ } if (debug > 0) { - PRINTF(("FT2 load_font: %s: size=%ld\n", font->name, (long) font->size)); + PRINTF(("FT2 load_font: %s: size=%08lx\n", font->name, (long) font->extra.size)); } /* By default faces should not be kept in memory... (void *)face */ @@ -739,7 +741,7 @@ Fontheader *ft2_load_font(Virtual *vwk, const char *filename) } -static Fontheader *ft2_open_face(Virtual *vwk, Fontheader *font, short ptsize) +static Fontheader *ft2_open_face(Virtual *vwk, Fontheader *font, fix31 ptsize) { FT_Error error; FT_Face face; @@ -816,10 +818,10 @@ static FT_Face ft2_get_face(Virtual *vwk, Fontheader *font) /* Open the face if needed */ if (!font->extra.unpacked.data) { - if (font->size) - font = ft2_open_face(vwk, font, font->size); + if (font->extra.size) + font = ft2_open_face(vwk, font, font->extra.size); else - font = ft2_open_face(vwk, font, 10); + font = ft2_open_face(vwk, font, SHORT_TO_FIX31(10)); } if (!font) @@ -829,7 +831,7 @@ static FT_Face ft2_get_face(Virtual *vwk, Fontheader *font) } -static Fontheader *ft2_dup_font(Virtual *vwk, Fontheader *src, short ptsize) +static Fontheader *ft2_dup_font(Virtual *vwk, Fontheader *src, fix31 ptsize) { Fontheader *font = (Fontheader *) malloc(sizeof(Fontheader)); @@ -850,7 +852,7 @@ static Fontheader *ft2_dup_font(Virtual *vwk, Fontheader *src, short ptsize) #ifdef DEBUG_FONTS if (debug > 1) { - PRINTF(("FT2 dup_font: %s, size: %d\n", font->name, ptsize)); + PRINTF(("FT2 dup_font: %s, size: %08lx\n", font->name, ptsize)); } #endif @@ -2244,7 +2246,7 @@ static MFDB *ft2_text_render(Virtual *vwk, Fontheader *font, const short *text, * different sizes of FreeType2 fonts loaded in the beginning * (which are maintained in the global font list normally). **/ -static Fontheader *ft2_find_fontsize(Virtual *vwk, Fontheader *font, short ptsize) +static Fontheader *ft2_find_fontsize(Virtual *vwk, Fontheader *font, fix31 ptsize) { static short font_count = 0; Fontheader *f; @@ -2255,17 +2257,17 @@ static Fontheader *ft2_find_fontsize(Virtual *vwk, Fontheader *font, short ptsiz /* Not a scalable font: * Fall back to the common add way of finding the right font size */ f = font->extra.first_size; - while (f->extra.next_size && (f->extra.next_size->size <= ptsize)) + while (f->extra.next_size && (f->extra.next_size->extra.size <= ptsize)) { f = f->extra.next_size; } /* Set the closest available bitmap font size */ - ptsize = f->size; + ptsize = f->extra.size; } if (debug > 2) { - PRINTF(("FT2 looking for cached_font: id=%ld size=%d eff=%d\n", (long) font->id, ptsize, vwk->text.effects)); + PRINTF(("FT2 looking for cached_font: id=%ld size=%08lx eff=%d\n", (long) font->id, ptsize, vwk->text.effects)); } /* LRU: put the selected font to the front of the list */ @@ -2276,11 +2278,11 @@ static Fontheader *ft2_find_fontsize(Virtual *vwk, Fontheader *font, short ptsiz { if (debug > 2) { - PRINTF(("FT2 cached_font: id==%ld size=%ld eff=%d\n", (long) i->font->id, (long) i->font->size, i->font->extra.effects)); + PRINTF(("FT2 cached_font: id=%ld size=%08lx eff=%d\n", (long) i->font->id, (long) i->font->extra.size, i->font->extra.effects)); } if (i->font->id == font->id && - i->font->size == ptsize && + i->font->extra.size == ptsize && i->font->extra.effects == (vwk->text.effects & FT2_EFFECTS_MASK)) { listRemove((LINKABLE *) i); @@ -2292,7 +2294,7 @@ static Fontheader *ft2_find_fontsize(Virtual *vwk, Fontheader *font, short ptsiz if (debug > 1) { - PRINTF(("FT2 find_font: fetch size=%d\n", ptsize)); + PRINTF(("FT2 find_font: fetch size=%08lx\n", ptsize)); } /* FIXME: handle maximum number of fonts in the cache here (configurable) */ @@ -2364,11 +2366,11 @@ long ft2_text_render_default(Virtual *vwk, unsigned long coords, short *s, long #endif /* FIXME: this should not happen once we have all the font id/size setup routines intercepted */ - if (!font->size) + if (!font->extra.size) { PUTS("FT2 RENDERER CALLED FOR 0 size: text_render_default font->size == 0\n"); /* Create a copy of the font for the particular size */ - font = ft2_find_fontsize(vwk, font, 16); + font = ft2_find_fontsize(vwk, font, SHORT_TO_FIX31(16)); if (!font) { PUTS("Cannot open face\n"); @@ -2458,7 +2460,7 @@ long ft2_set_effects(Virtual *vwk, Fontheader *font, long effects) vwk->text.effects = effects; /* Update the font metrics after effects change */ - font = ft2_find_fontsize(vwk, font, font->size); + font = ft2_find_fontsize(vwk, font, font->extra.size); /* Assign and update the ref_counts */ if (vwk->text.current_font != font && font) @@ -2473,30 +2475,31 @@ long ft2_set_effects(Virtual *vwk, Fontheader *font, long effects) } -Fontheader *ft2_vst_point(Virtual *vwk, long ptsize, short *sizes) +Fontheader *ft2_vst_point(Virtual *vwk, fix31 ptsize, short *sizes) { Fontheader *font = vwk->text.current_font; short i = 1; - if (font->size == ptsize) + if (font->extra.size == ptsize) return font; - if (ptsize > 32000) - ptsize = 32000; + if (ptsize > SHORT_TO_FIX31(32000)) + ptsize = SHORT_TO_FIX31(32000); if (sizes == NULL || sizes[0] == -1) { - PRINTF(("No search for size %ld\n", ptsize)); + PRINTF(("No search for size %08lx\n", ptsize)); } else { - PRINTF(("Searching $%08lx for %ld: ", (long) sizes, ptsize)); - while (sizes[i] <= ptsize && sizes[i] != -1) + short size = FIX31_TO_SHORT(ptsize); + PRINTF(("Searching $%08lx for %08lx: ", (long) sizes, ptsize)); + while (sizes[i] <= size && sizes[i] != -1) { i++; } - ptsize = sizes[i - 1]; - PRINTF(("%ld\n", ptsize)); + ptsize = SHORT_TO_FIX31(sizes[i - 1]); + PRINTF(("%08lx\n", ptsize)); } /* NEED to update metrics to be up-to-date immediately after vst_point() */