register wchar_t *cp; /* Steps through x_2byte_buffer[]. */
/* Allocate double the window width, as this buffer may contain MBCS
- characters under w32. */
- char *x_1byte_buffer
- = (char *) alloca (2 * FRAME_WINDOW_WIDTH (f) * sizeof (*x_1byte_buffer));
- register char *bp; /* Steps through x_1byte_buffer[]. */
+ characters under w32. Unsigned to let GetCharABCWidths work. */
+ unsigned char *x_1byte_buffer
+ = (unsigned char *) alloca (2 * FRAME_WINDOW_WIDTH (f)
+ * sizeof (*x_1byte_buffer));
+ register unsigned char *bp; /* Steps through x_1byte_buffer[]. */
register int tlen = GLYPH_TABLE_LENGTH;
register Lisp_Object *tbase = GLYPH_TABLE_BASE;
Window window = FRAME_W32_WINDOW (f);
|| font->tm.tmDescent >
line_height - baseline
|| (!cmpcharp
- && FONT_WIDTH (font) > glyph_width)));
+ && FONT_MAX_WIDTH (font) > glyph_width)));
if (font && (just_foreground || (cmpcharp && gidx > 0)))
background_filled = 1;
else if (!font
|| FONT_HEIGHT (font) < line_height
|| FONT_WIDTH (font) < glyph_width
+ || FONT_MAX_WIDTH (font) != FONT_WIDTH (font)
|| cmpcharp)
{
/* Fill in the background for the current run. */
if (!cmpcharp)
{
int multibyte_pos_offset = 0;
- if (require_clipping || FONT_WIDTH (font) != glyph_width)
+ if (require_clipping || FONT_WIDTH (font) != glyph_width
+ || FONT_MAX_WIDTH (font) != FONT_WIDTH (font))
{
RECT clip_rectangle;
LPRECT clip_region = NULL;
RECT clip_rectangle;
LPRECT clip_region = NULL;
UINT fuOptions = 0;
+ ABC char_placement;
+ int char_width = 0;
if (require_clipping)
{
i = 1;
+ /* Truetype fonts often contain underhangs to
+ handle composition characters. This works
+ against our attempts to position the characters
+ manually, so we need to compensate for this.
+ */
+ if (print_via_unicode ?
+ GetCharABCWidthsW (hdc, *x_2byte_buffer,
+ *x_2byte_buffer,
+ &char_placement)
+ : GetCharABCWidths (hdc, *x_1byte_buffer,
+ *x_1byte_buffer,
+ &char_placement))
+ {
+ char_width = char_placement.abcA
+ + char_placement.abcB + char_placement.abcC;
+ x_offset += FONT_WIDTH (font) - char_width;
+ }
+ /* Don't let characters go beyond the glyph
+ boundary whatever their over/underhangs. */
+ if (x_offset > glyph_width - char_width)
+ x_offset = glyph_width - char_width;
+
+ if (x_offset < 0)
+ x_offset = 0;
+
/* Draw the first character at the normal position. */
if (print_via_unicode)
ExtTextOutW (hdc, left + x_offset,
* FONT_WIDTH (FRAME_FONT(f)));
}
+ /* Truetype fonts often contain underhangs to
+ handle composition characters. This works
+ against our attempts to position the characters
+ manually, so we need to compensate for this.
+ */
+ if (print_via_unicode ?
+ GetCharABCWidthsW (hdc, *(x_2byte_buffer + i),
+ *(x_2byte_buffer + i),
+ &char_placement)
+ : GetCharABCWidths (hdc, *(x_1byte_buffer + i),
+ *(x_1byte_buffer + i),
+ &char_placement))
+ {
+ char_width = char_placement.abcA
+ + char_placement.abcB + char_placement.abcC;
+ x_offset += FONT_WIDTH (font) - char_width;
+ }
+ /* Don't let characters go beyond the glyph
+ boundary whatever their over/underhangs. */
+ if (x_offset > glyph_width - char_width)
+ x_offset = glyph_width - char_width;
+
+ if (x_offset < 0)
+ x_offset = 0;
+
if (print_via_unicode)
ExtTextOutW (hdc, left + x_offset,
top /*+ baseline - y_offset*/,