[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11229: Improve compatibility of dev
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11229: Improve compatibility of device font rendering: get the size right, the |
Date: |
Wed, 08 Jul 2009 17:49:56 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11229
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-07-08 17:49:56 +0200
message:
Improve compatibility of device font rendering: get the size right, the
position generally (but not always) correct, but not the bounds of the
rendered text, which still needs doing.
modified:
libcore/swf/TextRecord.cpp
testsuite/misc-ming.all/DeviceFontTest.c
------------------------------------------------------------
revno: 11228.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-07-08 15:39:47 +0200
message:
Add bounding boxes.
modified:
testsuite/misc-ming.all/DeviceFontTest.c
------------------------------------------------------------
revno: 11228.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-07-08 15:39:55 +0200
message:
Fix the size and position of device fonts, but not the display bounds.
modified:
libcore/swf/TextRecord.cpp
------------------------------------------------------------
revno: 11228.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-07-08 16:22:11 +0200
message:
Improve tests.
modified:
testsuite/misc-ming.all/DeviceFontTest.c
------------------------------------------------------------
revno: 11228.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-07-08 16:22:20 +0200
message:
Correct for y scale.
modified:
libcore/swf/TextRecord.cpp
------------------------------------------------------------
revno: 11228.1.5
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-07-08 16:33:56 +0200
message:
Minor cleanups.
modified:
libcore/swf/TextRecord.cpp
------------------------------------------------------------
revno: 11228.1.6
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-07-08 16:47:08 +0200
message:
Clean up a bit more.
modified:
libcore/swf/TextRecord.cpp
------------------------------------------------------------
revno: 11228.1.7
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-07-08 17:08:21 +0200
message:
Device fonts are always solid.
modified:
libcore/swf/TextRecord.cpp
=== modified file 'libcore/swf/TextRecord.cpp'
--- a/libcore/swf/TextRecord.cpp 2009-06-15 11:32:49 +0000
+++ b/libcore/swf/TextRecord.cpp 2009-07-08 15:08:21 +0000
@@ -142,19 +142,32 @@
}
-// Render the given glyph records.
+///Render the given glyph records.
+//
+/// Display of device fonts is complicated in Gnash as we use the same
+/// rendering process as for embedded fonts.
+//
+/// The shape and position of a font relies on the concatenated transformation
+/// of its containing DisplayObject and all parent DisplayObjects.
+//
+/// Device fonts have the peculiarity that the glyphs are always scaled
+/// equally in both dimensions, using the y scale only. However, indentation
+/// and left margin (the starting x position) *are* scaled using the given
+/// x scale. The translation is applied as normal.
+//
+/// The proprietary player does not display rotated or skewed device fonts.
+/// Gnash does.
void
TextRecord::displayRecords(const SWFMatrix& mat, const cxform& cx,
const TextRecords& records, bool embedded)
{
// Starting positions.
- float x = 0.0f;
- float y = 0.0f;
+ double x = 0.0;
+ double y = 0.0;
- for (TextRecords::const_iterator i = records.begin(),
- e = records.end(); i !=e; ++i)
- {
+ for (TextRecords::const_iterator i = records.begin(), e = records.end();
+ i !=e; ++i) {
// Draw the DisplayObjects within the current record; i.e. consecutive
// chars that share a particular style.
@@ -177,22 +190,43 @@
log_debug("font for TextRecord == %p" static_cast<void*>(fnt));
#endif
- if (rec.hasXOffset()) x = rec.xOffset();
+ // If we are displaying a device font, we will not be applying the
+ // matrix's x scale to each glyph. As the indentation and left
+ // margin are affected by the x scale, we must set it manually here.
+ // Worse, as we will be applying the y scale, we cancel that out
+ // in advance.
+ if (rec.hasXOffset()) x =
+ embedded ? rec.xOffset() :
+ rec.xOffset() * mat.get_x_scale() / mat.get_y_scale();
+
if (rec.hasYOffset()) y = rec.yOffset();
- boost::int16_t startX = x; // for the underline, if any
-
- const rgba textColor = cx.transform(rec.color());
+ // Save for the underline, if any
+ const boost::int16_t startX = x;
+
+ rgba textColor = cx.transform(rec.color());
+
+ // Device fonts have no transparency.
+ if (!embedded) textColor.m_a = 0xff;
for (Glyphs::const_iterator j = rec.glyphs().begin(),
- je = rec.glyphs().end(); j != je; ++j)
- {
- // the glyph entry
+ je = rec.glyphs().end(); j != je; ++j) {
+
const TextRecord::GlyphEntry& ge = *j;
const int index = ge.index;
- SWFMatrix m = mat;
+ SWFMatrix m;
+ if (embedded) m = mat;
+ else {
+ // Device fonts adopt the concatenated translation.
+ m.concatenate_translation(mat.tx, mat.ty);
+ // Device fonts have each glyph scaled in both dimensions
+ // by the matrix's y scale.
+ const double textScale = mat.get_y_scale();
+ m.concatenate_scale(textScale, textScale);
+ }
+
m.concatenate_translation(x, y);
m.concatenate_scale(scale, scale);
@@ -227,8 +261,7 @@
x += ge.advance;
}
- if (rec.underline())
- {
+ if (rec.underline()) {
// Underline should end where last displayed glyphs
// does. 'x' here is where next glyph would be displayed
// which is normally after some space.
=== modified file 'testsuite/misc-ming.all/DeviceFontTest.c'
--- a/testsuite/misc-ming.all/DeviceFontTest.c 2009-07-08 11:38:40 +0000
+++ b/testsuite/misc-ming.all/DeviceFontTest.c 2009-07-08 14:22:11 +0000
@@ -62,36 +62,13 @@
SWFTextField_setLineSpacing(tf, lineSpacing);
SWFTextField_setColor(tf, textR, textG, textB, textA);
- /* setting flags seem unneeded */
- /*SWFTextField_setFlags(tf, SWFTEXTFIELD_USEFONT|SWFTEXTFIELD_NOEDIT);*/
+ SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX);
SWFTextField_addChars(tf, text);
SWFTextField_addString(tf, text);
- /*
- * Bounds computed by Ming (if we omit the setBounds call)
- * are 2640, 240. This means that we're shrinking the available
- * space with this explicit setting. Gnash chokes in this case.
- *
- * Ref: https://savannah.gnu.org/bugs/?func=detailitem&item_id=16637.
- */
- SWFTextField_setBounds(tf, 100, 100);
- //SWFTextField_setBounds(tf, 60000, 338);
-
- /*
- * The following settings (found in the reported SWF)
- * are not needed to exploit the bug.
- */
-
- /*SWFTextField_setHeight(tf, 240);*/
- /*SWFTextField_setColor(tf, 0x00, 0x00, 0x00, 0xff);*/
- /*SWFTextField_setAlignment(tf, SWFTEXTFIELD_ALIGN_LEFT);*/
- /*SWFTextField_setLeftMargin(tf, 0);*/
- /*SWFTextField_setRightMargin(tf, 0);*/
- /*SWFTextField_setIndentation(tf, 0);*/
- /*SWFTextField_setLineSpacing(tf, 40);*/
- /*SWFTextField_setLineSpacing(tf, 40);*/
-
+ SWFTextField_setBounds(tf, 80, 16);
+
return SWFMovie_add(mo, (SWFBlock)tf);
}
@@ -203,25 +180,25 @@
SWFDisplayItem_scale(it, 8, 1);
y += inc;
- it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 0.2", 1, 2, 3,
+ it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 0.2", 8, 8, 8,
SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
SWFDisplayItem_moveTo(it, 50, y);
SWFDisplayItem_scale(it, 0.2, 1);
y += inc;
- it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 8", 0, 0, 0,
- SWFTEXTFIELD_ALIGN_LEFT, 0, 0, 0, 0, 255);
+ it = add_text_field(mo, (SWFBlock)bfont, "Y scaled by 4", 4, 4, 0,
+ SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
SWFDisplayItem_moveTo(it, 50, y);
- SWFDisplayItem_scale(it, 8, 1);
-
- y += inc;
-
- it = add_text_field(mo, (SWFBlock)bfont, "Y scaled by 8", 1, 2, 3,
+ SWFDisplayItem_scale(it, 1, 4);
+
+ y += inc * 3;
+
+ it = add_text_field(mo, (SWFBlock)bfont, "Y scaled by 8", 4, 4, 0,
SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
SWFDisplayItem_moveTo(it, 50, y);
SWFDisplayItem_scale(it, 1, 8);
-
+
SWFMovie_nextFrame(mo);
/*****************************************************
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11229: Improve compatibility of device font rendering: get the size right, the,
Benjamin Wolsey <=