changeset 1150:0c073534d722

Implemented OS/2 dw_pixmap_set_font() this will need more work... Need to implement sizes like when copying the settings from a window handle like in _CopyFontSettings(). Will revisit this when getting OS/2 printing working... but for now it allows it to compile and basically work.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 11 Sep 2011 22:32:40 +0000
parents cf934fd39d03
children 641aa6941b2a
files os2/dw.c
diffstat 1 files changed, 35 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Sun Sep 11 22:19:01 2011 +0000
+++ b/os2/dw.c	Sun Sep 11 22:32:40 2011 +0000
@@ -8338,7 +8338,7 @@
 
    GpiQueryFontMetrics(hpsSrc, sizeof(FONTMETRICS), &fm);
 
-    memset(&fat, 0, sizeof(fat));
+   memset(&fat, 0, sizeof(fat));
 
    fat.usRecordLength  = sizeof(FATTRS);
    fat.lMatch          = fm.lMatch;
@@ -8782,6 +8782,40 @@
 }
 
 /*
+ * Sets the font used by a specified pixmap.
+ * Normally the pixmap font is obtained from the associated window handle.
+ * However this can be used to override that, or for pixmaps with no window.
+ * Parameters:
+ *          pixmap: Handle to a pixmap returned by dw_pixmap_new() or
+ *                  passed to the application via a callback.
+ *          fontname: Name and size of the font in the form "size.fontname"
+ * Returns:
+ *       DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
+ */
+int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname)
+{
+    if(pixmap && fontname && *fontname)
+    {
+		char *name = strchr(fontname, '.');
+
+		if(name)
+		{
+			FATTRS fat;
+
+			memset(&fat, 0, sizeof(fat));
+
+			fat.usRecordLength  = sizeof(FATTRS);
+			strcpy(fat.szFacename, name);
+
+			GpiCreateLogFont(pixmap->hps, 0, 1L, &fat);
+			GpiSetCharSet(pixmap->hps, 1L);
+			return DW_ERROR_NONE;
+		}
+	}
+    return DW_ERROR_GENERAL;
+}
+
+/*
  * Destroys an allocated pixmap.
  * Parameters:
  *       pixmap: Handle to a pixmap returned by