Commit be33dfbd authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

wineps: Remove no longer used font selection code from PE side.

parent 4e1de86d
......@@ -36,195 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
/***********************************************************************
* is_stock_font
*/
static inline BOOL is_stock_font( HFONT font )
{
int i;
for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++)
{
if (i != DEFAULT_PALETTE && font == GetStockObject(i)) return TRUE;
}
return FALSE;
}
/*******************************************************************************
* ScaleFont
*
* Scale builtin font to requested lfHeight
*
*/
static inline float Round(float f)
{
return (f > 0) ? (f + 0.5) : (f - 0.5);
}
static VOID ScaleFont(const AFM *afm, LONG lfHeight, PSFONT *font,
TEXTMETRICW *tm)
{
const WINMETRICS *wm = &(afm->WinMetrics);
USHORT usUnitsPerEm, usWinAscent, usWinDescent;
SHORT sAscender, sDescender, sLineGap, sAvgCharWidth;
float scale;
TRACE("'%s' %li\n", afm->FontName, lfHeight);
if (lfHeight < 0) /* match em height */
scale = - ((float)lfHeight / (float)(wm->usUnitsPerEm));
else /* match cell height */
scale = (float)lfHeight / (float)(wm->usWinAscent + wm->usWinDescent);
font->size.xx = (INT)Round(scale * (float)wm->usUnitsPerEm);
font->size.xy = font->size.yx = 0;
font->size.yy = -(INT)Round(scale * (float)wm->usUnitsPerEm);
usUnitsPerEm = (USHORT)Round((float)(wm->usUnitsPerEm) * scale);
sAscender = (SHORT)Round((float)(wm->sAscender) * scale);
sDescender = (SHORT)Round((float)(wm->sDescender) * scale);
sLineGap = (SHORT)Round((float)(wm->sLineGap) * scale);
usWinAscent = (USHORT)Round((float)(wm->usWinAscent) * scale);
usWinDescent = (USHORT)Round((float)(wm->usWinDescent) * scale);
sAvgCharWidth = (SHORT)Round((float)(wm->sAvgCharWidth) * scale);
tm->tmAscent = (LONG)usWinAscent;
tm->tmDescent = (LONG)usWinDescent;
tm->tmHeight = tm->tmAscent + tm->tmDescent;
tm->tmInternalLeading = tm->tmHeight - (LONG)usUnitsPerEm;
if (tm->tmInternalLeading < 0)
tm->tmInternalLeading = 0;
tm->tmExternalLeading =
(LONG)(sAscender - sDescender + sLineGap) - tm->tmHeight;
if (tm->tmExternalLeading < 0)
tm->tmExternalLeading = 0;
tm->tmAveCharWidth = (LONG)sAvgCharWidth;
tm->tmWeight = afm->Weight;
tm->tmItalic = (afm->ItalicAngle != 0.0);
tm->tmUnderlined = 0;
tm->tmStruckOut = 0;
tm->tmFirstChar = (WCHAR)(afm->Metrics[0].UV);
tm->tmLastChar = (WCHAR)(afm->Metrics[afm->NumofMetrics - 1].UV);
tm->tmDefaultChar = 0x001f; /* Win2K does this - FIXME? */
tm->tmBreakChar = tm->tmFirstChar; /* should be 'space' */
tm->tmPitchAndFamily = TMPF_DEVICE | TMPF_VECTOR;
if (!afm->IsFixedPitch)
tm->tmPitchAndFamily |= TMPF_FIXED_PITCH; /* yes, it's backwards */
if (wm->usUnitsPerEm != 1000)
tm->tmPitchAndFamily |= TMPF_TRUETYPE;
tm->tmCharSet = ANSI_CHARSET; /* FIXME */
tm->tmOverhang = 0;
/*
* This is kludgy. font->scale is used in several places in the driver
* to adjust PostScript-style metrics. Since these metrics have been
* "normalized" to an em-square size of 1000, font->scale needs to be
* similarly adjusted..
*/
scale *= (float)wm->usUnitsPerEm / 1000.0;
tm->tmMaxCharWidth = (LONG)Round(
(afm->FontBBox.urx - afm->FontBBox.llx) * scale);
TRACE("Selected PS font '%s' size %d weight %ld.\n", afm->FontName,
font->size.xx, tm->tmWeight );
TRACE("H = %ld As = %ld Des = %ld IL = %ld EL = %ld\n", tm->tmHeight,
tm->tmAscent, tm->tmDescent, tm->tmInternalLeading,
tm->tmExternalLeading);
}
/****************************************************************************
* PSDRV_SelectBuiltinFont
*
* Set up physDev->font for a builtin font
*
*/
BOOL PSDRV_SelectBuiltinFont(PHYSDEV dev, HFONT hfont,
LOGFONTW *plf, WCHAR *face_name)
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
AFMLISTENTRY *afmle;
FONTFAMILY *family;
BOOL bd = FALSE, it = FALSE;
TEXTMETRICW tm;
LONG height;
TRACE("Trying to find facename %s\n", debugstr_w(face_name));
/* Look for a matching font family */
for(family = physDev->pi->Fonts; family; family = family->next) {
if(!wcsicmp(face_name, family->FamilyName))
break;
}
if(!family) {
/* Fallback for Window's font families to common PostScript families */
if(!wcscmp(face_name, L"Arial"))
wcscpy(face_name, L"Helvetica");
else if(!wcscmp(face_name, L"System"))
wcscpy(face_name, L"Helvetica");
else if(!wcscmp(face_name, L"Times New Roman"))
wcscpy(face_name, L"Times");
else if(!wcscmp(face_name, L"Courier New"))
wcscpy(face_name, L"Courier");
for(family = physDev->pi->Fonts; family; family = family->next) {
if(!wcscmp(face_name, family->FamilyName))
break;
}
}
/* If all else fails, use the first font defined for the printer */
if(!family)
family = physDev->pi->Fonts;
TRACE("Got family %s\n", debugstr_w(family->FamilyName));
if(plf->lfItalic)
it = TRUE;
if(plf->lfWeight > 550)
bd = TRUE;
for(afmle = family->afmlist; afmle; afmle = afmle->next) {
if( (bd == (afmle->afm->Weight == FW_BOLD)) &&
(it == (afmle->afm->ItalicAngle != 0.0)) )
break;
}
if(!afmle)
afmle = family->afmlist; /* not ideal */
TRACE("Got font '%s'\n", afmle->afm->FontName);
physDev->font.fontloc = Builtin;
height = plf->lfHeight;
/* stock fonts ignore the mapping mode */
if (!is_stock_font( hfont )) {
POINT pts[2];
pts[0].x = pts[0].y = pts[1].x = 0;
pts[1].y = height;
LPtoDP(dev->hdc, pts, 2);
height = pts[1].y - pts[0].y;
}
ScaleFont(afmle->afm, height,
&(physDev->font), &tm);
/* Does anyone know if these are supposed to be reversed like this? */
tm.tmDigitizedAspectX = physDev->logPixelsY;
tm.tmDigitizedAspectY = physDev->logPixelsX;
return TRUE;
}
BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev)
{
struct font_info font_info;
......
......@@ -30,6 +30,7 @@
#include "winternl.h"
#include "psdrv.h"
#include "unixlib.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
......@@ -40,85 +41,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
HFONT CDECL PSDRV_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectFont );
HFONT ret;
LOGFONTW lf;
BOOL subst = FALSE;
struct font_info font_info;
if (!GetObjectW( hfont, sizeof(lf), &lf )) return 0;
*aa_flags = GGO_BITMAP; /* no anti-aliasing on printer devices */
TRACE("FaceName = %s Height = %ld Italic = %d Weight = %ld\n",
debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
lf.lfWeight);
if(lf.lfFaceName[0] == '\0') {
switch(lf.lfPitchAndFamily & 0xf0) {
case FF_DONTCARE:
break;
case FF_ROMAN:
case FF_SCRIPT:
wcscpy(lf.lfFaceName, L"Times");
break;
case FF_SWISS:
wcscpy(lf.lfFaceName, L"Helvetica");
break;
case FF_MODERN:
wcscpy(lf.lfFaceName, L"Courier");
break;
case FF_DECORATIVE:
wcscpy(lf.lfFaceName, L"Symbol");
break;
}
}
if(lf.lfFaceName[0] == '\0') {
switch(lf.lfPitchAndFamily & 0x0f) {
case VARIABLE_PITCH:
wcscpy(lf.lfFaceName, L"Times");
break;
default:
wcscpy(lf.lfFaceName, L"Courier");
break;
}
}
if (physDev->pi->FontSubTableSize != 0)
{
DWORD i;
for (i = 0; i < physDev->pi->FontSubTableSize; ++i)
{
if (!wcsicmp (lf.lfFaceName,
physDev->pi->FontSubTable[i].pValueName))
{
TRACE("substituting facename %s for %s\n",
debugstr_w((WCHAR *)physDev->pi->FontSubTable[i].pData), debugstr_w(lf.lfFaceName));
if (wcslen((WCHAR *)physDev->pi->FontSubTable[i].pData) < LF_FACESIZE)
if (ExtEscape(dev->hdc, PSDRV_GET_BUILTIN_FONT_INFO, 0, NULL,
sizeof(font_info), (char *)&font_info))
{
wcscpy(lf.lfFaceName, (WCHAR *)physDev->pi->FontSubTable[i].pData);
subst = TRUE;
physDev->font.fontloc = Builtin;
}
else
WARN("Facename %s is too long; ignoring substitution\n",
debugstr_w((WCHAR *)physDev->pi->FontSubTable[i].pData));
break;
}
}
}
physDev->font.escapement = lf.lfEscapement;
physDev->font.set = UNSET;
if (!subst && ((ret = next->funcs->pSelectFont( next, hfont, aa_flags ))))
{
PSDRV_SelectDownloadFont(dev);
return ret;
physDev->font.fontloc = Download;
physDev->font.fontinfo.Download = NULL;
}
PSDRV_SelectBuiltinFont(dev, hfont, &lf, lf.lfFaceName);
next->funcs->pSelectFont( next, 0, aa_flags ); /* tell next driver that we selected a device font */
return hfont;
}
......
......@@ -44,7 +44,6 @@ struct pp_data
WCHAR *out_file;
PSDRV_PDEVICE *pdev;
struct gdi_physdev font_dev;
struct brush_pattern *patterns;
BOOL path;
......@@ -155,31 +154,6 @@ static struct pp_data* get_handle_data(HANDLE pp)
return ret;
}
static HFONT CDECL font_SelectFont(PHYSDEV dev, HFONT hfont, UINT *aa_flags)
{
HFONT tt_font, old_font;
LOGFONTW lf;
*aa_flags = GGO_BITMAP;
if (!GetObjectW(hfont, sizeof(lf), &lf))
return 0;
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
tt_font = CreateFontIndirectW(&lf);
if (!tt_font)
return 0;
old_font = SelectObject(dev->hdc, tt_font);
DeleteObject(tt_font);
return old_font ? hfont : 0;
}
static const struct gdi_dc_funcs font_funcs =
{
.pSelectFont = font_SelectFont,
.priority = GDI_PRIORITY_FONT_DRV
};
static inline INT GDI_ROUND(double val)
{
return (int)floor(val + 0.5);
......@@ -3015,9 +2989,6 @@ HANDLE WINAPI OpenPrintProcessor(WCHAR *port, PRINTPROCESSOROPENDATA *open_data)
return NULL;
}
data->pdev->dev.hdc = hdc;
data->pdev->dev.next = &data->font_dev;
data->font_dev.funcs = &font_funcs;
data->font_dev.hdc = hdc;
return (HANDLE)data;
}
......
......@@ -535,8 +535,6 @@ BOOL PSDRV_GetType1Metrics(void) DECLSPEC_HIDDEN;
const AFMMETRICS *PSDRV_UVMetrics(LONG UV, const AFM *afm) DECLSPEC_HIDDEN;
SHORT PSDRV_CalcAvgCharWidth(const AFM *afm) DECLSPEC_HIDDEN;
extern BOOL PSDRV_SelectBuiltinFont(PHYSDEV dev, HFONT hfont,
LOGFONTW *plf, WCHAR *face_name) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteBuiltinGlyphShow(PHYSDEV dev, LPCWSTR str, INT count) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment