Diff

Differences From Artifact [81bc9c8cc1]:

To Artifact [9a8959c24a]:


1800
1801
1802
1803
1804
1805
1806
1807

1808






1809
1810
1811
1812
1813
1814
1815
1800
1801
1802
1803
1804
1805
1806

1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821







-
+

+
+
+
+
+
+







 */
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
		      unsigned long attr, int lattr)
{
    struct draw_ctx *dctx = (struct draw_ctx *)ctx;
    struct gui_data *inst = dctx->inst;
    GdkGC *gc = dctx->gc;

    int ncombining, combining;
    int nfg, nbg, t, fontid, shadow, rlen, widefactor;

    if (attr & TATTR_COMBINING) {
	ncombining = len;
	len = 1;
    } else
	ncombining = 1;

    nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
    nfg = 2 * (nfg & 0xF) + (nfg & 0x10 ? 1 : 0);
    nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
    nbg = 2 * (nbg & 0xF) + (nbg & 0x10 ? 1 : 0);
    if (attr & ATTR_REVERSE) {
	t = nfg;
1870
1871
1872
1873
1874
1875
1876
1877
1878


1879
1880
1881
1882
1883
1884
1885
1876
1877
1878
1879
1880
1881
1882


1883
1884
1885
1886
1887
1888
1889
1890
1891







-
-
+
+







    gdk_gc_set_foreground(gc, &inst->cols[nfg]);
    {
	GdkWChar *gwcs;
	gchar *gcs;
	wchar_t *wcs;
	int i;

	wcs = snewn(len+1, wchar_t);
	for (i = 0; i < len; i++) {
	wcs = snewn(len*ncombining+1, wchar_t);
	for (i = 0; i < len*ncombining; i++) {
	    wcs[i] = text[i];
	}

	if (inst->fonts[fontid] == NULL) {
	    /*
	     * The font for this contingency does not exist.
	     * Typically this means we've been given ATTR_WIDE
1903
1904
1905
1906
1907
1908
1909

1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920












1921
1922
1923

1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934












1935
1936
1937
1938
1939
1940
1941
1909
1910
1911
1912
1913
1914
1915
1916











1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932











1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951







+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+



+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+







	     */
	    gwcs = snewn(len*2+1, GdkWChar);
	    memset(gwcs, 0, sizeof(GdkWChar) * (len*2+1));
	    /*
	     * FIXME: when we have a wide-char equivalent of
	     * from_unicode, use it instead of this.
	     */
	    for (combining = 0; combining < ncombining; combining++) {
	    for (i = 0; i <= len; i++)
		gwcs[i] = wcs[i];
	    gdk_draw_text_wc(inst->pixmap, inst->fonts[fontid], gc,
			     x*inst->font_width+inst->cfg.window_border,
			     y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
			     gwcs, len*2);
	    if (shadow)
		gdk_draw_text_wc(inst->pixmap, inst->fonts[fontid], gc,
				 x*inst->font_width+inst->cfg.window_border+inst->cfg.shadowboldoffset,
				 y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
				 gwcs, len*2);
		for (i = 0; i <= len; i++)
		    gwcs[i] = wcs[i + combining];
		gdk_draw_text_wc(inst->pixmap, inst->fonts[fontid], gc,
				 x*inst->font_width+inst->cfg.window_border,
				 y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
				 gwcs, len*2);
		if (shadow)
		    gdk_draw_text_wc(inst->pixmap, inst->fonts[fontid], gc,
				     x*inst->font_width+inst->cfg.window_border+inst->cfg.shadowboldoffset,
				     y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
				     gwcs, len*2);
	    }
	    sfree(gwcs);
	} else {
	    gcs = snewn(len+1, gchar);
	    for (combining = 0; combining < ncombining; combining++) {
	    wc_to_mb(inst->fontinfo[fontid].charset, 0,
		     wcs, len, gcs, len, ".", NULL, NULL);
	    gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
			  x*inst->font_width+inst->cfg.window_border,
			  y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
			  gcs, len);
	    if (shadow)
		gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
			      x*inst->font_width+inst->cfg.window_border+inst->cfg.shadowboldoffset,
			      y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
			      gcs, len);
		wc_to_mb(inst->fontinfo[fontid].charset, 0,
			 wcs + combining, len, gcs, len, ".", NULL, NULL);
		gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
			      x*inst->font_width+inst->cfg.window_border,
			      y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
			      gcs, len);
		if (shadow)
		    gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
				  x*inst->font_width+inst->cfg.window_border+inst->cfg.shadowboldoffset,
				  y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
				  gcs, len);
	    }
	    sfree(gcs);
	}
	sfree(wcs);
    }

    if (attr & ATTR_UNDER) {
	int uheight = inst->fonts[0]->ascent + 1;