From 86264d32a01f7ae3538646e6845c9f1c05e90732 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 11 Mar 2018 22:17:16 -0400 Subject: [PATCH] And migrated the IDWriteFont -> uiFontDescriptor code. --- windows/OLD_drawtext.cpp | 19 ------------------- windows/OLD_uipriv_attrstr.h | 9 --------- windows/attrstr.hpp | 1 + windows/fontmatch.cpp | 18 ++++++++++++++++++ 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/windows/OLD_drawtext.cpp b/windows/OLD_drawtext.cpp index 0db8fc9b..201d3a1d 100644 --- a/windows/OLD_drawtext.cpp +++ b/windows/OLD_drawtext.cpp @@ -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; -} diff --git a/windows/OLD_uipriv_attrstr.h b/windows/OLD_uipriv_attrstr.h index 1ef2b71f..360ec9e2 100644 --- a/windows/OLD_uipriv_attrstr.h +++ b/windows/OLD_uipriv_attrstr.h @@ -131,12 +131,3 @@ public: return true; } }; -// TODO these should not be exported -extern std::map dwriteItalics; -extern std::map dwriteStretches; - -// drawtext.cpp -extern void fontdescFromIDWriteFont(IDWriteFont *font, uiDrawFontDescriptor *uidesc); - -// opentype.cpp -extern IDWriteTypography *otfToDirectWrite(const uiOpenTypeFeatures *otf); diff --git a/windows/attrstr.hpp b/windows/attrstr.hpp index ca1226c5..56523aa5 100644 --- a/windows/attrstr.hpp +++ b/windows/attrstr.hpp @@ -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); diff --git a/windows/fontmatch.cpp b/windows/fontmatch.cpp index 05986dc1..034b9907 100644 --- a/windows/fontmatch.cpp +++ b/windows/fontmatch.cpp @@ -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; +}