Author: fejj
Date: 2007-11-02 17:20:24 -0500 (Fri, 02 Nov 2007)
New Revision: 88755
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/font.cpp
trunk/moon/src/font.h
trunk/moon/src/text.cpp
trunk/moon/src/text.h
Log:
2007-11-02 Jeffrey Stedfast <[EMAIL PROTECTED]>
* font.cpp (TextFontDescription::SetScale): Removed, this hack
wasn't working as well as I'd hoped.
(TextFontDescription::GetScale): Same.
(TextFontDescription::CreatePattern): If the requested font size
is < 41.0 (seems to be the magic number where scaling loses impact
on metrics), use FontSize=41.0 and do proper scaling to get the
actual size we want. My worry was that asking for small font sizes
(smaller than 16.0?) would look ugly with this hack, but that is
surprisingly not true. By always requesting a font size that will
yield the generic font metrics (e.g. not some hacked font size),
we will always be able to wrap identically no matter what FontSize
is requested (so long as the width gets scaled appropriately).
* text.cpp (TextBlock::ComputeTransform): Removed.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-11-02 22:14:29 UTC (rev 88754)
+++ trunk/moon/src/ChangeLog 2007-11-02 22:20:24 UTC (rev 88755)
@@ -1,5 +1,22 @@
2007-11-02 Jeffrey Stedfast <[EMAIL PROTECTED]>
+ * font.cpp (TextFontDescription::SetScale): Removed, this hack
+ wasn't working as well as I'd hoped.
+ (TextFontDescription::GetScale): Same.
+ (TextFontDescription::CreatePattern): If the requested font size
+ is < 41.0 (seems to be the magic number where scaling loses impact
+ on metrics), use FontSize=41.0 and do proper scaling to get the
+ actual size we want. My worry was that asking for small font sizes
+ (smaller than 16.0?) would look ugly with this hack, but that is
+ surprisingly not true. By always requesting a font size that will
+ yield the generic font metrics (e.g. not some hacked font size),
+ we will always be able to wrap identically no matter what FontSize
+ is requested (so long as the width gets scaled appropriately).
+
+ * text.cpp (TextBlock::ComputeTransform): Removed.
+
+2007-11-02 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
* font.cpp (RenderLine): Render glyphs with index 0 too, so that
we render an empty box for glyphs not in the font (just like
Silverlight).
Modified: trunk/moon/src/font.cpp
===================================================================
--- trunk/moon/src/font.cpp 2007-11-02 22:14:29 UTC (rev 88754)
+++ trunk/moon/src/font.cpp 2007-11-02 22:20:24 UTC (rev 88755)
@@ -661,7 +661,6 @@
weight = FontWeightsNormal;
stretch = FontStretchesNormal;
size = 14.666f;
- scale = 1.0f;
index = 0;
}
@@ -679,6 +678,8 @@
g_free (family);
}
+#define MIN_FONT_SIZE 41.0f
+
FcPattern *
TextFontDescription::CreatePattern ()
{
@@ -703,8 +704,13 @@
FcPatternAddInteger (pattern, FC_SLANT, fc_style (style));
FcPatternAddInteger (pattern, FC_WEIGHT, fc_weight (weight));
FcPatternAddInteger (pattern, FC_WIDTH, fc_stretch (stretch));
- FcPatternAddDouble (pattern, FC_PIXEL_SIZE, size * scale);
- FcPatternAddDouble (pattern, FC_SCALE, scale);
+ if (size < MIN_FONT_SIZE) {
+ FcPatternAddDouble (pattern, FC_PIXEL_SIZE, MIN_FONT_SIZE);
+ FcPatternAddDouble (pattern, FC_SCALE, MIN_FONT_SIZE / size);
+ } else {
+ FcPatternAddDouble (pattern, FC_PIXEL_SIZE, size);
+ FcPatternAddDouble (pattern, FC_SCALE, 1.0);
+ }
FcDefaultSubstitute (pattern);
@@ -780,9 +786,6 @@
if (mask & FontMaskSize)
size = 14.666f;
- if (mask & FontMaskScale)
- scale = 1.0f;
-
set &= ~mask;
}
@@ -849,15 +852,6 @@
set |= FontMaskSize;
}
- if ((desc->set & FontMaskScale) && (!(set & FontMaskScale) || replace))
{
- if (scale != desc->scale) {
- scale = desc->scale;
- changed = true;
- }
-
- set |= FontMaskScale;
- }
-
if (changed && font != NULL) {
font->unref ();
font = NULL;
@@ -974,19 +968,6 @@
set |= FontMaskSize;
}
-double
-TextFontDescription::GetScale ()
-{
- return scale;
-}
-
-void
-TextFontDescription::SetScale (double scale)
-{
- this->scale = scale;
- set |= FontMaskScale;
-}
-
char *
TextFontDescription::ToString ()
{
Modified: trunk/moon/src/font.h
===================================================================
--- trunk/moon/src/font.h 2007-11-02 22:14:29 UTC (rev 88754)
+++ trunk/moon/src/font.h 2007-11-02 22:20:24 UTC (rev 88755)
@@ -79,7 +79,6 @@
FontMaskStretch = 1 << 3,
FontMaskSize = 1 << 4,
FontMaskFilename = 1 << 5,
- FontMaskScale = 1 << 6,
};
@@ -165,7 +164,6 @@
FontStyles style;
FontWeights weight;
FontStretches stretch;
- double scale;
double size;
int index;
@@ -205,9 +203,6 @@
double GetSize ();
void SetSize (double size);
- double GetScale ();
- void SetScale (double scale);
-
char *ToString ();
};
Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp 2007-11-02 22:14:29 UTC (rev 88754)
+++ trunk/moon/src/text.cpp 2007-11-02 22:20:24 UTC (rev 88755)
@@ -820,31 +820,6 @@
}
void
-TextBlock::ComputeTransform ()
-{
- UIElement::ComputeTransform ();
-
- // We extract the scale component of the absolute transform
- // matrix and apply it to the font so that if we are scaling
- // up, the rendered glyphs don't look really bad. The font
- // itself will reverse-scale the rendering so that once the
- // trasnform is applied, it renders at the correct size.
-
- if (!RENDER_USING_PANGO) {
- double scale = font.custom->GetScale ();
-
- if (absolute_xform.yy != scale) {
- if (absolute_xform.yy <= 1.0)
- font.custom->UnsetFields (FontMaskScale);
- else
- font.custom->SetScale (absolute_xform.yy);
-
- dirty = true;
- }
- }
-}
-
-void
TextBlock::OnPropertyChanged (DependencyProperty *prop)
{
bool invalidate = true;
Modified: trunk/moon/src/text.h
===================================================================
--- trunk/moon/src/text.h 2007-11-02 22:14:29 UTC (rev 88754)
+++ trunk/moon/src/text.h 2007-11-02 22:20:24 UTC (rev 88755)
@@ -189,7 +189,6 @@
virtual void OnPropertyChanged (DependencyProperty *prop);
virtual void OnSubPropertyChanged (DependencyProperty *prop,
DependencyObject *obj, DependencyProperty *subprop);
virtual void OnCollectionChanged (Collection *col, CollectionChangeType
type, DependencyObject *obj, DependencyProperty *prop);
- virtual void ComputeTransform ();
virtual Value *GetValue (DependencyProperty *property);
virtual void SetValue (DependencyProperty *property, Value *value);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches