2 * PostScript driver downloadable font functions
4 * Copyright 2002 Huw D M Davies for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
37 /****************************************************************************
40 static void get_download_name(PSDRV_PDEVICE *physDev, LPOUTLINETEXTMETRICA
45 len = strlen((char*)potm + (ptrdiff_t)potm->otmpFullName) + 1;
46 *str = HeapAlloc(GetProcessHeap(),0,len);
47 strcpy(*str, (char*)potm + (ptrdiff_t)potm->otmpFullName);
50 while((p = strchr(p, ' ')))
56 /****************************************************************************
59 static DOWNLOAD *is_font_downloaded(PSDRV_PDEVICE *physDev, char *ps_name)
63 for(pdl = physDev->downloaded_fonts; pdl; pdl = pdl->next)
64 if(!strcmp(pdl->ps_name, ps_name))
69 /****************************************************************************
70 * PSDRV_SelectDownloadFont
72 * Set up physDev->font for a downloadable font
75 BOOL PSDRV_SelectDownloadFont(PSDRV_PDEVICE *physDev)
78 LPOUTLINETEXTMETRICA potm;
79 DWORD len = GetOutlineTextMetricsA(physDev->hdc, 0, NULL);
81 potm = HeapAlloc(GetProcessHeap(), 0, len);
82 GetOutlineTextMetricsA(physDev->hdc, len, potm);
83 get_download_name(physDev, potm, &ps_name);
85 physDev->font.fontloc = Download;
86 physDev->font.fontinfo.Download = is_font_downloaded(physDev, ps_name);
88 physDev->font.size = INTERNAL_YWSTODS(physDev->dc, /* ppem */
89 potm->otmTextMetrics.tmAscent +
90 potm->otmTextMetrics.tmDescent -
91 potm->otmTextMetrics.tmInternalLeading);
92 physDev->font.underlineThickness = potm->otmsUnderscoreSize;
93 physDev->font.underlinePosition = potm->otmsUnderscorePosition;
94 physDev->font.strikeoutThickness = potm->otmsStrikeoutSize;
95 physDev->font.strikeoutPosition = potm->otmsStrikeoutPosition;
97 HeapFree(GetProcessHeap(), 0, ps_name);
98 HeapFree(GetProcessHeap(), 0, potm);
102 /****************************************************************************
103 * PSDRV_WriteSetDownloadFont
105 * Write setfont for download font.
108 BOOL PSDRV_WriteSetDownloadFont(PSDRV_PDEVICE *physDev)
111 LPOUTLINETEXTMETRICA potm;
112 DWORD len = GetOutlineTextMetricsA(physDev->hdc, 0, NULL);
115 assert(physDev->font.fontloc == Download);
117 potm = HeapAlloc(GetProcessHeap(), 0, len);
118 GetOutlineTextMetricsA(physDev->hdc, len, potm);
120 get_download_name(physDev, potm, &ps_name);
122 if(physDev->font.fontinfo.Download == NULL) {
123 pdl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pdl));
124 pdl->ps_name = HeapAlloc(GetProcessHeap(), 0, strlen(ps_name)+1);
125 strcpy(pdl->ps_name, ps_name);
128 if(physDev->pi->ppd->TTRasterizer == RO_Type42) {
129 pdl->typeinfo.Type42 = T42_download_header(physDev, potm,
133 if(pdl->typeinfo.Type42 == NULL) {
134 pdl->typeinfo.Type1 = T1_download_header(physDev, potm, ps_name);
137 pdl->next = physDev->downloaded_fonts;
138 physDev->downloaded_fonts = pdl;
139 physDev->font.fontinfo.Download = pdl;
143 PSDRV_WriteSetFont(physDev, ps_name, physDev->font.size,
144 physDev->font.escapement);
146 HeapFree(GetProcessHeap(), 0, ps_name);
147 HeapFree(GetProcessHeap(), 0, potm);
151 void get_glyph_name(HDC hdc, WORD index, char *name)
154 sprintf(name, "g%04x", index);
158 /****************************************************************************
159 * PSDRV_WriteDownloadGlyphShow
161 * Download and write out a number of glyphs
164 BOOL PSDRV_WriteDownloadGlyphShow(PSDRV_PDEVICE *physDev, WORD *glyphs,
168 char g_name[MAX_G_NAME + 1];
169 assert(physDev->font.fontloc == Download);
171 switch(physDev->font.fontinfo.Download->type) {
173 for(i = 0; i < count; i++) {
174 get_glyph_name(physDev->hdc, glyphs[i], g_name);
175 T42_download_glyph(physDev, physDev->font.fontinfo.Download,
177 PSDRV_WriteGlyphShow(physDev, g_name);
182 for(i = 0; i < count; i++) {
183 get_glyph_name(physDev->hdc, glyphs[i], g_name);
184 T1_download_glyph(physDev, physDev->font.fontinfo.Download,
186 PSDRV_WriteGlyphShow(physDev, g_name);
191 ERR("Type = %d\n", physDev->font.fontinfo.Download->type);
197 /****************************************************************************
198 * PSDRV_EmptyDownloadList
200 * Clear the list of downloaded fonts
203 BOOL PSDRV_EmptyDownloadList(PSDRV_PDEVICE *physDev)
206 if(physDev->font.fontloc == Download) {
207 physDev->font.set = FALSE;
208 physDev->font.fontinfo.Download = NULL;
211 pdl = physDev->downloaded_fonts;
212 physDev->downloaded_fonts = NULL;
216 T42_free(pdl->typeinfo.Type42);
220 T1_free(pdl->typeinfo.Type1);
224 ERR("Type = %d\n", pdl->type);
228 HeapFree(GetProcessHeap(), 0, pdl->ps_name);
231 HeapFree(GetProcessHeap(), 0, old);