FRAME_PTR f;
struct font *font;
{
+ int i;
struct w32font_info *w32_font = (struct w32font_info *) font;
+
+ /* Delete the GDI font object. */
DeleteObject (w32_font->hfont);
+
+ /* Free all the cached metrics. */
+ if (w32_font->cached_metrics)
+ {
+ for (i = 0; i < w32_font->n_cache_blocks; i++)
+ {
+ if (w32_font->cached_metrics[i])
+ xfree (w32_font->cached_metrics[i]);
+ }
+ xfree (w32_font->cached_metrics);
+ w32_font->cached_metrics = NULL;
+ }
}
/* w32 implementation of has_char for font backend.
{
metrics->width = total_width;
metrics->lbearing = 0;
- metrics->rbearing = total_width
- + ((struct w32font_info *) font)->metrics.tmOverhang;
+ metrics->rbearing = total_width + w32_font->metrics.tmOverhang;
}
/* Restore state and release DC. */
/* We don't know how much space we need for the full name, so start with
96 bytes and go up in steps of 32. */
len = 96;
- name = xmalloc (len);
+ name = alloca (len);
while (name && w32font_full_name (&logfont, font_entity, pixel_size,
name, len) < 0)
{
- char *new = xrealloc (name, len += 32);
-
- if (! new)
- xfree (name);
- name = new;
+ len += 32;
+ name = alloca (len);
}
if (name)
font->props[FONT_FULLNAME_INDEX]
/* Initialize as much of the font details as we can from the current
default font. */
hdc = GetDC (FRAME_W32_WINDOW (f));
- oldobj = SelectObject (hdc, ((struct w32font_info *) FRAME_FONT (f))->hfont);
+ oldobj = SelectObject (hdc, FONT_HANDLE (FRAME_FONT (f)));
GetTextFace (hdc, LF_FACESIZE, lf.lfFaceName);
if (GetTextMetrics (hdc, &tm))
{
struct glyph_string *s;
{
int i, x;
- struct w32font_info * w32_font;
- HFONT old_font;
/* If first glyph of S has a left box line, start drawing the text
of S to the right of that box line. */
else
x = s->x;
- if (s->for_overlaps || (s->background_filled_p && s->hl != DRAW_CURSOR)
- || cleartype_active)
- SetBkMode (s->hdc, TRANSPARENT);
- else
- SetBkMode (s->hdc, OPAQUE);
-
SetTextColor (s->hdc, s->gc->foreground);
SetBkColor (s->hdc, s->gc->background);
SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT);
- w32_font = (struct w32font_info *) s->font;
-
- if (w32_font && w32_font->hfont)
- old_font = SelectObject (s->hdc, w32_font->hfont);
-
/* Draw characters of S as rectangles if S's font could not be
loaded. */
if (s->font_not_found_p)
}
else
{
- int boff = s->font->baseline_offset;
+ struct font *font = s->font;
+ int boff = font->baseline_offset;
int y;
+ HFONT old_font;
+
+ old_font = SelectObject (s->hdc, FONT_HANDLE (font));
- if (s->font->vertical_centering)
- boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff;
+ if (font->vertical_centering)
+ boff = VCENTER_BASELINE_OFFSET (font, s->f) - boff;
y = s->ybase - boff;
if (s->for_overlaps
|| (s->background_filled_p && s->hl != DRAW_CURSOR))
- s->font->driver->draw (s, 0, s->nchars, x, y, 0);
+ font->driver->draw (s, 0, s->nchars, x, y, 0);
else
- s->font->driver->draw (s, 0, s->nchars, x, y, 1);
+ font->driver->draw (s, 0, s->nchars, x, y, 1);
if (s->face->overstrike)
- s->font->driver->draw (s, 0, s->nchars, x + 1, y, 0);
- }
+ font->driver->draw (s, 0, s->nchars, x + 1, y, 0);
- if (w32_font && w32_font->hfont)
- SelectObject (s->hdc, old_font);
+ SelectObject (s->hdc, old_font);
+ }
}
/* Draw the foreground of composite glyph string S. */
struct glyph_string *s;
{
int i, j, x;
- HFONT old_font;
- struct w32font_info * w32_font;
/* If first glyph of S has a left box line, start drawing the text
of S to the right of that box line. */
SetTextColor (s->hdc, s->gc->foreground);
SetBkColor (s->hdc, s->gc->background);
- SetBkMode (s->hdc, TRANSPARENT);
SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT);
- w32_font = (struct w32font_info *) s->font;
-
- if (w32_font && w32_font->hfont)
- old_font = SelectObject (s->hdc, w32_font->hfont);
-
/* Draw a rectangle for the composition if the font for the very
first character of the composition could not be loaded. */
if (s->font_not_found_p)
w32_draw_rectangle (s->hdc, s->gc, x, s->y, s->width - 1,
s->height - 1);
}
-
+ else
{
struct font *font = s->font;
int y = s->ybase;
int width = 0;
+ HFONT old_font;
+
+ old_font = SelectObject (s->hdc, FONT_HANDLE (font));
if (s->cmp->method == COMPOSITION_WITH_GLYPH_STRING)
{
font->driver->draw (s, j, j + 1, xx + 1, yy, 0);
}
}
+ SelectObject (s->hdc, old_font);
}
-
- if (w32_font && w32_font->hfont)
- SelectObject (s->hdc, old_font);
}
/* Draw strike-through. */
if (s->face->strike_through_p
- && !((struct w32font_info *) s->font)->metrics.tmStruckOut)
+ && !FONT_TEXTMETRIC(s->font).tmStruckOut)
{
unsigned long h = 1;
unsigned long dy = (s->height - h) / 2;
f = XFRAME (selected_frame);
context = get_frame_dc (f);
- old_font = SelectObject (context, ((struct w32font_info *) font)->hfont);
+ old_font = SelectObject (context, FONT_HANDLE(font));
features = otf_features (context, "GSUB");
XSETCAR (capability, features);
f = XFRAME (selected_frame);
context = get_frame_dc (f);
- old_font = SelectObject (context, uniscribe_font->w32_font.hfont);
+ old_font = SelectObject (context, FONT_HANDLE(font));
glyphs = alloca (max_glyphs * sizeof (WORD));
clusters = alloca (nchars * sizeof (WORD));
/* Use selected frame until API is updated to pass the frame. */
f = XFRAME (selected_frame);
context = get_frame_dc (f);
- old_font = SelectObject (context, ((struct w32font_info *) font)->hfont);
+ old_font = SelectObject (context, FONT_HANDLE(font));
retval = GetGlyphIndicesW (context, chars, 1, indices,
GGI_MARK_NONEXISTING_GLYPHS);