And migrated the IDWriteFont -> uiFontDescriptor code.

This commit is contained in:
Pietro Gagliardi 2018-03-11 22:17:16 -04:00
parent 1f61fb30de
commit 86264d32a0
4 changed files with 19 additions and 28 deletions

View File

@ -665,22 +665,3 @@ void caretDrawParams(uiDrawContext *c, double height, struct caretDrawParams *p)
// and there doesn't seem to be this either... (TODO check what PadWrite does?)
p->xoff = 0;
}
// TODO split this and the above related font matching code into a separate file?
void fontdescFromIDWriteFont(IDWriteFont *font, uiDrawFontDescriptor *uidesc)
{
DWRITE_FONT_STYLE dwitalic;
DWRITE_FONT_STRETCH dwstretch;
dwitalic = font->GetStyle();
// TODO reverse the above misalignment if it is corrected
uidesc->Weight = (uiDrawTextWeight) (font->GetWeight());
dwstretch = font->GetStretch();
for (uidesc->Italic = uiDrawTextItalicNormal; uidesc->Italic < uiDrawTextItalicItalic; uidesc->Italic++)
if (dwriteItalics[uidesc->Italic] == dwitalic)
break;
for (uidesc->Stretch = uiDrawTextStretchUltraCondensed; uidesc->Stretch < uiDrawTextStretchUltraExpanded; uidesc->Stretch++)
if (dwriteStretches[uidesc->Stretch] == dwstretch)
break;
}

View File

@ -131,12 +131,3 @@ public:
return true;
}
};
// TODO these should not be exported
extern std::map<uiDrawTextItalic, DWRITE_FONT_STYLE> dwriteItalics;
extern std::map<uiDrawTextStretch, DWRITE_FONT_STRETCH> dwriteStretches;
// drawtext.cpp
extern void fontdescFromIDWriteFont(IDWriteFont *font, uiDrawFontDescriptor *uidesc);
// opentype.cpp
extern IDWriteTypography *otfToDirectWrite(const uiOpenTypeFeatures *otf);

View File

@ -10,3 +10,4 @@ extern IDWriteTypography *uiprivOpenTypeFeaturesToIDWriteTypography(const uiOpen
extern DWRITE_FONT_WEIGHT uiprivWeightToDWriteWeight(uiTextWeight w);
extern DWRITE_FONT_STYLE uiprivItalicToDWriteStyle(uiTextItalic i);
extern DWRITE_FONT_STRETCH uiprivStretchToDWriteStretch(uiTextStretch s);
extern void uiprivFontDescriptorFromIDWriteFont(IDWriteFont *font, uiDrawFontDescriptor *uidesc);

View File

@ -41,3 +41,21 @@ DWRITE_FONT_STRETCH uiprivStretchToDWriteStretch(uiTextStretch s)
{
return dwriteStretches[s];
}
void uiprivFontDescriptorFromIDWriteFont(IDWriteFont *font, uiDrawFontDescriptor *uidesc)
{
DWRITE_FONT_STYLE dwitalic;
DWRITE_FONT_STRETCH dwstretch;
dwitalic = font->GetStyle();
// TODO reverse the above misalignment if it is corrected
uidesc->Weight = (uiDrawTextWeight) (font->GetWeight());
dwstretch = font->GetStretch();
for (uidesc->Italic = uiDrawTextItalicNormal; uidesc->Italic < uiDrawTextItalicItalic; uidesc->Italic++)
if (dwriteItalics[uidesc->Italic] == dwitalic)
break;
for (uidesc->Stretch = uiDrawTextStretchUltraCondensed; uidesc->Stretch < uiDrawTextStretchUltraExpanded; uidesc->Stretch++)
if (dwriteStretches[uidesc->Stretch] == dwstretch)
break;
}