#include "w32bdf.h"
#include <shellapi.h>
-#ifdef USE_FONT_BACKEND
#include "font.h"
-#endif /* USE_FONT_BACKEND */
-
+#include "w32font.h"
\f
/* Fringe bitmaps. */
/* Function prototypes of this page. */
+#if OLD_FONT
+
XCharStruct *w32_per_char_metric P_ ((XFontStruct *, wchar_t *, int));
static int w32_encode_char P_ ((int, wchar_t *, struct font_info *,
struct charset *, int *));
}
}
-
/* Determine if a font is double byte. */
static int
w32_font_is_double_byte (XFontStruct *font)
nchars * charset_dim, NULL);
}
+#endif /* OLD_FONT */
static void x_set_glyph_string_clipping P_ ((struct glyph_string *));
static void x_set_glyph_string_gc P_ ((struct glyph_string *));
/* If font in this face is same as S->font, use it. */
if (s->font == s->face->font)
s->gc = s->face->gc;
-#ifdef USE_FONT_BACKEND
- else if (enable_font_backend)
- /* No need of setting a font for s->gc. */
- s->gc = s->face->gc;
-#endif /* USE_FONT_BACKEND */
else
{
/* Otherwise construct scratch_cursor_gc with values from FACE
x_set_glyph_string_clipping (s)
struct glyph_string *s;
{
-#ifdef USE_FONT_BACKEND
RECT *r = s->clip;
-#else
- RECT r[2];
-#endif
int n = get_glyph_string_clip_rects (s, r, 2);
if (n == 1)
DeleteObject (clip2);
DeleteObject (full_clip);
}
-#ifdef USE_FONT_BACKEND
s->num_clips = n;
-#endif /* USE_FONT_BACKEND */
}
/* Set SRC's clipping for output of glyph string DST. This is called
{
RECT r;
-#ifdef USE_FONT_BACKEND
- if (enable_font_backend)
- {
- r.left = src->x;
- r.right = r.left + src->width;
- r.top = src->y;
- r.bottom = r.top + src->height;
- dst->clip[0] = r;
- dst->num_clips = 1;
- }
- else
+ r.left = src->x;
+ r.right = r.left + src->width;
+ r.top = src->y;
+ r.bottom = r.top + src->height;
+ dst->clip[0] = r;
+ dst->num_clips = 1;
+#if OLD_FONT
{
-#endif /* USE_FONT_BACKEND */
struct glyph_string *clip_head = src->clip_head;
struct glyph_string *clip_tail = src->clip_tail;
src->clip_head = src->clip_tail = src;
get_glyph_string_clip_rect (src, &r);
src->clip_head = clip_head, src->clip_tail = clip_tail;
-#ifdef USE_FONT_BACKEND
}
-#endif /* USE_FONT_BACKEND */
+#endif /* OLD_FONT */
w32_set_clip_rectangle (dst->hdc, &r);
}
/* RIF:
- Compute left and right overhang of glyph string S. If S is a glyph
- string for a composition, assume overhangs don't exist. */
+ Compute left and right overhang of glyph string S. */
static void
w32_compute_glyph_string_overhangs (s)
struct glyph_string *s;
{
if (s->cmp == NULL
- && s->first_glyph->type == CHAR_GLYPH)
+ && s->first_glyph->type == CHAR_GLYPH
+ && !s->font_not_found_p)
{
-#ifdef USE_FONT_BACKEND
- if (enable_font_backend)
- {
- unsigned *code = alloca (sizeof (unsigned) * s->nchars);
- struct font *font = (struct font *) s->font_info;
- struct font_metrics metrics;
- int i;
+ unsigned *code = alloca (sizeof (unsigned) * s->nchars);
+ struct font *font = s->font;
+ struct font_metrics metrics;
+ int i;
- for (i = 0; i < s->nchars; i++)
- code[i] = s->char2b[i];
- font->driver->text_extents (font, code, s->nchars, &metrics);
- s->right_overhang = (metrics.rbearing > metrics.width
- ? metrics.rbearing - metrics.width : 0);
- s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0;
- }
-#else
- /* TODO: Windows does not appear to have a method for
- getting this info without getting the ABC widths for each
- individual character and working it out manually. */
-#endif
+ for (i = 0; i < s->nchars; i++)
+ code[i] = s->char2b[i];
+ font->driver->text_extents (font, code, s->nchars, &metrics);
+ s->right_overhang = (metrics.rbearing > metrics.width
+ ? metrics.rbearing - metrics.width : 0);
+ s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0;
}
else if (s->cmp)
{
if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
|| s->font_not_found_p
|| s->extends_to_end_of_line_p
- || s->font->bdf
+ || FONT_COMPAT (s->font)->bdf
|| cleartype_active
|| force_p)
{
SetBkColor (s->hdc, s->gc->background);
SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT);
- if (s->font && s->font->hfont)
- old_font = SelectObject (s->hdc, s->font->hfont);
+ if (s->font && FONT_COMPAT (s->font)->hfont)
+ old_font = SelectObject (s->hdc, FONT_COMPAT (s->font)->hfont);
/* Draw characters of S as rectangles if S's font could not be
loaded. */
x += g->pixel_width;
}
}
-#ifdef USE_FONT_BACKEND
- else if (enable_font_backend)
+ else
{
- int boff = s->font_info->baseline_offset;
- struct font *font = (struct font *) s->font_info;
+ int boff = s->font->baseline_offset;
+ struct font *font = s->font;
int y;
- if (s->font_info->vertical_centering)
+ if (s->font->vertical_centering)
boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff;
y = s->ybase - boff;
if (s->face->overstrike)
font->driver->draw (s, 0, s->nchars, x + 1, y, 0);
}
-#endif /* USE_FONT_BACKEND */
- else
- {
- char *char1b = (char *) s->char2b;
- int boff = s->font_info->baseline_offset;
-
- if (s->font_info->vertical_centering)
- boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff;
- /* If we can use 8-bit functions, condense S->char2b. */
- if (!s->two_byte_p)
- for (i = 0; i < s->nchars; ++i)
- char1b[i] = XCHAR2B_BYTE2 (&s->char2b[i]);
-
- /* Draw text with TextOut and friends. */
- w32_text_out (s, x, s->ybase - boff, s->char2b, s->nchars);
-
- if (s->face->overstrike)
- {
- /* For overstriking (to simulate bold-face), draw the
- characters again shifted to the right by one pixel. */
- int old_BkMode = SetBkMode (s->hdc, TRANSPARENT);
- w32_text_out (s, x + 1, s->ybase - boff, s->char2b, s->nchars);
- if (old_BkMode && old_BkMode != TRANSPARENT)
- SetBkMode (s->hdc, old_BkMode);
- }
- }
- if (s->font && s->font->hfont)
+ if (s->font && FONT_COMPAT (s->font)->hfont)
SelectObject (s->hdc, old_font);
}
SetBkMode (s->hdc, TRANSPARENT);
SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT);
- if (s->font && s->font->hfont)
- old_font = SelectObject (s->hdc, s->font->hfont);
+ if (s->font && FONT_COMPAT (s->font)->hfont)
+ old_font = SelectObject (s->hdc, FONT_COMPAT (s->font)->hfont);
/* Draw a rectangle for the composition if the font for the very
first character of the composition could not be loaded. */
w32_draw_rectangle (s->hdc, s->gc, x, s->y, s->width - 1,
s->height - 1);
}
-#ifdef USE_FONT_BACKEND
- else if (enable_font_backend)
+
{
- struct font *font = (struct font *) s->font_info;
+ struct font *font = s->font;
int y = s->ybase;
int width = 0;
}
}
}
-#endif /* USE_FONT_BACKEND */
- else
- {
- for (i = 0, j = s->gidx; i < s->nchars; i++, j++)
- if (s->face)
- {
- w32_text_out (s, x + s->cmp->offsets[j * 2],
- s->ybase - s->cmp->offsets[j * 2 + 1],
- s->char2b + j, 1);
- if (s->face->overstrike)
- w32_text_out (s, x + s->cmp->offsets[j * 2] + 1,
- s->ybase - s->cmp->offsets[j + 1],
- s->char2b + j, 1);
- }
- }
- if (s->font && s->font->hfont)
+ if (s->font && FONT_COMPAT (s->font)->hfont)
SelectObject (s->hdc, old_font);
}
x_set_glyph_string_gc (next);
x_set_glyph_string_clipping (next);
x_draw_glyph_string_background (next, 1);
-#ifdef USE_FONT_BACKEND
next->num_clips = 0;
-#endif /* USE_FONT_BACKEND */
}
}
if (!s->for_overlaps)
{
/* Draw underline. */
- if (s->face->underline_p
- && (s->font->bdf || !s->font->tm.tmUnderlined))
+ if (s->face->underline_p)
{
- unsigned long h;
+ unsigned long thickness, position;
int y;
- /* Get the underline thickness. Default is 1 pixel. */
-#ifdef USE_FONT_BACKEND
- if (enable_font_backend)
- /* In the future, we must use information of font. */
- h = 1;
- else
-#endif /* USE_FONT_BACKEND */
- h = 1;
-#ifdef USE_FONT_BACKEND
- if (enable_font_backend)
- {
- if (s->face->font)
- /* In the future, we must use information of font. */
- y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
- else
- y = s->y + s->height - h;
- }
- else
-#endif
+ if (s->prev && s->prev->face->underline_p)
{
- y = s->y + s->height - h;
- /* TODO: Use font information for positioning and
- thickness of underline. See OUTLINETEXTMETRIC,
- and xterm.c. Note: If you make this work,
- don't forget to change the doc string of
- x-use-underline_color-position-properties
- below. */
-#if 0
- if (!x_underline_at_descent_line)
+ /* We use the same underline style as the previous one. */
+ thickness = s->prev->underline_thickness;
+ position = s->prev->underline_position;
+ }
+ else
+ {
+ /* Get the underline thickness. Default is 1 pixel. */
+ if (s->font && s->font->underline_thickness > 0)
+ thickness = s->font->underline_thickness;
+ else
+ thickness = 1;
+ if (x_underline_at_descent_line)
+ position = (s->height - thickness) - s->ybase;
+ else
{
- ...
+ /* Get the underline position. This is the recommended
+ vertical offset in pixels from the baseline to the top of
+ the underline. This is a signed value according to the
+ specs, and its default is
+
+ ROUND ((maximum_descent) / 2), with
+ ROUND (x) = floor (x + 0.5) */
+
+ if (x_use_underline_position_properties
+ && s->font && s->font->underline_position >= 0)
+ position = s->font->underline_position;
+ else if (s->font)
+ position = (s->font->descent + 1) / 2;
}
-#endif
+ s->underline_thickness = thickness;
+ s->underline_position =position;
}
+ y = s->ybase + position;
if (s->face->underline_defaulted_p)
{
w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x,
/* Draw strike-through. */
if (s->face->strike_through_p
- && (s->font->bdf || !s->font->tm.tmStruckOut))
+ && (FONT_COMPAT (s->font)->bdf
+ || !FONT_COMPAT (s->font)->tm.tmStruckOut))
{
unsigned long h = 1;
unsigned long dy = (s->height - h) / 2;
x_draw_composite_glyph_string_foreground (prev);
w32_set_clip_rectangle (prev->hdc, NULL);
prev->hl = save;
-#ifdef USE_FONT_BACKEND
prev->num_clips = 0;
-#endif /* USE_FONT_BACKEND */
}
}
x_draw_composite_glyph_string_foreground (next);
w32_set_clip_rectangle (next->hdc, NULL);
next->hl = save;
-#ifdef USE_FONT_BACKEND
next->num_clips = 0;
-#endif /* USE_FONT_BACKEND */
}
}
}
/* Reset clipping. */
w32_set_clip_rectangle (s->hdc, NULL);
-#ifdef USE_FONT_BACKEND
s->num_clips = 0;
-#endif /* USE_FONT_BACKEND */
}
\f
/* Changing the font of the frame. */
+#if OLD_FONT
+
/* Give frame F the font named FONTNAME as its default font, and
return the full name of that font. FONTNAME may be a wildcard
pattern; in that case, we choose some font that fits the pattern.
return fontset_name (fontset);
}
+#endif /* OLD_FONT */
+
-#ifdef USE_FONT_BACKEND
Lisp_Object
-x_new_fontset2 (f, fontset, font_object)
+x_new_font (f, font_object, fontset)
struct frame *f;
- int fontset;
Lisp_Object font_object;
+ int fontset;
{
- struct font *font = XSAVE_VALUE (font_object)->pointer;
+ struct font *font = XFONT_OBJECT (font_object);
- if (FRAME_FONT_OBJECT (f) == font)
+ if (fontset < 0)
+ fontset = fontset_from_font (font_object);
+ FRAME_FONTSET (f) = fontset;
+ if (FRAME_FONT (f) == font)
/* This font is already set in frame F. There's nothing more to
do. */
return fontset_name (fontset);
BLOCK_INPUT;
- FRAME_FONT_OBJECT (f) = font;
- FRAME_FONT (f) = font->font.font;
- FRAME_BASELINE_OFFSET (f) = font->font.baseline_offset;
- FRAME_FONTSET (f) = fontset;
-
- FRAME_COLUMN_WIDTH (f) = font->font.average_width;
- FRAME_SPACE_WIDTH (f) = font->font.space_width;
- FRAME_LINE_HEIGHT (f) = font->font.height;
+ FRAME_FONT (f) = font;
+ FRAME_BASELINE_OFFSET (f) = font->baseline_offset;
+ FRAME_COLUMN_WIDTH (f) = font->average_width;
+ FRAME_SPACE_WIDTH (f) = font->space_width;
+ FRAME_LINE_HEIGHT (f) = font->height;
compute_fringe_widths (f, 1);
return fontset_name (fontset);
}
-#endif /* USE_FONT_BACKEND */
\f
/***********************************************************************
BLOCK_INPUT;
-#ifdef USE_FONT_BACKEND
- /* We must free faces before destroying windows because some
- font-driver (e.g. xft) access a window while finishing a
- face. */
- if (enable_font_backend
- && FRAME_FACE_CACHE (f))
- free_frame_faces (f);
-#endif /* USE_FONT_BACKEND */
+ /* We must free faces before destroying windows because some
+ font-driver (e.g. xft) access a window while finishing a
+ face. */
+ if (FRAME_FACE_CACHE (f))
+ free_frame_faces (f);
if (FRAME_W32_WINDOW (f))
my_destroy_window (f, FRAME_W32_WINDOW (f));
Fonts
***********************************************************************/
+#if OLD_FONT
+
/* The following functions are listed here to help diff stay in step
with xterm.c. See w32fns.c for definitions.
x_find_ccl_program (fontp)
*/
+
+#endif /* OLD_FONT */
+
\f
/***********************************************************************
Initialization
w32_draw_fringe_bitmap,
w32_define_fringe_bitmap,
w32_destroy_fringe_bitmap,
+#if OLD_FONT
w32_per_char_metric,
w32_encode_char,
+#endif
w32_compute_glyph_string_overhangs,
x_draw_glyph_string,
w32_define_frame_cursor,
return;
BLOCK_INPUT;
+#if OLD_FONT
/* Free the fonts in the font table. */
for (i = 0; i < dpyinfo->n_fonts; i++)
if (dpyinfo->font_table[i].name)
{
DeleteObject (((XFontStruct*)(dpyinfo->font_table[i].font))->hfont);
}
+#endif
x_delete_display (dpyinfo);
UNBLOCK_INPUT;
if (dpyinfo->palette)
DeleteObject(dpyinfo->palette);
}
+#if OLD_FONT
xfree (dpyinfo->font_table);
+#endif
xfree (dpyinfo->w32_id_name);
w32_reset_fringes ();