mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
win32 font point size fixes.
This commit is contained in:
parent
e58b915300
commit
a07ce814eb
2 changed files with 12 additions and 7 deletions
|
|
@ -130,7 +130,7 @@ class WindowsDirectWriteTypeface : public Typeface
|
|||
public:
|
||||
WindowsDirectWriteTypeface (const Font& font, IDWriteFontCollection* fontCollection)
|
||||
: Typeface (font.getTypefaceName(), font.getTypefaceStyle()),
|
||||
ascent (0.0f)
|
||||
unitsToHeightScaleFactor (1.0f), heightToPointsFactor (1.0f), ascent (0.0f)
|
||||
{
|
||||
jassert (fontCollection != nullptr);
|
||||
|
||||
|
|
@ -175,6 +175,10 @@ public:
|
|||
ascent /= totalSize;
|
||||
unitsToHeightScaleFactor = designUnitsPerEm / totalSize;
|
||||
|
||||
HDC tempDC = GetDC (0);
|
||||
heightToPointsFactor = (72.0f / GetDeviceCaps (tempDC, LOGPIXELSY)) * unitsToHeightScaleFactor;
|
||||
ReleaseDC (0, tempDC);
|
||||
|
||||
const float pathAscent = (1024.0f * dwFontMetrics.ascent) / designUnitsPerEm;
|
||||
const float pathDescent = (1024.0f * dwFontMetrics.descent) / designUnitsPerEm;
|
||||
const float pathScale = 1.0f / (std::abs (pathAscent) + std::abs (pathDescent));
|
||||
|
|
@ -183,7 +187,7 @@ public:
|
|||
|
||||
float getAscent() const { return ascent; }
|
||||
float getDescent() const { return 1.0f - ascent; }
|
||||
float getHeightToPointsFactor() const { return unitsToHeightScaleFactor; }
|
||||
float getHeightToPointsFactor() const { return heightToPointsFactor; }
|
||||
|
||||
float getStringWidth (const String& text)
|
||||
{
|
||||
|
|
@ -254,14 +258,14 @@ public:
|
|||
|
||||
private:
|
||||
ComSmartPtr<IDWriteFontFace> dwFontFace;
|
||||
float unitsToHeightScaleFactor, ascent;
|
||||
float unitsToHeightScaleFactor, heightToPointsFactor, ascent;
|
||||
int designUnitsPerEm;
|
||||
AffineTransform pathTransform;
|
||||
|
||||
class PathGeometrySink : public ComBaseClassHelper<IDWriteGeometrySink>
|
||||
{
|
||||
public:
|
||||
PathGeometrySink() { resetReferenceCount(); }
|
||||
PathGeometrySink() : ComBaseClassHelper<IDWriteGeometrySink> (0) {}
|
||||
|
||||
void __stdcall AddBeziers (const D2D1_BEZIER_SEGMENT *beziers, UINT beziersCount)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ public:
|
|||
|
||||
if (GetTextMetrics (dc, &tm))
|
||||
{
|
||||
heightToPointsFactor = 256.0f / tm.tmHeight;
|
||||
heightToPointsFactor = (72.0f / GetDeviceCaps (dc, LOGPIXELSY)) * heightInPoints / (float) tm.tmHeight;
|
||||
ascent = tm.tmAscent / (float) tm.tmHeight;
|
||||
defaultGlyph = getGlyphForChar (dc, tm.tmDefaultChar);
|
||||
createKerningPairs (dc, (float) tm.tmHeight);
|
||||
|
|
@ -355,7 +355,7 @@ private:
|
|||
HDC dc;
|
||||
TEXTMETRIC tm;
|
||||
float ascent, heightToPointsFactor;
|
||||
int defaultGlyph;
|
||||
int defaultGlyph, heightInPoints;
|
||||
|
||||
struct KerningPair
|
||||
{
|
||||
|
|
@ -403,7 +403,8 @@ private:
|
|||
OUTLINETEXTMETRIC otm;
|
||||
if (GetOutlineTextMetrics (dc, sizeof (otm), &otm) != 0)
|
||||
{
|
||||
lf.lfHeight = -(int) otm.otmEMSquare;
|
||||
heightInPoints = otm.otmEMSquare;
|
||||
lf.lfHeight = -(int) heightInPoints;
|
||||
fontH = CreateFontIndirect (&lf);
|
||||
|
||||
SelectObject (dc, fontH);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue