|
|
1.1 ! root 1: /*-------------------------------------------------- ! 2: VF00.C -- Routines for working with vector fonts ! 3: --------------------------------------------------*/ ! 4: ! 5: #define INCL_WIN ! 6: #define INCL_GPI ! 7: #include <os2.h> ! 8: #include <stdlib.h> ! 9: #include <string.h> ! 10: #include "vectfont.h" ! 11: ! 12: extern HAB hab ; ! 13: ! 14: LONG CreateVectorFont (HPS hps, LONG lcid, CHAR *szFacename) ! 15: { ! 16: FATTRS fat ; ! 17: ! 18: fat.usRecordLength = sizeof fat ; ! 19: fat.fsSelection = 0 ; ! 20: fat.lMatch = 0 ; ! 21: fat.idRegistry = 0 ; ! 22: fat.usCodePage = GpiQueryCp (hps) ; ! 23: fat.lMaxBaselineExt = 0 ; ! 24: fat.lAveCharWidth = 0 ; ! 25: fat.fsType = 0 ; ! 26: fat.fsFontUse = FATTR_FONTUSE_OUTLINE | ! 27: FATTR_FONTUSE_TRANSFORMABLE ; ! 28: ! 29: strcpy (fat.szFacename, szFacename) ; ! 30: ! 31: return GpiCreateLogFont (hps, NULL, lcid, &fat) ; ! 32: } ! 33: ! 34: BOOL ScaleVectorFont (HPS hps, SHORT xPointSize, SHORT yPointSize) ! 35: { ! 36: HDC hdc ; ! 37: LONG xDeviceRes, yDeviceRes ; ! 38: POINTL ptlFont ; ! 39: SIZEF sizfx ; ! 40: // Get device resolution in pixels per meter ! 41: ! 42: hdc = GpiQueryDevice (hps) ; ! 43: ! 44: DevQueryCaps (hdc, CAPS_HORIZONTAL_RESOLUTION, 1L, &xDeviceRes) ; ! 45: DevQueryCaps (hdc, CAPS_VERTICAL_RESOLUTION, 1L, &yDeviceRes) ; ! 46: ! 47: // Find desired font size in pixels ! 48: ! 49: ptlFont.x = 254L * xPointSize * xDeviceRes / 7200000L ; ! 50: ptlFont.y = 254L * yPointSize * yDeviceRes / 7200000L ; ! 51: ! 52: // Convert to page units ! 53: ! 54: GpiConvert (hps, CVTC_DEVICE, CVTC_PAGE, 1L, &ptlFont) ; ! 55: ! 56: // Set the character box ! 57: ! 58: sizfx.cx = MAKEFIXED (ptlFont.x, 0) ; ! 59: sizfx.cy = MAKEFIXED (ptlFont.y, 0) ; ! 60: ! 61: return GpiSetCharBox (hps, &sizfx) ; ! 62: } ! 63: ! 64: BOOL ScaleFontToBox (HPS hps, LONG cbText, CHAR *szText, LONG cxBox, ! 65: LONG cyBox) ! 66: { ! 67: POINTL aptl[TXTBOX_COUNT] ; ! 68: SIZEF sizfx ; ! 69: ! 70: GpiQueryCharBox (hps, &sizfx) ; ! 71: GpiQueryTextBox (hps, cbText, szText, TXTBOX_COUNT, aptl) ; ! 72: ! 73: sizfx.cx = sizfx.cx / ! 74: (max (aptl[TXTBOX_TOPRIGHT].x, aptl[TXTBOX_BOTTOMRIGHT].x) - ! 75: min (aptl[TXTBOX_TOPLEFT].x, aptl[TXTBOX_BOTTOMLEFT].x)) ! 76: * cxBox ; ! 77: ! 78: sizfx.cy = sizfx.cy / ! 79: (max (aptl[TXTBOX_TOPRIGHT].y, aptl[TXTBOX_TOPLEFT].y) - ! 80: min (aptl[TXTBOX_BOTTOMRIGHT].y, aptl[TXTBOX_BOTTOMLEFT].y)) ! 81: * cyBox ; ! 82: ! 83: return GpiSetCharBox (hps, &sizfx) ; ! 84: } ! 85: ! 86: VOID QueryStartPointInTextBox (HPS hps, LONG cbText, CHAR *szText, ! 87: POINTL *pptl) ! 88: { ! 89: POINTL aptl[TXTBOX_COUNT] ; ! 90: ! 91: GpiQueryTextBox (hps, cbText, szText, TXTBOX_COUNT, aptl) ; ! 92: ! 93: pptl->x = max(-aptl[TXTBOX_TOPLEFT].x, -aptl[TXTBOX_BOTTOMLEFT].x); ! 94: pptl->y = max(-aptl[TXTBOX_TOPLEFT].y, -aptl[TXTBOX_BOTTOMLEFT].y); ! 95: } ! 96: ! 97: VOID ColorClient (HPS hps, LONG cxClient, LONG cyClient, LONG lColor) ! 98: { ! 99: RECTL rcl ; ! 100: ! 101: WinSetRect (hab, &rcl, 0, 0, (SHORT) cxClient, (SHORT) cyClient) ; ! 102: WinFillRect (hps, &rcl, lColor) ; ! 103: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.